Archived

This topic is now archived and is closed to further replies.

Copy to a surface

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my screen, i will draw something for some seconds, and after that time i want to draw to my screen it''s initial state. So, before i draw to my screen my stuff, i have to save somewhere the initial state of the screen, which mean i have to copy the screen surface to soewhere temporarily. I do this: SDL_Surface *temp = SDL_DisplayFormat(screen ); //draw some stuff SDL_BlitSurface ( temp, NULL, screen, NULL ); but it doesn''t work from the documentation it says: "This function takes a surface and *copies* it to a new surface (of the pixel format and colors of the video framebuffer)" Questions: 1) Why it doesn''t work? 2) What should i do??????

Share this post


Link to post
Share on other sites
I''m not entirely sure but you might with SDL you can blit the contents of one surface to another - like drawing an image from a source surface to the screen surface so in theory you should be able to swap the order of the surfaces in the call to SDL_BlitSurface() to blit the contents of the screen to another tempory surface like this:

SDL_Surface *g_ScreenCopy = NULL;
SDL_BlitSurface(screen, NULL, g_ScreenCopy, NULL);

That method might work, it might not. I haven''t tested it out but there are bound to be better ways to do it.

Share this post


Link to post
Share on other sites
thank you Spudder but that won''t work because you didn''t create the surface at first
Maybe i can get it to work if i use CreatRGBSurface and then BlitSurface (i''ll try it now), but why Display format didn''t work???
thanks...

Share this post


Link to post
Share on other sites