[SDL] Hardware aceleration in Linux (windowed)

André Wagner andre.nho at gmail.com
Thu Sep 28 05:51:48 PDT 2006

On Monday 04 September 2006 23:29, Bob Pendleton wrote:
> > Right. This was the first problem I ran into: I can't use SDL 
> > textures, as I can't get at the OpenGL texture name or Direct3D 
> > texture pointer.
> Right there you lost me. SDL doesn't have textures. SDL has
> surfaces.

Sorry, I was talking about SDL 1.3, which is a bit different from the 
SDL 1.2 API. Among other things, source surfaces for display 
rendering calls have now been replaced with textures, which are 
basically a bit more abstract than surfaces.

In short, the SDL 1.3 is designed to work well with modern accelerated 
APIs like OpenGL and Direct3D, but if need be, it still supports the 
"retro style" tricks you could do with SDL 1.2.

> OpenGL has textures, and you get the texture name when you upload
> the surface in OpenGL. I do not understand the situation in which
> SDL would hide a texture name from you since SDL does not have
> textures.

From testsprites2.c of SDL 1.3:
LoadSprite(char *file)
    int i;
    SDL_Surface *temp;

    /* Load the sprite image */
    temp = SDL_LoadBMP(file);
    if (temp == NULL) {
        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
        return (-1);
    sprite_w = temp->w;
    sprite_h = temp->h;

    /* Set transparent pixel as the pixel at (0,0) */
    if (temp->format->palette) {
        SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
			*(Uint8 *) temp->pixels);

    /* Create textures from the image */
    for (i = 0; i < state->num_windows; ++i) {
        sprites[i] =
        if (!sprites[i]) {
            fprintf(stderr, "Couldn't create texture: %s\n",
            return (-1);

    /* We're ready to roll. :) */
    return (0);

The problem is that the SDL_TextureID returned from 
SDL_CreateTextureFromSurface() is just an internal identifier, and 
there is no API to get an OpenGL texture name or a Direct3D texture 
interface object pointer from that.

//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'

More information about the SDL mailing list