Jump to content
  • Advertisement
Sign in to follow this  
TeSsL

glclearcolor

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

Hi.. Can i have different clearcolor for different viewport? How do i do it. If not, lets say my second viewport is at gl.glViewport(0, HEIGHT/4, WIDTH, HEIGHT/3-50), How do i know the real coordinate to draw a quad the same size? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Method 1 :

when clearing the background color, you don't need to draw a quad.

just set the viewport and then set glClearColor, once that is done, just to glClear( GL_COLOR_BUFFER_BIT );


Method 2 :

If you are wanting to render 2D quads in 2D, then just set your projection to orthographic glOrtho or glOrtho2D. Then you can draw in 2D and know the placement of the quad. Make sure to set the modelview to the identity before proceeding.

Share this post


Link to post
Share on other sites
Oh thanks, used method 2 and is working now.
But now i encounter another problem. Currently i am drawing a quad in the viewport as the backcolor. and when i change to a second viewport which is within the first viewport, everything i render on the second viewport seems to go under the the backcolor. Shouldn't obj drawn last be on the top?
Or is it because i made use of different projection mode? my first viewport uses Ortho so the quad i draw does not contain z. But the 2nd viewport uses perspective view with some z values. Can this be the reason? What should i include so as not to change my projection matrix for both and at the same time achieving what is required.

Share this post


Link to post
Share on other sites
First of all, don't draw a quad to clear the screen. That screws up hierarchical Z-testing, which can lead to a huge performance hit.

Second of all... nah. Fix that first.

Share this post


Link to post
Share on other sites
as Sneftel saiz if u wanna clear to a solid color use glClear + dont draw a quad (though if u wanna clear to a picture background or gradient though u have to do this)

perhaps try glScissor(..) Im not sure though if this restricts the area that glClear works in, but try it

Share this post


Link to post
Share on other sites
Quote:
Original post by zedz
perhaps try glScissor(..) Im not sure though if this restricts the area that glClear works in, but try it

It does. The scissor test is one of the few things actually affecting glClear.

In general, if you want a viewport not covering the whole client area, it is a good idea to match the viewport with scissor box. The viewport does not perform clipping, so drawing outside the viewport is possible, and usually unwanted.

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!