Jump to content
  • Advertisement
Sign in to follow this  
Daniel Lee

OpenGL viewports 1st one no show

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

i'd adapted the example from nehe lesson 42 to show 2 openGL context. Lets call it viewport-A and viewport-B. the code is as follows but note that the issue was that viewport-A showed no graphics and viewport-B did. why ? void draw(){ for(int loop=0; loop < 2; loop++){ /// viewport-A setup if(loop == 0){ /// set the top viewport glViewport( 0, pScreen->h/4, pScreen->w, 3*(pScreen->h)/4); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( 45.0f, pScreen->w / (3*(pScreen->h)/4), 10.0f, 5000.0f); }/// end of viewport-A glContext Setup /// viewport-B setup if(loop == 1){ glViewport( 0, 0, pScreen->w, (pScreen->h)/4); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( 45.0f, pScreen->w / ((pScreen->h)/4), 10.0f, 5000.0f); }/// end of viewport-B glContext Setup /*- common 3Lines -*/ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClear(GL_COLOR_BUFFER_BIT); /// viewport-A rendering if(loop == 0){ if(!bViewportA){ glTranslatef(0, -10.0, -100.0); if (LoadFile(&obj,"A.xxx") == 0){ printf("file not found !\n"); }; glNewList(listA, GL_COMPILE_AND_EXECUTE); glShadeModel(GL_SMOOTH); renderVP(obj); glEndList(); bViewportA = true; }else glTranslatef(0, -10.0, -100.0); glRotatef(0.0, 0.0, 1.0, 0.0); glCallList(listA); }/// end of viewport-A rendering /// viewport-B rendering if(loop == 1){ if(!bViewportB_0){ glTranslatef(-100.0, -10.0, -200.0); if (LoadFile(&obj,"B.xxx") == 0){ printf("file not found !\n"); }; glNewList(listB, GL_COMPILE_AND_EXECUTE); glShadeModel(GL_SMOOTH); renderVP(obj); glEndList(); bViewportB_0 = true; }else glTranslatef(-100.0, -10.0, -200.0); glCallList(listB); /*-- end of viewport_B:0 ----.*/ }/// end of for(loop) glFlush(); SDL_GL_SwapBuffers(); SDL_Delay(t); }///end of draw(). At this length please note that only viewport-A did not show the gl Graphics. What else is missing or where's that bug. ciao

Share this post


Link to post
Share on other sites
Advertisement
First of all, you only need to create the display lists once, secondly, I think you could put more code up after cleaning it up. I can't see what ifs go for what and I don't see where the current viewport variable is changed, though I see it used. Maybe in the rest of the code, you set it always to the second view somewhere.

Share this post


Link to post
Share on other sites
i'd experimented with the common "3Lines" and if those were places outside the for-loop, the 2 viewports can show the opengl graphics, but if those "3Lines" were placed as shown in the previous extract then only the viewport-B has graphics.

it seemed that the placing of those "3Lines" outside the for-loop (before the viewport setup) had produced graphics in the viewports but the translations and rotations is effective only once. That is no continuous animation.

what's your thought of that.
ciao

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!