How to draw objects only partly?

Started by
6 comments, last by ernii 17 years, 7 months ago
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
Advertisement
It seems glScissors is exactly what I need :) ... I'm just checking it out.
Yes, that sounds correct.
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
Or glScissor of course if rectangles are all you want :-)

Skizz
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
Stencilling out parts of the framebuffer is exactly what the stencil buffer is meant for.
;) 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

This topic is closed to new replies.

Advertisement