Jump to content
  • Advertisement
Sign in to follow this  
polarboy

OpenGL OpenGL + SDL loading .png file

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

Hi, guys, my problem is as follows: I have successfully used OpenGL and SDL to load a tile set on my screen the tileset is a .bmp file However, when the same file is converted to .png OpenGl simply fails to read it as it is not a "true color image" the bpp I get from nOfColors = surface->format->BytesPerPixel; cout <<"Its number of colors is "<<nOfColors<<endl; is 2 hehe, as I typed this up, I realized this could be the problem of SDL_DisplayFormat So now I deleted the function where I optimize the image by SDL_DisplayFormat Now my question is: I thought by making the image the same format as the screen, it would make it easier for the system to load...so now for openGL, does it make things any slower by not doing SDL_DisplayFormat?

Share this post


Link to post
Share on other sites
Advertisement
Do you use SDL_image and IMG_Load? Loading a .png is easy with that, SDL can only load .bmp I think, that's what SDL_image is for.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tenac
Do you use SDL_image and IMG_Load? Loading a .png is easy with that, SDL can only load .bmp I think, that's what SDL_image is for.


Yeah, that's what I used, but I also used the optimization function from Lazy Foo's tutorial, which converts the image to the same format as the screen

that was my problem

Share this post


Link to post
Share on other sites
Personally I prefer SOIL for loading images. It gives you the texture handle instead of having to deal with conversion also does POT changes for you. If you decide to use it and need any help, shoot me a message.

Share this post


Link to post
Share on other sites
Yeah, i also use SOIL too. It can load a number of image formats and it has functions to load as an OpenGL texture or raw image data.

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!