Question about sdl+opengl

Hi there

Does somebody know how to use SDL Surfaces as OpenGL Textures? I read it
was possible in a book called: ‘Programming Linux Games’ but it didn’t say
how to do it!

Thanx
Sijmen

Hi there

Does somebody know how to use SDL Surfaces as OpenGL Textures? I read it
was possible in a book called: ‘Programming Linux Games’ but it didn’t say
how to do it!

Take a look at the file testgl.c in the test subdirectory of the latest
SDL source archive.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

The pixel data stored in the Surface structure can be passed to
glTexImage function.

Sijmen Mulder wrote:> Hi there

Does somebody know how to use SDL Surfaces as OpenGL Textures? I read it
was possible in a book called: ‘Programming Linux Games’ but it didn’t say
how to do it!

Thanx
Sijmen


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

The testgl example program included with SDL (in the test directory) shows how
to use an SDL surface as an OpenGL texture. Look at the function
"SDL_GL_LoadTexture".On Thursday 22 August 2002 07:46, Sijmen Mulder wrote:

Does somebody know how to use SDL Surfaces as OpenGL Textures? I read it
was possible in a book called: ‘Programming Linux Games’ but it didn’t say
how to do it!


Max Watson <@Max_Watson>

i found the answer at NeHe tutorial 6-SDL

sijmen

“Sijmen Mulder” <sijmen_mulder at programmer.net> wrote in message
news:ak2bk4$5mi$1 at hoth.stenstad.net…> Hi there

Does somebody know how to use SDL Surfaces as OpenGL Textures? I read it
was possible in a book called: ‘Programming Linux Games’ but it didn’t say
how to do it!

Thanx
Sijmen

string s=“my_texture.png”;

    SDL_Surface *picture;
    int result;
    picture=IMG_Load(s.c_str());
    assert(picture);
    cout <<"texture" <<s <<" nr="<<t<<" width="<<picture->w<<" height="<<picture->h<<" bits="<<(int)picture->format->BitsPerPixel<<"\n";
    glBindTexture(GL_TEXTURE_2D,t);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
    result=gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGB4,picture->w, picture->h,GL_RGB,GL_UNSIGNED_BYTE,picture->pixels);
    assert(result==0);

    SDL_FreeSurface(picture);On Thu, Aug 22, 2002 at 12:46:33PM +0100, Sijmen Mulder wrote:

Does somebody know how to use SDL Surfaces as OpenGL Textures? I read it
was possible in a book called: ‘Programming Linux Games’ but it didn’t say
how to do it!


http://decopter.sf.net - free unrealistic helicopter simulator