# OpenGL Deviding the screen...

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

## Recommended Posts

Using: OpenGL API C++, MSVS .NET Problem: I want to devide the screen into to two parts... I have made a perspective at the init of OpenGL and now i want to devide that perspective into 2 different ones... Can you help me? Thanks in advance!

##### Share on other sites
I use the glViewport command to do it, but I have heard of the glScissor function as well. I don't know how that one works though. With glViewport for example, if you use a resolution of 800x600, then set the params of glViewport accordingly. So for the top of the screen, I believe it is glViewport(0, 300, 800, 300). The first two are the start of the rect and the second two are the number of pixels in length of the rect. I'm not sure exactly if that is correct, but that is an idea of how it works. I already "black-boxed" that function, so I don't remember exactly though.

##### Share on other sites
Quote:
 Original post by kburkhart84I use the glViewport command to do it, but I have heard of the glScissor function as well. I don't know how that one works though. With glViewport for example, if you use a resolution of 800x600, then set the params of glViewport accordingly. So for the top of the screen, I believe it is glViewport(0, 300, 800, 300). The first two are the start of the rect and the second two are the number of pixels in length of the rect. I'm not sure exactly if that is correct, but that is an idea of how it works. I already "black-boxed" that function, so I don't remember exactly though.
It is a good idea to use both glViewport and glScissor because the viewport itself doesn't clip things. It's pretty common that the viewport is the entire screen so most people don't realize this. More info on this can be found here, pitfall 10.

##### Share on other sites
the thing is that i want a top part to have text...
middle left - GUI
the rest is rendering...
---------------------------------------------Text                                        |---------------------------------------------       |                                    |       |                                    |  GUI  |                                    |       |                                    |       |            Rendering               |       |                                    |       |                                    |       |                                    |       |                                    |---------------------------------------------

All frames should be updated and they should have different Perspective system...

Text, GUI - ORTHO (Not a problem)
Rendering - Different perspective - that is the problem...

##### Share on other sites
Quote:
 Original post by Ancient SpiritText, GUI - ORTHO (Not a problem)Rendering - Different perspective - that is the problem...
Just change the viewport and scissor to correspond to the rendering area, then set a perspective projection and render.

EDIT: Here's a basic rundown...

//Render the text and gui areasglViewport(/*rendering area*/);glScissor(/*rendering area*/);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(/*perspective projection parameters*/);glMatrixMode(GL_MODELVIEW);glLoadIdentity();//Now render everything that goes into the Rendering area

That should be basically all you need.

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633328
• Total Posts
3011380
• ### Who's Online (See full list)

There are no registered users currently online

×