Jump to content
  • Advertisement
Sign in to follow this  
mlt

Different view-ports with different colors?

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

Is it possible to have two view-ports in one window each with its own background color? I have tried:
glPushAttrib(GL_VIEWPORT_BIT);
  glClearColor(0.0, 0.0, 1.0, 1.0); // blue
  glViewport(0, 0, 150, 150);
     render_obj1();
glPopAttrib();

glClearColor(0.5, 0.5, 0.5, 0.5);


// Use full view-port
     render_obj2();


But both objects are drawn on a dark gray background.

Share this post


Link to post
Share on other sites
Advertisement
The viewport only defines a transformation from normalized device coordinates to screen space, nothing else. If you want to prevent something from being drawn outside the viewport, you need to setup a scissor box also. The viewport itself does nothing to prevent drawing outside the viewport. Check glScissor, and don't forget to enable the scissor test.

Share this post


Link to post
Share on other sites
glClearColor only sets the color that is set when calling glClear (which you need to call also. only then is the color changed).

so, simply, define window, setup vp1 i a part, clear, render; setup viewport2 somewhere else, clear, render.
(this with viewports not overlapping eachother in any way)


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!