View Full Version : Circular Clipping Window

12-15-2003, 04:34 AM
Is there any way to create a circular clipping window?

What I'd like to do is render a scene that will sometimes be displayed on the whole screen and other times be clipped away leaving only a circluar portion in the middle... kind of like looking through a circular window.

12-15-2003, 04:54 AM
Use the stencil buffer.

12-15-2003, 06:35 AM
Or you could just mask it with a texture of a "hole" applied to a quad.

12-16-2003, 06:48 AM
Stencil buffer is way too slow.

Anybody have a better solution for this. I am searching for an answer as well. Thanks.

Pop N Fresh
12-16-2003, 08:35 AM
Use the Z buffer. Render your clip shape with colour writes disabled and z-writes enabled.

12-16-2003, 04:12 PM
Originally posted by heath:
Or you could just mask it with a texture of a "hole" applied to a quad.

Aka Alpha test.

12-19-2003, 10:36 AM
Doesn't alpha test compare the incoming fragment's alpha component with a constant? In order to use that here, you'd have to turn on texgen and use an alpha texture or something.

Depth is probably the way to go.


04-25-2011, 06:38 AM
Hi everyone! Sorry for reviving this thread...

I'm trying to migrate some app from X11 to 'pure' OpenGL so I need something similar to X11 Nonrectangular Window Shape Extension in OpenGL.

I see some suggestions here, but does anyone managed to implement circular clipping? Is there an easy and efficient way to do that?

I'm a newbie in OpenGL so any help would be very welcome!!!!



Ilian Dinev
04-25-2011, 08:16 AM
'pure' OpenGL does not do _any_ windowing. That's why you use a windowing lib/system, depending on the OS, to create a window and initialize it for use with a GL context, and then create and bind a GL context with it. WGL for Windows, X11 for linux, EGL for some hopeful cross-platforming.
Under Windows, you'd make the window be layered, and update its shape/alpha once or every frame with UpdateLayeredWindow() from data gotten via glReadPixels().

04-25-2011, 10:59 AM

I forgot to mention: I'm actually using GLUT to create/manipulate windows at my OpenGL app.

Unfortunatelly, MS Windows is out of context for me. Is still there an option for circular clipping at Linux/Ubuntu/GLUT platform?

Thanks again,


Ilian Dinev
04-25-2011, 10:25 PM
I re-checked the src of glut and freeglut, and both use wgl on windows, x11 otherwise.
So, grab the x11 wnd-handle, and use the "X11 Nonrectangular Window Shape Extension" :).

04-26-2011, 05:29 AM

Ok thanks, IŽll do that.

As a matter of fact, the only way I managed to do circular clipping and OpenGL drawing was defining an Xlib clipped Window (XShapeQueryExtension) and binding that window to an OpenGL context with GLX (glXMakeCurrent). It worked pretty well but, unfortunately, it is not a portable choice, once it depends on X11/Xlib.

I thought glut would provide me an option for circular clipping on both MS Windows and X11 environments.

I was also wondering if GTK would also give me a portable choice.

Thanks again!