View Full Version : Texture
I am trying to texture an object using an RGB-bitmap.
At first I wrote a function that would make use of the glaux library, but somehow windows got problems with any glauximp.dll I had installed, so I wrote my own bitmap loader, thus replacing auxDIBImageLoad().
The bitmap seem to be loaded ok, except for the fact that the entire texture is now composed of all shades of one of the three prime colors, depending on where I point the glTexImage2D bitmap data pointer (the last argument).
In fact when I point the pointer to the start of the bitmap data the entire texture is composed of all shades of blue, when I point it to the second data element everything is green, at the next byte everything is red, and after that everything starts all over again.
Anyone knows what could be the cause of this?
Some of the GLUT (IRIX) ports of the NeHe tutorials has a BMP loader. A better solution is probably to pick the TGA loader from the last tutorial. Should be easy to use since it is separate implementation/header files. TGA is more useful than BMP because you can have images with a alpha channel.
If you for some strange reason wants glaux can you compile or get a dll from here http://www.delphi-jedi.org/DelphiGraphics/opengl/download.htm
I still want to know what could be the cause if this strange behavior.
07-19-2001, 04:40 AM
What is the colour state set to. I seem to remember having a similar problem as I was drawing an object in a colour, say blue, and then trying to texture map, but as the gl state was blue the texture was all blue.
07-19-2001, 05:22 AM
Show your code around glTexImage2D.
Well I looked at the color state too and I changed it but that would make no difference.
As I said the only time the color changes is when I change the offset from where to begin reading bitmap data, it then cycles through the colors blue green and red in that order.
I tried that loader too, but I am having exactly the same problem, so I suppose the problem is not in the loader but with the actual GL code, perhaps I passed a wrong option to one of the texture commands...
07-20-2001, 07:19 AM
err... if you offset from when you start reading data in, then yeah the components of the channels will change.
If you use a blue texture, then it will start off blue, then change to green, then red, with each succesive offset added.
There's obviously a bug in your bitmap loader.
What exactly do you mean by 'if you offset from when you start reading data in'?
My texture is not a single solid color, it has multiple colors, it's a wooden crate.
07-20-2001, 01:25 PM
I meant exactly what you said.
the color changes is when I change the offset from where to begin reading bitmap data
Thats what I meant.
If your texture is wooden colour, and you're getting all of one colour, then their must be something wrong with the way you're loading the texture.
07-20-2001, 01:30 PM
IHOPE..., the data in the file is composed of a stream of RGB triplets if it is a 24 bit color file. So if you offset it a byte it will start with G instead of R (or B). The effect is that green turns red (or blue), and so on. If you offset it two bytes you get exactly the opposite combination. If its a 15 or 16 bit color file, then things look wrong if the offset is odd. To see if something is really wrong with the loading rountine use three different bitmaps each just a primary color. See how each texture turns out when loaded. If the colors change then pay attention to which color turns into which color, that should provide some hint as to what is wrong. Also be aware that some bitmaps may be in planar order (though I haven't run across that type in a long time), i.e. all red data followed by all green data, and so on.
[This message has been edited by DFrey (edited 07-20-2001).]
Well, the problem is that whatever offset I seem to choose, the texture always ends up consisting of shades of only one of the prime colors.
I don't suppose the bitmap is in planar order, but I really think I am doing something wrong, since I tried loading both BMPs and TARGAs with the same problem, all shades of one color, instead of the actual colors, so it's not that the colors have changed what is happening is that all colorvalues are interpreted as shades of one of the prime colors, like in a black and white bitmap, except that it's now composed of a prime color instead of B&W.
If anybody thinks it will help I could post the loading routine and the actual gl code that displays the texture.
I went over that offset shifting again right after I wrote the above post, and I made the code working by starting to fead the data at an offset that was 8 bytes before the offset I calculated... and it seemed to work ... for the TGA loader, the BMP loader is still broke, but who cares anyway.
The only problem I am having now is that my texture is misaligned, but I guess I'll figure that out.
Thanks for your time guys.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.