Jump to content
  • Advertisement
Sign in to follow this  
jake_Ghost

Rendering to a part of the screen

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a map in my game and I wanted to know how to render to a part of the screen instead of the full thing. Currently, thats what I do and I don't want to do that , I just want it to be rendered to the top right corner for example. How might I go about doing this? Jake

Share this post


Link to post
Share on other sites
Advertisement
my best suggestion would be to research glScissor

try this:
render your entire scene
glScissor(x, y, width, height);
glEnable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT); //this clears the area inside of the scissor region
draw what you want inside of that box
glDisable(GL_SCISSOR_TEST);

easy enough?

Share this post


Link to post
Share on other sites
Quote:
Original post by jake_Ghost
I have a map in my game and I wanted to know how to render to a part of the screen instead of the full thing. Currently, thats what I do and I don't want to do that , I just want it to be rendered to the top right corner for example. How might I go about doing this?

Jake
Assuming you are using an orthographic projection with the origin at the bottom-left and (width,height) at the top-right, for a fullscreen quad you would do something like...
glBegin(GL_QUADS);
glVertex2f(0.0f, 0.0f);
glVertex2f(width, 0.0f);
glVertex2f(width, height);
glVertex2f(0.0f, height);
glEnd();
Which you said you know already. So for a quad that's the top-right quarter of the screen it's the same thing except you start at the center of the screen (width/2, height/2) instead of the bottom-left, go to center-right, then top-right, and finally top-center like so...
glBegin(GL_QUADS);
glVertex2f(width/2.0f, height/2.0f);
glVertex2f(width, height/2.0f);
glVertex2f(width, height);
glVertex2f(width/2.0f, height);
glEnd();
Simple as that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!