Writing C++ wrapper for 1.3, which file is FreeSurface in?

I’m writing a C++ wrapper for SDL 1.3. Specifically, I’m currently
writing smart pointers for the actual SDL types (I can decide whether
to write smart pointers for the wrappers later). Now, from my
perspective SDL_Surface has everything I need to easily create a
sharing- smart pointer with it (in the form of the refcount member),
but I need to know how to interact with it, and how other code
interacts with it. Thus, I have a few questions:

Is it safe for the smart pointer to automatically increment refcount
on every surface that’s given to it? As far as I can tell it’s
’expected’, but there might be a gotcha in some code I haven’t looked
at.

Is all of the actual SDL code that accesses refcount in the
SDL_Surface.c source file?

It is erroneous to free a locked surface, correct? (I realize that
SDL_FreeSurface() will unlock it, that doesn’t mean it’s proper
behavior )

As far as I can tell, simply calling SDL_FreeSurface() blindly on
destruction or reassignment should be perfectly fine (when used in
conjunction with arguments to control whether refcount gets
incremented in the first place), but I’m only checking the source
files where I think it makes sense for refcount to be accessed, so…

Although you can still use SDL_Surface * with SDL 1.3, the preferred type is
now SDL_Texture *. The only place where you still need to use SDL_Surface
*'s is when calling functions like IMG_Load() which return a pointer to a
SDL_Surface.

However, the optimal thing to do after loading an image is to convert it
from an SDL_Surface * to a SDL_Texture * using
SDL_CreateTextureFromSurface().

Ken> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Jared Maddox
Sent: Tuesday, November 09, 2010 1:24 AM
To: sdl at lists.libsdl.org
Subject: [SDL] Writing C++ wrapper for 1.3, which file is FreeSurface in?

I’m writing a C++ wrapper for SDL 1.3. Specifically, I’m currently
writing smart pointers for the actual SDL types (I can decide whether
to write smart pointers for the wrappers later). Now, from my
perspective SDL_Surface has everything I need to easily create a
sharing- smart pointer with it (in the form of the refcount member),
but I need to know how to interact with it, and how other code
interacts with it. Thus, I have a few questions:

Is it safe for the smart pointer to automatically increment refcount
on every surface that’s given to it? As far as I can tell it’s
’expected’, but there might be a gotcha in some code I haven’t looked
at.

Is all of the actual SDL code that accesses refcount in the
SDL_Surface.c source file?

It is erroneous to free a locked surface, correct? (I realize that
SDL_FreeSurface() will unlock it, that doesn’t mean it’s proper
behavior )

As far as I can tell, simply calling SDL_FreeSurface() blindly on
destruction or reassignment should be perfectly fine (when used in
conjunction with arguments to control whether refcount gets
incremented in the first place), but I’m only checking the source
files where I think it makes sense for refcount to be accessed, so…


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi, Ken.
I would like to join to your effort on C++ wrapper. I have some thoughts and
partially implemented wrapper.On Tue, Nov 9, 2010 at 10:03 AM, Ken Rogoway wrote:

Although you can still use SDL_Surface * with SDL 1.3, the preferred type
is
now SDL_Texture *. The only place where you still need to use SDL_Surface
*'s is when calling functions like IMG_Load() which return a pointer to a
SDL_Surface.

However, the optimal thing to do after loading an image is to convert it
from an SDL_Surface * to a SDL_Texture * using
SDL_CreateTextureFromSurface().

Ken

-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org]
On
Behalf Of Jared Maddox
Sent: Tuesday, November 09, 2010 1:24 AM
To: sdl at lists.libsdl.org
Subject: [SDL] Writing C++ wrapper for 1.3, which file is FreeSurface in?

I’m writing a C++ wrapper for SDL 1.3. Specifically, I’m currently
writing smart pointers for the actual SDL types (I can decide whether
to write smart pointers for the wrappers later). Now, from my
perspective SDL_Surface has everything I need to easily create a
sharing- smart pointer with it (in the form of the refcount member),
but I need to know how to interact with it, and how other code
interacts with it. Thus, I have a few questions:

Is it safe for the smart pointer to automatically increment refcount
on every surface that’s given to it? As far as I can tell it’s
’expected’, but there might be a gotcha in some code I haven’t looked
at.

Is all of the actual SDL code that accesses refcount in the
SDL_Surface.c source file?

It is erroneous to free a locked surface, correct? (I realize that
SDL_FreeSurface() will unlock it, that doesn’t mean it’s proper
behavior )

As far as I can tell, simply calling SDL_FreeSurface() blindly on
destruction or reassignment should be perfectly fine (when used in
conjunction with arguments to control whether refcount gets
incremented in the first place), but I’m only checking the source
files where I think it makes sense for refcount to be accessed, so…


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org