Jump to content
  • Advertisement
Sign in to follow this  

SDL + OpenGL Texture / Surface question

This topic is 3530 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

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 http://ubuntuforums.org/showthread.php?t=396281 -- [Edited by - fmwyso on January 18, 2009 3:20:55 PM]

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!