Jump to content
  • Advertisement
Sign in to follow this  
Ancient Spirit

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.

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

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
Share on other sites
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 areas

glViewport(/*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.

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!