[SDL] OpenGL Textures

Jacek Popławski jpopl at interia.pl
Mon Aug 13 20:27:01 PDT 2001


On Mon, Aug 13, 2001 at 02:10:21PM +1000, Adam Gates wrote:
> What is the best way to load image files into OpenGL textures?
> Should I use SDL_image to load it and then convert to an OpenGL texture?
> (Anybody have code for that?)

 texture=IMG_Load("../deracer-data/road.png");
 assert(texture!=NULL);

 glBindTexture(GL_TEXTURE_2D,textures[TextureRoad]);
 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
 glTexImage2D(GL_TEXTURE_2D,0,3,texture->w,texture->h,0,GL_RGB,GL_UNSIGNED_BYTE,texture->pixels);

 SDL_FreeSurface(texture);

-- 
Turn round slowly 
Tell us what you see
Oh no - The fly got the spider 
And now he's chasing me                        "Otherworld" - Ronnie James Dio




More information about the SDL mailing list