Archived

This topic is now archived and is closed to further replies.

subnet_rx

BGR to RGB?

Recommended Posts

The OGL book I have says bmp''s are in BGR format and you have to switch them for OpenGL, but I don''t see this in NeHe''s tutorials. Do you have to or not?

Share this post


Link to post
Share on other sites
Either you switch them to RGB or you tell OpenGL that they''re in BGR format (use GL_BGR_EXT, or something like that, for the external format in your call to glTexImage2D). If I remember correctly, the NeHe tutorials use a GLaux function to get around all of that.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Yes, the auxDIBImageLoad can be used if you don''t want to manually convert BGR-RGB.

Something to consider: the OpenGL extension you suggested may not be available in all implementations, and it isn''t all that much trouble to just convert it or, if you really want to, to use auxDIBImageLoad.

Later,
ZE.

Share this post


Link to post
Share on other sites
ok, I''m mainly trying to figure out why NeHe''s code seems a lot more forgiving if I insert xx texture. The OGL book''s code doesn''t want to take anything but their bmp''s. I''ll try inserting that glaux call.

subnet_rx


"There are two types of langages, those that everyone bitches about, and those that no one uses."


Standardized C++ Libraries
C++ Programming help
The only news site on the web

Share this post


Link to post
Share on other sites
quote:
Original post by ZealousElixir
Something to consider: the OpenGL extension you suggested may not be available in all implementations...

Another thing to consider: It was standardized in OpenGL 1.2 (that''s why it''s simply GL_BGR without the _EXT in most implementations not in Windows). Your point still stands for crappy video cards and/or drivers though .

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by subnet_rx
The OGL book I have says bmp''s are in BGR format and you have to switch them for OpenGL, but I don''t see this in NeHe''s tutorials. Do you have to or not?


I don''t see the problem. You either have to flip BGR to RGB or use some function to except palette information in that form.Don''t for get the dumby byte (I guess they use it for 24 bit color or something?) at the end of each BGR. So it would be more like BGRD

Share this post


Link to post
Share on other sites
I just participated in a topic, where I pasted code to replace auxDIBImageLoad().

http://www.gamedev.net/community/forums/topic.asp?topic_id=72875

Regarding the book being unforgiving about textures...this is probably the cause:

If you mipmap the bmp, the bmp can be of *any* dimension...

...but...

if you load the bmp normally (i.e., without building mipmaps)...
Then the bitmap must have square dimensions of the power of 2.
For example, these are some of the following bitmap dimensions valid within opengl (without mipmapping):
16x16 , 32x32 , 64x64, 128x128, 256x256, 512x512 and onward...

If you try to load a 50x50 bmp file in opengl, without mipmapping, it will *not work*.

Hope that helps

Share this post


Link to post
Share on other sites
yeah, I''m resizing the bmp before loading it. I don''t see mipmapping in lesson 6 and that''s where I''m loading this texture, and I''m trying to load the same texture in the book, but it doesn''t show up. A white box everytime. Ohh well, guess I''ll figure it out later, reading Display Lists now.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

Don''t for get the dumby byte (I guess they use it for 24 bit color or something?) at the end of each BGR



It''s not a dummy byte. It''s used for the alpha-channel, if there is any, that would make 32bit, BTW.

Share this post


Link to post
Share on other sites
subnet_rx i assume you bought Prima Tech''s Opengl Game Programming. I recoment useing the re code with a Grain or 20 of salt. It''s not that good and out of the 4 or so examples i''ve tried only 1 worked (i couldn''t even get there FRAMEWORK to work the FRAMEWORK i mean come on. because if that i''m haveing to reverse enginere all the examples(good for learning by the way) and re write them for NeHe''s engine.

PS thank got for header files.......no reason why.

A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.

Share this post


Link to post
Share on other sites