problem in texture mapping on multispectral image

hi, i want to display multispectral image using texture mapping.

how can i load the 3 bands in the texture?

Anybody can help me?plsss

You could create three textures and apply them with multitexture.

You could temporarily draw the images to the framebuffer with writemasks and read them to a texture or use render to texture to do the equivalent.

You could combine them in software then load to a texture.

There is no convenient direct way in OpenGL to load your images as separate bands to a single texture if they exist as band separate images in memory.

Mr.Dorbie, i’m using opengl’s old version only so i can’t try multitexturing.

And i shouldnot use anyother software for combining the images.

So i have to try by copying it into the frame buffer using writemasks. Can you pls explain me about it in detail? Since i’m beginner in opengl.

Originally posted by hemsbalu:
And i shouldnot use anyother software for combining the images.
I’m pretty sure he meant combining the image-data using regular C/C++/Java/whatever-your-programming-language-might-be, and uploading the resulting rgb-data as a texture as usual.

Hmm, you make it sound like you’re doing some kind of exercise now.

Look at the glColorMask function if you insist on keeping the bands separate, but that means having multiple textures instead of one.

w.r.t. using software to combine images, the other poster is correct, I meant interleave the data using your own code to copy it in memory prior to loading it to a texture. Not use some 3rd party software for such a trivial operation. Thuis would be the preferred approach especially if you were drawing with the image many times after you have created the texture.

It occurs that there is another longhand way, use glColorMask and drawpixels to the framebuffer then glcopyteximage to get it from there to texture. Kinda silly and potentially fraught with problems like precision and window clipping etc but if you have an exercise to teach you about the limitations of OpenGL it may be worthwhile.

i have combined the image using the unsigned char array img[][][]. Each dimension is for each band. It is displaying properly when i’m using GL_RGB in loading the texture. But if i use GL_BGR, the o/p is not right.

Well of course.

That token determined the byte ordering of the source data for the ‘external’ format.

Now if you want that to work you have to change your packing order in the third array dimension, instead of [0]=red it would be [0]=blue etc.