Copying from SDLSurface to Window in 1.3?

The testsprite2 demo uses SDL_RenderCopy() method to draw to the window. BUt this function requires a SDL_Texture as input. I’d like to draw from an SDL_Surface. Is that possible under SDL 1.3?

You need to convert the surface to a texture first, then RenderCopy the
texture. I believe the function is called SDL_CreateTextureFromSurface.________________________________
From: vern@actionsoft.com (VernJensen)
To: sdl at lists.libsdl.org
Sent: Mon, September 20, 2010 11:32:31 AM
Subject: [SDL] Copying from SDLSurface to Window in 1.3?

The testsprite2 demo uses SDL_RenderCopy() method to draw to the window. BUt
this function requires a SDL_Texture as input. I’d like to draw from an
SDL_Surface. Is that possible under SDL 1.3?

That’s not an option. I am upgrading a legacy project, where there is a “work frame” the same size as the window, where each frame of animation is rendered, then copied to the screen. This “work frame” is an SDL_Surface. Creating a same-size texture from it each frame (when it’s the same size as the window) would likely kill performance.

Nope, it won’t kill performance, and this is just how SDL does stuff now,
unless you want to convert all your code so it uses textures (which wouldn’t
be fun, by the way).On Mon, Sep 20, 2010 at 5:49 PM, VernJensen wrote:

That’s not an option. I am upgrading a legacy project, where there is a
"work frame" the same size as the window, where each frame of animation is
rendered, then copied to the screen. This “work frame” is an SDL_Surface.
Creating a same-size texture from it each frame (when it’s the same size as
the window) would likely kill performance.


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

The compatibility layer should at least be a good way to test it, right?
Then he doesn’t need to use SDL_RenderCopy explicitly.

Jonny DOn Mon, Sep 20, 2010 at 5:53 PM, Alex Barry <alex.barry at gmail.com> wrote:

Nope, it won’t kill performance, and this is just how SDL does stuff now,
unless you want to convert all your code so it uses textures (which wouldn’t
be fun, by the way).

On Mon, Sep 20, 2010 at 5:49 PM, VernJensen wrote:

That’s not an option. I am upgrading a legacy project, where there is a
"work frame" the same size as the window, where each frame of animation is
rendered, then copied to the screen. This “work frame” is an SDL_Surface.
Creating a same-size texture from it each frame (when it’s the same size as
the window) would likely kill performance.


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

Yes, you can check out SDL_compat.c to see how it’s done.
Specifically look at how the video texture is created for optimal
streaming performance and then updated in SDL_UpdateRects()

You might even just want to use the SDL 1.2 compatibility directly in this case.

Cheers!On Mon, Sep 20, 2010 at 11:32 AM, VernJensen wrote:

The testsprite2 demo uses SDL_RenderCopy() method to draw to the window. BUt
this function requires a SDL_Texture as input. I’d like to draw from an
SDL_Surface. Is that possible under SDL 1.3?


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


? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC