Jump to content
  • Advertisement
Sign in to follow this  
darkbard

OpenGL 2d Clipping

This topic is 5129 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, I-m usign OpenGL to draw a 2D animation, and I'd like to know how can I manage Clipping so I can redraw only what changes and not the whole window content. I find out glClipPlane function, but I can't understand the second parameter: what should be the right array I have to pass to redraw only data contained inside a giving rectangle (x,y and w,h)? tnx p.s: maybe I don't understand OpenGL clipping, and glClipPlane does not fit my needs. In this case can u tell me how 2D clipping works in OpenGL? bye

Share this post


Link to post
Share on other sites
Advertisement
If you want to be able to use glClear on only a specified segment of the screen, use a scissor test.

define the area to be affected with

glScissor(LeftSide, BottomSide, RightSide, TopSide)

you can then

glEnable(GL_SCISSOR_TEST)
glClear(GL_COLOR_BUFFER_BIT)
glDisable(GL_SCISSOR_TEST)

Using this, you can clear whatever rectangle of the screen you wish.

Share this post


Link to post
Share on other sites
Ok, and what about drawing only inside the cleaned part of the screen (as I'd do with GDI) without drawing out of its borders?

Share this post


Link to post
Share on other sites
You can use the stencil buffer to "cover up" the areas that you don't want to draw to. Hehe, I forgot to mention that part.. sorry.

Share this post


Link to post
Share on other sites
Quote:
Original post by darkbard
Ok, and what about drawing only inside the cleaned part of the screen ?

Use scissor testing again.
The only problem with scissoring is that you're merely limited to rectangular regions.
Stencil buffer can be thougher to use, needs better hardware, and needs more memory (added bits in the framebuffer) and more processing power (clearing costs), but at least with stencil buffer you can define any kind of shape for your mask (ie you're not limited to rectangular clipping anymore).

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!