Sign in to follow this  

SDL + OpenGL Texture / Surface question

Recommended Posts

I solved my problem by using a whole different function to load my file because the other function wasn't working for alpha for some reason... Here is the new function I'm using in case anyone is having problems w/ IMG_Load and using alpha transparency.
GLuint load_texture(const char* file)
   SDL_Surface* surface = IMG_Load(file);
   GLuint texture;
   glGenTextures(1, &texture);
   glBindTexture(GL_TEXTURE_2D, texture);
   SDL_PixelFormat *format = surface->format;
   if (format->Amask)
      gluBuild2DMipmaps(GL_TEXTURE_2D, 4,
         surface->w, surface->h, GL_RGBA,GL_UNSIGNED_BYTE, surface->pixels);
      gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
         surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, surface->pixels);
   return texture;
-- Was grabbed from -- [Edited by - fmwyso on January 18, 2009 3:20:55 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this