"boingX" (transparent ogl) under carbon
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
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
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
Notice the window class is "kOverlayWindowClass" and the attributes parameter is "kWindowNoAttributes".
Create the AGL ContextÖ
Now, we need to set the context opacity so that it can have a transparent background.
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.
First, create the window using CreateNewWindow
Code:
SetRect(&Bounds, 50, 50, 350, 350);
CreateNewWindow(kOverlayWindowClass,
kWindowNoAttributes, &Bounds, &Window);
ShowWindow(Window);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."
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Transparent textures | kordeul | 2 | 2,150 |
Aug 27, 2007 01:38 AM Last Post: kordeul |
|
| OpenGL, SDL, and Transparent Bitmaps | RyanA | 4 | 3,362 |
Jun 26, 2006 04:26 PM Last Post: RyanA |
|
| About transparent colors un textures | valle | 2 | 2,476 |
Oct 26, 2004 09:52 AM Last Post: valle |
|
| Blending mode for Transparent fog? | JeroMiya | 2 | 2,423 |
Jan 30, 2004 08:09 AM Last Post: MattDiamond |
|
| Panther + BoingX | MacFiend | 4 | 2,951 |
Jan 10, 2004 08:12 AM Last Post: MacFiend |
|

