sorry for this stupid queation. I just used the function glTexImage2D to show an image:
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->sizeX, image->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image->data);
It works well with a color image, but when I tried with an intensity(grey-scale) image and changed the components(the 2rd parameter of this function) to 1, just a white block of same size appears on the window. Can anybody give me some suggestion?
first of all ( im still working on enlighten all people ) the 3rd parameter shoulndt have just ‘3’, it should have an enumrator telling the driver what internal format you want ( GL_RGB(A)4 for 16bit, GL_RGB(A)8 for 24/32 bit, or just GL_RGB(A) if you dont care.
for the rest of the question, format should be GL_LUMINANCE, and internalfomrat (3rd parameter) should be one of GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8, depending on selected quality
If you still use your colored (that means 3 channel RGB texture) but want OpenGL to make a greyscale texture out of it, then you have to do it this way:
The 7th parameter tells OpenGL how YOU have the data at hand (in this case you have a 3 component image, consisting of red, green and blue) and the 3rd parameter tells OpenGL how IT is supposed to store it (int this case as a greyscale texture).
Mazy has mixed the 3rd and 7th parameter accidantly around.
You should get a good book or some other documentation about OpenGL. Such problems can easily be solved by simply looking up a description of the function.