Viewports Viewports
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.
I'm not sure what you're trying to do. But glViewport will only set the size of your viewport...
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]
edit: The docs say it should just clear the viewport.
[Edited by - Boder on May 8, 2006 2:05:07 AM]
So how to clear only the viewport? If you've every use D3D, setting the viewport only clear a portion associated with the viewport.
My only guess from the code is that somehow the second call to glViewport() takes up the whole window.
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.
I guess the documentation means "window" when they say "the viewport"
I guess you'll have to get out your scissors.
I guess you'll have to get out your scissors.
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...).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement