what's the most suitable graphic file format when deadling with OpenGL?

Member
Posts: 61
Joined: 2007.01
Post: #1
Hi,

I'm currently learning OpenGL as I try to convert a J2ME phone game I worked on a while back. All my previous image file experience is with *.PNG files due to the limited resources on a phone.

However, I've seen code examples and posts in various forums for *.tga and *.bmp files used with OpenGL and I was wondering if there is a preferred format? (maybe on the grounds of ease of use / flexibility?)

Thanks.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
PNG and JPEG are common choices. PNG is convenient when an alpha channel is needed, and JPEG is convenient when tight compression ratios are needed. I think there are also some DDS proponents on this board, but I'll let them speak for themselves.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
Avoid TGA and BMP like the plague. IMO, there are basically four graphics formats you'll ever need for a game:

JPEG (you don't need alpha, you do need good compression, you don't care about lossy compression)
PNG (you do need alpha, you don't need great compression, you do care about lossy compression)
DDS (you don't need great compression, you don't care about lossy compression, you do care about VRAM usage)
HDR "radiance" (or some other, better format -- I'm no expert here) (you need floating-point images)
Quote this message in a reply
Member
Posts: 37
Joined: 2006.08
Post: #4
It all depends on your needs. Basically, OpenGL doesn't care about your image files. It just wants an array of pixel data. You can get that data from a JPEG, PNG, TIFF, GIF, TGA, BMP, or if you're on OS X even a PSD file.

What matters is your needs: I'm working on a 2D pixel-perfect type of game using OpenGL, with sprites and not 3D objects, so PNG is the brain-dead obvious choice for me. It means simple alpha channel support, lossless compression (RLE), and it's simple to load using libpng.

If I was writing a game using Allegro I'd use BMP with a transparency key (that nasty hot pink, usually) because that's the easiest option. If I was making a 3D game with big detailed textures and a sky-box, I'd use fairly high-quality JPEGs. If I was making an old Sega AM-2 style 3D game with chunky bright colored 3D objects that needed super-clean textures, I'd still use PNG in 3D.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #5
I dont know the ins and outs of PNG but im sure it doesnt use RLE (I think it uses zip)
I search http://en.wikipedia.org/wiki/PNG for 'rle' nothing comes up.

Do you have any info on that, or was it just a guess?

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
unknown Wrote:I dont know the ins and outs of PNG but im sure it doesnt use RLE (I think it uses zip)
I search http://en.wikipedia.org/wiki/PNG for 'rle' nothing comes up.

Do you have any info on that, or was it just a guess?

Close, it uses zlib's Deflate algorithm. Zip uses the same. It can also do a bunch of spatial filters to increase compression, but no RLE.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #7
OneSadCookie Wrote:DDS (you don't need great compression, you don't care about lossy compression, you do care about VRAM usage)
And loading speed is better.

-Jon
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
I'm a big fan of PNG, one reason is because I've seen jpgs that look horrible due to compression, but not PNGs, not to mention the alpha channel. Also, libpng is quite easy to interface with.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #9
unknown Wrote:I dont know the ins and outs of PNG but im sure it doesnt use RLE (I think it uses zip)
I search http://en.wikipedia.org/wiki/PNG for 'rle' nothing comes up.

OTOH, both BMP and TGA can use RLE.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Opengl picking problem (zip file) papillon68 1 4,397 Mar 1, 2009 08:49 PM
Last Post: chronus
  Wings3D .obj file -> OpenGL problem WhatMeWorry 21 15,977 Apr 24, 2007 06:11 AM
Last Post: ThemsAllTook
  OpenGL Preferred Image Format (BMP, TIFF, ect) Justin Brimm 7 4,770 Apr 18, 2006 03:28 PM
Last Post: arekkusu
  Wishful 3D file format DoG 79 28,869 Mar 24, 2005 03:39 PM
Last Post: The Cheat
  Reverse Engineering 3d File Format nabobnick 1 2,853 Aug 13, 2004 12:11 PM
Last Post: nabobnick