Sign in to follow this  
ernii

OpenGL How to draw objects only partly?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this