Jump to content
  • Advertisement
Sign in to follow this  
Simplicity

Viewports Viewports

This topic is 4548 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 need to render multiple viewports onto a window and have viewports of different size but I can't get it to work with glViewport: glViewport( 0, 0, WinWidth, WinHeight ); glClearColor(1.0f, 1.0f, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glViewport( 0, 0, WinWidth * 0.5f, WinHeight * 0.5f ); glClearColor(1.0f, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); What gets clear is the second one, but to the whole window.

Share this post


Link to post
Share on other sites
Advertisement
Looks like glClear() clears the whole window instead of just the viewport.

edit: The docs say it should just clear the viewport.

[Edited by - Boder on May 8, 2006 2:05:07 AM]

Share this post


Link to post
Share on other sites
So how to clear only the viewport? If you've every use D3D, setting the viewport only clear a portion associated with the viewport.

Share this post


Link to post
Share on other sites
My only guess from the code is that somehow the second call to glViewport() takes up the whole window.

Share this post


Link to post
Share on other sites
As far as I am aware, glClear(GL_COLOR_BUFFER_BIT) clears the _whole_ color buffer. glViewport will only affect the normalised device coord to window space transformation. To clear a single viewport just draw a quad of the required colour in the viewport - it isn't ideal but it's quick and it works.

Share this post


Link to post
Share on other sites
I guess the documentation means "window" when they say "the viewport"

I guess you'll have to get out your scissors.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kuladus
As far as I am aware, glClear(GL_COLOR_BUFFER_BIT) clears the _whole_ color buffer. glViewport will only affect the normalised device coord to window space transformation. To clear a single viewport just draw a quad of the required colour in the viewport - it isn't ideal but it's quick and it works.


Just to notice that with this method, others buffers won't be cleared (depth, accum...).

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!