views:

58

answers:

1

Ok this is a little tricky. I'm detecting when an application goes into fullscreen mode (captures the display) and then i need to draw occasionally some stuff into the captured displays context for notification purposes (like Growl notifications, but has to work in fullscreen mode too).

Is there any way to modify another apps GL/CG context (For example Fraps on Windows does inject the FPS counter into OGL apps)? The shielding window overlay method unfortunately doesn't work when a display is captured. Any ideas?

Regards, Erik

Update


You can in fact draw over the screen with plain OpenGL and the Quartz Display Services. There are some drawbacks tough that i don't know how to work around.

  • The CGLSetFullScreen is deprecated and CGLSetFullScreenOnDisplay won't work with captured displays.

  • The drawing flickers because the other GL context interferes with this one

.

CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask(displayId);
CGLPixelFormatAttribute attribs[] = {
    kCGLPFAFullScreen,
    kCGLPFADisplayMask,
    displayMask,
    0
};

// Create gl context
GLint numPixelFormats;
CGLPixelFormatObj pixelFormatObj;
CGLChoosePixelFormat(attribs, &pixelFormatObj, &numPixelFormats);

CGLCreateContext(pixelFormatObj, NULL, &glContext);

CGLDestroyPixelFormat(pixelFormatObj);
CGLSetCurrentContext(glContext);
CGLSetFullScreen(glContext);

do {
    glLoadIdentity();

    glBegin(GL_TRIANGLES);

    glColor3f(1.0f, 0.0f, 0.0f);
    glVertex3f(0.0f, 1.0f, 0.0f);
    glColor3f(0.0f, 1.0f, 0.0f);
    glVertex3f(-1.0f, -1.0f, 0.0f);
    glColor3f(0.0f, 0.0f, 1.0f);
    glVertex3f(1.0f, -1.0f, 0.0f);

    glEnd();
    glFlush();

} while (!invalid);
A: 

The GLFullscreen sample application shows the old way and the 10.6+ way of creating fullscreen windows (and contexts). The new way is just a screen-sized window above most other things, while the old way is a special fullscreen mode that doesn't let anything else draw above it, with CGL. So if the application is using the new, simplified mechanism it may make a difference. I'm guessing you can't with the old way but might be able to with the new way.

Mk12
Yes but that's not the question. The question is how i can modify ANOTHER applications captured screen contents.
Erik Aigner
I know, and I'm saying it might depend on which way that OTHER application creates its fullscreen context.
Mk12
I tried the deprecated `CGLSetFullScreen` and it seems to work (the `CGLSetFullScreenOnDisplay` doesn't) even if the screen is already captured, so I might be able to render something on top. But i don't really want to use a deprecated function :(. I'll try getting it to work with the AGL calls (http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/AGL_OpenGL/Reference/reference.html)
Erik Aigner
Don't you mean NSGL? AGL is for Carbon.
Mk12