Loading Jpegs
http://www.realityflux.com/abba/C++/SXMLEngine/SXMLEngine.zip
Look into ImageUtils/Image.h/.cpp and AppUtils/Texture.h/cpp
Look into ImageUtils/Image.h/.cpp and AppUtils/Texture.h/cpp
#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
Another one is, if you need to use JPEG's as OpenGL textures, you can use NeHe's IPicture code, which can even load JPGs from the net [smile].
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement