"boingX" (transparent ogl) under carbon

GioFX
Unregistered
 
Post: #1
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
Quote this message in a reply
Member
Posts: 20
Joined: 2002.12
Post: #2
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.

"Programmers are tools for converting caffeine into code."
Quote this message in a reply
GioFX
Unregistered
 
Post: #3
woah!
1024K thanks Akisha!!

Gio
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Transparent textures kordeul 2 2,578 Aug 27, 2007 01:38 AM
Last Post: kordeul
  Panther + BoingX MacFiend 4 3,190 Jan 10, 2004 08:12 AM
Last Post: MacFiend
  Transparent Color? Josh 6 5,789 Apr 22, 2002 05:27 AM
Last Post: Josh