Circular Clipping Window

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.

Use the stencil buffer.

Or you could just mask it with a texture of a “hole” applied to a quad.

Stencil buffer is way too slow.

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

Use the Z buffer. Render your clip shape with colour writes disabled and z-writes enabled.

Originally posted by heath:
Or you could just mask it with a texture of a “hole” applied to a quad.

Aka Alpha test.

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.

-Won

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

Thanks!

Julio.

‘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().

Hi!

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,

Julio.

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” :).

Hi!

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!

Julio.