Deviding the screen...

Started by
3 comments, last by Kalidor 18 years, 7 months ago
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!
This world is ruled by big furry CATS!! :)Meow! :)
Advertisement
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.


Quote:Original post by kburkhart84
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.
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.
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...
This world is ruled by big furry CATS!! :)Meow! :)
Quote:Original post by Ancient Spirit
Text, 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.

This topic is closed to new replies.

Advertisement