• Advertisement
Sign in to follow this  

Loading Jpegs

This topic is 4712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
http://www.realityflux.com/abba/C++/SXMLEngine/SXMLEngine.zip

Look into ImageUtils/Image.h/.cpp and AppUtils/Texture.h/cpp

Share this post


Link to post
Share on other sites

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

void LoadTexture(Model &model , const char *tex)
{
SDL_Surface *texture = IMG_Load(tex);

if(texture)
{
/* create texture */
glGenTextures(1, &model.tex_id);

glBindTexture(GL_TEXTURE_2D, model.tex_id);

/* load in texture */
glTexImage2D( GL_TEXTURE_2D , 0 , 3 ,
texture->w , texture->h , 0 , GL_BGR,
GL_UNSIGNED_BYTE , texture->pixels);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

SDL_FreeSurface(texture);
}
else
{
// should throw
cerr << "error : loading texture " << tex << "\n";
}
}


will load any image format

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement