PDA

View Full Version : Capturing Overlay Screen using Opengl



rohitss
10-22-2002, 08:15 PM
Hi,
In main window, we are having Image with overlay plan above it having labeling information about that image.
We wrote the screen capture using opengl calls supported by MFC like
DescribePixelFormat
wglDescribeLayerPlane
wglMakeCurrent
DescribePixelFormat
SetPixelFormat
wglSetLayerPaletteEntries
wglRealizeLayerPalette
wglCreateLayerContext
wglMakeCurrent
wglSwapLayerBuffers
glReadBuffer
glReadPixels
It is running fine for the Image plan information but it is not able to get overlay plan information.

Any suggestions for this problem ?
or any way using opengl ?

Thanks,
Rohit

Relic
10-23-2002, 01:36 AM
Mainplane and overlay planes are different OpenGL contexts. It's not possible to read out the visible screen information of mainplane and overlay plane in one glReadPixels call, if that's what your trying. What you see is not what you get(tm). http://www.opengl.org/discussion_boards/ubb/smile.gif

rohitss
10-23-2002, 03:02 AM
Hi,
Iam not trying to get image data and overlay data in single glReadPixels call.
Iam ablr to get image data successfully
same trying for overlay data using...
HDC hDCScreen = GetDC(NULL);
SetupPixelFormat(hDCScreen);
hglrc = wglCreateContext(hDCScreen);
hglrc = wglCreateLayerContext
(hDCScreen,1/*For OVerlay*/);
wglMakeCurrent(hDCScreen, hglrc);
glubScreenshot = new GLubyte[(nWidth * nHeight)];
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, nWidth, nHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, glubScreenshot);

Still I ma not able to get Overlay data in
glubScreenshot.
And One more thing if I do PRINTSCREEN from keyboard still overlay data is not coming in image captured from PRINTSCREEN
Any suggestions ?
Thanks,
Rohit


Originally posted by Relic:
Mainplane and overlay planes are different OpenGL contexts. It's not possible to read out the visible screen information of mainplane and overlay plane in one glReadPixels call, if that's what your trying. What you see is not what you get(tm). http://www.opengl.org/discussion_boards/ubb/smile.gif

Relic
10-23-2002, 04:45 AM
HDC hDCScreen = GetDC(NULL); is a no-no!
Never ever call SetPixelformat on the desktop window!
You don't own it, you cannot destroy it, you cannot call SetPixelformat again that way. That is, your program only runs once per reboot. Set pixelformats only for windows YOU created.

And GDI does not know of overlays at all, it's an OpenGL private layer. There's no interface to access this additional frame buffer memory from GDI. You can access it via the OpenGL app that created it, of course.

Have you programmed an app which draws into the main plane and into the overlay plane yourself? Then the readpixels code must be implemented in there.
Or do you want to grab the OpenGL output of another program? This is at least highly implementation dependent, if it works at all.

And note that overlay planes are color indexed in general, you're reading BGR.

rohitss
10-23-2002, 05:08 AM
Hi Relic,
Yes...Iam trying to get overlay information which created by other application.
can this be possible through my application ?
Actually I trying to capture the whole monitor screen which is having Image data, and part of the monitor screen is having overlay data. Image data is coming but overlay data is not coming

Thanks a lot for your information...
if you have any suggestions please send it across.
Thanks again,
Rohit

Relic
10-23-2002, 06:25 AM
>>can this be possible through my application ?<<

I don't think so, it's a lost case.

Your OpenGL context does not own any of the other app's pixels (see the OpenGL spec on readback behaviour of unexposed window areas).
It would even be correct bahaviour if you would see nothing in your mainplane.
Simply put: You didn't draw anything in _your_ OpenGL application, so why should you expect meaningful data on readback.

rohitss
10-24-2002, 08:39 PM
Hi Relic,

>(see the OpenGL spec on readback behaviour >of unexposed window areas)

could you please tell me where I can find above mentioned stuff
Thanks,
Rohit

Relic
10-24-2002, 10:14 PM
The OpenGL spec can be found, uhm, on www.opengl.org?! (http://www.opengl.org?!)
Look on the right frame "OpenGL 1.4 spec (pdf)".