Prob. with glTexImage2d

Hello Everybody!

As I tried to load my textures into the OpenGL framework lataly I came across something very strange.

When I created the Texture using gluBuild2DMipmaps everything worked just fine. When used glTexImage2D instead no texture appeared at all.

These are the function calls:

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, ImageData->sizeX, ImageData->sizeY, GL_RGB, GL_UNSIGNED_BYTE, ImageData->data);

glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageData->sizeX, ImageData->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, ImageData->data);

They should be ok as they are…

The ImageData Object is of type ‘AUX_RGBImageRec *’.

What does Build2DMipmaps do more than TexImage2D (besides creating Mip Map Sub Textures of course)?

Has anybody experienced similar problems.

Any help would be apreciated.

Thanks in advance
Martin

Martin,

If you’re not using mipmapping, you should make sure your minification filter is set to LINEAR or NEAREST. Here’s how you would set it to LINEAR:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

The default minification filter in OpenGL is LINEAR_MIPMAP_NEAREST, which requires you to specify all mipmap levels.

Hope this helps -
Cass

I’m afraid this was not a solution for the problem. The Object I apply my (somewhat) bad Texture to, is still rendered in the by glColor specified color.

But thanks a lot for the Post anyway

Best regards Martin

make sure that your original image has dimensions that are powers of two. if you try to create a texture that is not a power of two, it will not appear. but, using mipmaps, it will.

to quote the Red Book: “If your original image has dimensions that are not exact powers of 2, gluBuild*DMipmaps() helpfully scales the image to the nearest power of 2.”

this would explain the behavior you’re seeing.

[This message has been edited by phlake (edited 07-19-2000).]

I agree with phlake. That is probably you’re problem. Infact I often used mipmapping if the textures I’m reading in aren’t a power of 2 inorder to get the textures to display.

Hello Again!

Thanks a lot for your help.
You were right Phlake. First my texture was 320x240. The width and height are powers of two, but they have to be of same value as well I think. Then I tried 320x320. No way. At last I tried 256x256 and ahaaa it WORKED!

Thanks a lot again!!

Martin