iDevGames Forums
"boingX" (transparent ogl) under carbon - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: "boingX" (transparent ogl) under carbon (/thread-6494.html)



"boingX" (transparent ogl) under carbon - GioFX - Jun 28, 2004 02:50 AM

Hi to all, and sorry my english, this is my first post!

my question is: I saw the boingX sample and I'm interested in putting
the same effect in a carbon (XCode1.2) app.

First of all I found the SetWindowAlpha() statement to change the windows behaviour in a trasparent one, then AGL_SURFACE_OPACITY enable the same as NB.....SurfaceOpacity cocoa instruction, now I dont understand how to make a SOLID object in the middle of the desktop ... the object change his transparency value accordly to the AGL_SURFACE_OPACITY so it is semitransparent too.

tnx in advance
Gio


"boingX" (transparent ogl) under carbon - akisha - Jun 28, 2004 08:52 AM

Never having seen the boingX sample, I'm not quite sure what you're asking. If you want a transparent window (no frame, widgets, or background) and an opaque OpenGL context, what you want to do is create an overlay window.

First, create the window using CreateNewWindow
Code:
SetRect(&Bounds, 50, 50, 350, 350);
CreateNewWindow(kOverlayWindowClass,
    kWindowNoAttributes, &Bounds, &Window);
ShowWindow(Window);
Notice the window class is "kOverlayWindowClass" and the attributes parameter is "kWindowNoAttributes".

Create the AGL ContextÖ
Code:
Format = aglChoosePixelFormat(NULL, 0, Attrib);
Context = aglCreateContext(Format, NULL);
aglSetDrawable(Context, GetWindowPort(Window));
aglSetCurrentContext(Context);
aglDestroyPixelFormat(Format);

Now, we need to set the context opacity so that it can have a transparent background.
Code:
GLint Opacity = 0;
aglSetInteger(Context, AGL_SURFACE_OPACITY, &Opacity);
glClearColor(0, 0, 0, 0);

That's it. Draw into the context like you would normally. Instead of filling the context with a color, glClear(GL_COLOR_BUFFER_BIT) will "erase" what you've drawn, making the window completely transparent.


"boingX" (transparent ogl) under carbon - GioFX - Jun 29, 2004 09:08 AM

woah!
1024K thanks Akisha!!

Gio