# Rendering to a part of the screen

## Recommended Posts

jake_Ghost    103
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 on other sites
my best suggestion would be to research glScissor

try this:
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 on other sites
Kalidor    1087
Quote:
 Original post by jake_GhostI 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 on other sites
jake_Ghost    103
Alrite thx I'll try out the scissor test.

Jake