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