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 andCGLSetFullScreenOnDisplay
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);