
Screenshot of external app/game
Posted Wednesday, 24 February, 2010 - 14:44 by relic inHello!
I'm writing application, which should take screenshots of extrenal app/game (opengl).
So, as far as i have found it's done by using GL.ReadPixels (glReadPixels) method, but using it alone produces nullreference exception.
Could you enlight me how can i do it? Should i hook into game/ or catch app's graphicscontext/ bind frame buffer, if so, how it's done.
I coudn't find in docs about this stuff, only about creating your one context, which i don't need.
Some code example would be really great.
Thanks,
P.S. I'm new to OpenGL & OpenTK


Comments
Re: Screenshot of external app/game
P.S.S Language is C#
Re: Screenshot of external app/game
You probably would need to inject code into the game's process in order to get access to its graphics context. Some examples here: http://www.codeproject.com/KB/threads/winspy.aspx
But why are you specifically trying to use OpenGL? There should be easier ways to do this, like the following method:
http://www.codeproject.com/KB/dialog/screencap.aspx
(replace the call to GetDesktopWindow with something that gets the HWND for the window you want to capture)
Re: Screenshot of external app/game
Using that method results in black screenshot (directx) or desktop screenshot (opengl), when 3d game is running in fullscreen mode.
Re: Screenshot of external app/game
Taksi is an open-source application that capture screenshots of fullscreen applications. You can look at its source code to see how it achieves this.
As far as I know, OpenGL contexts can't be shared between processes (i.e. your process cannot access OpenGL resources belonging to a different one). This means that regular OpenGL commands like GL.ReadPixels won't work for getting screenshots of 3rd party applications. To do that, you'll need to somehow "hook into" the external process directly - check Taksi for the details.