In the SDL WiKi, at the page: http://www.libsdl.org/cgi/docwiki.cgi/SDL_Surface
it is shown the proper way to duplicate an SDL_Surface.
But, OMG, the code is not duplicating anything, it is only creating a “shared” surface,
for which the refcount equals 2, preventing the memory to be freed at the
first call of SDL_FreeSurface.
By the way, what is the proper way to really make a deep copy of a surface ?
I wonder why there’s no “SDL_CopySurface” or something like this… the only trick
I’ve found is to use SDL_DisplayFormat() which is not really optimal.
In the SDL WiKi, at the page: http://www.libsdl.org/cgi/docwiki.cgi/SDL_Surface
it is shown the proper way to duplicate an SDL_Surface.
But, OMG, the code is not duplicating anything, it is only creating a “shared” surface,
for which the refcount equals 2, preventing the memory to be freed at the
first call of SDL_FreeSurface.
By the way, what is the proper way to really make a deep copy of a surface ?
I wonder why there’s no “SDL_CopySurface” or something like this… the only trick
I’ve found is to use SDL_DisplayFormat() which is not really optimal.
It seems to be slightly faster than the SDL_DisplayFormat() trick.
If it can help some of you …
Julien CLEMENT
De : julien CLEMENT
? : SDL
Envoy? le : Mercredi, 5 Ao?t 2009, 10h57mn 14s
Objet?: [SDL] SDL_Surface duplication
Hi,
In the SDL WiKi, at the
page:?http://www.libsdl.org/cgi/docwiki.cgi/SDL_Surface
it is shown the proper way to duplicate an SDL_Surface.
But, OMG, the code is not duplicating anything, it is only creating a
"shared" surface,
for which the refcount equals 2, preventing the memory to be freed at the
first call of SDL_FreeSurface.
By the way, what is the proper way to really make a deep copy of a surface ?
I wonder why there’s no “SDL_CopySurface” or something like this… the only
trick
I’ve found is to use SDL_DisplayFormat() which is not really optimal.
Thanks