OpenGL Preferred Image Format (BMP, TIFF, ect)

Member
Posts: 64
Joined: 2005.06
Post: #1
Just a quick question, does OpenGL prefer any particular image format for textures?

I've noticed that in almost all examples, .bmp is used for textures, but I've been having problems with .bmp, as colors are off, or the colors blend together; where it should be white, it'll look like someone poured water over it and the color ran into the white area. Or the texture will be different shades of one color (usually red when that happens). I don't think it's my program as I've run the textures through several other OpenGL setups done by other people, and they all have the same problems with certain files (NeHe tutorials do this, some of the texture files work, others don't).

On a whim, I tried .tif though and I have no problems with the textures showing up correctly. It seems like the perfect replacement for .bmp as .tif also supports alpha (36bit file format), but before I go and start doing all textures in .tif, I want to know if OpenGL prefers any particular format over another.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
A texture is just a bunch of bytes to OpenGL. If your image looks OK in Preview and wrong in your game, it's a bug on your part.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2006.02
Post: #3
And to answer your question, OpenGL has no interest in what image format you choose to use. As OneSadCookie says, the image is just a bunch of bytes as far as OpenGL is concerned. How you choose to store them outside of the runtime is up to you.

PNG is my personal favourite. It's lossless, supports transparency and compresses reasonably well (somewhat better than TIFF).
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #4
Hey, going on what OneSadCookie said, I realized that if I pull my Bitmap data from [image tiffRepresentation] rather than just pulling the data directly from the image without doing anything to it, I don't run into any problems anymore.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2006.02
Post: #5
... you were passing BMP-compressed data to OpenGL? Heh. That'll bugger it up, for sure :-p
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
um, trying to use the -tiffRepresentation data sounds dodgy...

and 24-bit BMPs aren't compressed...

Sounds like Justin has a fundamental misunderstanding about how images work, but I'm not quite sure where to start...
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #7
All I have to go off of is how I see it done, and both NeHe and ~ktatters feed the data to OpenGL in the same manner.
Add: Also, I don't know what has changed since it was written, but Tutorial 9 at NeHe no longer works; blending doesn't work in it so all it draws is rectangles.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #8
Store your textures in .png or .jpeg and use whichever system framework you are comfortable with to decompress the image.

Do not use .bmp or .tga as they are particularly poor image formats.

btw, this sort of question has been answered many times on this forum before. Search around.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Image Textures mikey 52 24,049 Jun 30, 2009 10:42 AM
Last Post: AnotherJake
  OpenGL / SDL 2d Interface: Preferred Method? TythosEternal 5 4,173 Nov 8, 2008 07:57 PM
Last Post: Wowbagger
  what's the most suitable graphic file format when deadling with OpenGL? anthony 8 4,629 Feb 16, 2007 06:25 PM
Last Post: PowerMacX
  Displaying image with OpenGL and DevIL in C? leRiCl 13 9,100 Jan 23, 2007 01:25 PM
Last Post: djork
  2D Image Generation & openGL LWStrike 2 3,269 Mar 28, 2006 03:34 PM
Last Post: OneSadCookie