SDL & OpenGL question

if i use OpenGL, how could i take a “screenshot” picture ?
(without using SDL_OPENGLBLIT, of course…)

i guess i could use glReadPixels(…) but i wonder i could still use
screen->pixels ?..

if i use OpenGL, how could i take a “screenshot” picture ?
(without using SDL_OPENGLBLIT, of course…)

In fact, it’s not possible to do it with SDL_OPENLBLIT even if you wanted
to, as it never even attempts to access the framebuffer directly. (All it
can do is render an RGBA surface on top of the OpenGL scene.)

i guess i could use glReadPixels(…) but i wonder i could still use
screen->pixels ?..

Not unless there’s some undocumented feature I missed when I looked at
the code… As I said, SDL_OPENGLBLIT is one-way, and that’s the closest
screen->pixel ever gets to OpenGL, AFAIK.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 09 November 2001 22:34, Lloyd Dupont wrote:

i guess i could use glReadPixels(…) but i wonder i could still use
screen->pixels ?..

You can’t use screen->pixels. glReadPixels() is the way every game I’ve
ever seen takes screenshots.

–ryan.

Here’s the hacked up C++ screenshot function I’m using… It’s pretty crude
and evil - for example, the resulting shot is upside-down - but it did what I
needed at the time.

void Scene::ScreenShot( std::string const& filename )
{
SDL_Surface* tmp;
int w = g_Screen->w;
int h = g_Screen->h;

tmp = SDL_CreateRGBSurface( SDL_SWSURFACE, w, h,
    24, 0x0000FF, 0x00FF00, 0xFF0000, 0x000000 );

glReadPixels( 0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, tmp->pixels );

SDL_SaveBMP( tmp, filename.c_str() );
SDL_FreeSurface( tmp );

}

Ugh. BMP.

Hope this is useful!
Ben.On Friday 09 November 2001 9:34 pm, you wrote:

if i use OpenGL, how could i take a “screenshot” picture ?
(without using SDL_OPENGLBLIT, of course…)

i guess i could use glReadPixels(…) but i wonder i could still use
screen->pixels ?..

thanks for all your answer…
i had a doubt, but no it is clear.

thanks, again.