Jump to content
  • Advertisement
Sign in to follow this  
HuaMuLan

OpenGL Draw a viewport inside a viewport

This topic is 2785 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

Generally , I want "Draw a viewport inside a viewport".

And My idear is something like below:
------------------------------------------------------
float ar = (float) width / (float) height;
glGetIntegerv(GL_SCISSOR_BOX,para);
glGetIntegerv(GL_VIEWPORT,para1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();


glViewport(xof,yof,width,height);
glScissor(xof,yof,width,height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;

glClearColor(0.0f,0.0f,0.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,1.0f,1.0f);
glTranslated(0.0f,0.0f,-6.0f);
drawsolidcube(1);

glViewport(para1[0],para1[1],para1[2],para1[3]);
glScissor(para[0],para[1],para[2],para[3]);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
-----------------------------------------------------------------
With same viewport width,height drawsolidcube() translation and also glFrustum params .
It works when I test it.
http://i486.photobucket.com/albums/rr230/HuaMuLanChina/test-1.png
But when I nest it into blender(which did all the UI drawings with opengl),
only black rectangle viewport without box(did by drawsolidcube function).
http://i486.photobucket.com/albums/rr230/HuaMuLanChina/failed.jpg
I want to known where the possible problems lay?

Thanx in advance.

[Edited by - HuaMuLan on December 5, 2010 12:46:55 PM]

Share this post


Link to post
Share on other sites
Advertisement
I do it like this:

- Set viewport1 to some size and location
- Save it's global location and size in variables
- Draw stuff that belongs to viewport1

- Before setting viewport2 check if it's size and location lie inside viewport1. If it doesn't crop it accordingly (just recalculate x,y,w,h)
- Set viewport2
- Draw stuff that belongs to viewport2

Share this post


Link to post
Share on other sites
Sorry for interruption.
Stupid problem but quite tricky.
I invoke the drawsolidcube(1) function without declaration "extern void drawsolidcube(float size);"
But I passed the checking of vs compiler , only with param size always 0.
So nothing can be seen. :P

Share this post


Link to post
Share on other sites
What interruption? And what happened to the viewport inside a viewport thing?

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!