Jump to content
  • Advertisement
Sign in to follow this  
ernii

OpenGL How to draw objects only partly?

This topic is 4309 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 again a question relating to GUIs in OpenGL, each widget has useally a parent (except the RootPane) and should only be able to draw in that area ... So that results to situations where you have objects that should only be partly drawn, like when you have something with a scrollbar naturaly the content inside has such situations. Is there a simple way to do that in opengl? cu & thx ernii

Share this post


Link to post
Share on other sites
Advertisement
You can use glClipPlane to define the extents of the panel. Alternatively, use the Z buffer. Clear the Z buffer with values very close to camera, then, prior to rendering the panel, set Z buffer for panel area to very far away. Set Z value of polygons drawn to somewhere between the two. After drawing panel, set Z buffer values back to near to camera values. This is probably a quicker method than glClipPlane and does allow you to do some more complex shaped clipping regions.

Skizz

Share this post


Link to post
Share on other sites
Okay I did not think this through ;) ... I implemented it with glScissor in 2D, works fine, only if I do "effects" like rotating that are 3D it need a more complex form ...
So I will have a look at the Z Buffer method (thank you Skizz) and the Stencil Buffer should be good for that too?

cu & thx
ernii

Share this post


Link to post
Share on other sites
;) okay kind of a stupid question ...

But I have a problem with it now ...
It implemted it like this:
Every widget gets a layer which is like its depth in the widget hirachy (so the rootplane has 0, a panel on that 1, a child of that panel 2 ...)
I check if the value in the stencil buffer is level-1, and if that is the case I increase it by one.
This method works fine, but a child is now allowed to draw in the siblings of his parent :(.

I can't give every widget a single id since the stencil buffer is only 8bit ...
I was thinking about redrawing the stencil buffer everytime before drawing the next child ... but that would cause so much more drawing that I think it's not a solution ...

Any ideas for that?

cu
ernii

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!