[SDL] Questions about SDL 1.3

Mason Wheeler masonwheeler at yahoo.com
Mon Dec 27 11:40:13 PST 2010

Render targets (intermediate textures) are incredibly useful when you need to do 
things more complicated than simply rendering predefined images directly to the 

For example, let's say you want to create a text box that displays text one 
character at a time.  Without render targets, your display code would read like 
this, in psedudocode:

procedure RenderTextBox
  for i from 0 DisplayedCharacterList.length

But if you're storing the text box in a render target, you can update it as you 

procedure RenderTextBox
  RenderCharacter(GetNextCharacter(CurrentMessage), TextBoxTexture, 
  RenderToScreen(TextBoxTexture, TextBoxLocation))

Simpler code and no need for a loop inside the rendering.

From: "santiago at dragontech.net" <santiago at dragontech.net>
Subject: Re: [SDL] Questions about SDL 1.3

Why do you need an intermediate texture? Use a sdl rect to render a portion of 
it to there screen.

Enviado desde mi HTC
----- Reply message -----
De: "Mason Wheeler" <masonwheeler at yahoo.com>
Fecha: lun., dic. 27, 2010 18:37
Asunto: [SDL] Questions about SDL 1.3
Para: <sdl at lists.libsdl.org>

I had similar problems, so I wrote up a patch to implement #3.  I submitted it 
back in April, and apparently it's never been touched or looked at since. :(


This is for the OpenGL renderer only, but similar concepts exist in Direct3D and 
you shouldn't have too much trouble extending it if that's what you're using.

From: ebyard <e_byard at yahoo.co.uk>
To: sdl at lists.libsdl.org
Sent: Mon, December 27, 2010 8:59:14 AM
Subject: Re: [SDL] Questions about SDL 1.3



1.) How do I draw stuff directly to a SDL_Texture? Currently I am blitting to a 
SDL_Surface then using SDL_CreateTextureFromSurface to convert it for 
SDL_RenderCopy. I feel that there should be a more efficient way to do this, but 
I can't find a function that does direct drawing to a texture in the new api 

I have had to do this on a project. It is horrifically inefficient - ~58ms to 
convert a 1024x768 surface to a texture and display it, and I have 2 windows, so 
double that. I really do not know how to fix this.

If SDL 1.3 is made to be able to be a "frame" based system then there needs to 
be a way to either: 

1. render a surface directly to a window
2. convert a surface to a texture very quickly
3. copy a portion of a texture to another texture quickly, which can then be 
rendered to the screen

There's also a big question mark over scaling in 1.3 - I can see no fast /easy 
way to draw a new frame and then scale it. I draw lots of small rectangles from 
a large texture on to the screen - problem is you can't scale with this method 
as there is no way to fast-copy between textures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20101227/e1d40467/attachment-0008.htm>

More information about the SDL mailing list