Archived

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

This topic is 5559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I got a problem with OpenGL textures. Since GLAUX sucks I decided to learn lesson24 and replace loadBMP with loadTGA. I *think* loadTGA works fine, but the texture conversion may not, since I have a WHITE rotating cube. It's not "glEnable(GL_TEXTURE_2D);" because that line is there. Nehe.tga is 24bits. I choose the texture like this (in drawGLscene) "glBindTexture(GL_TEXTURE_2D, textures[0].texID);" LoadTGA is identical to lesson24 except I erased the build texture stuff after the line "// Build a texture..." and put it in LoadGLTextures() instead.
int LoadGLTextures()
{
int Status=FALSE;

Status=TRUE;
}

GLuint type=GL_RGB;
if (textures[0].bpp==32)
{
type=GL_RGBA;
}

glGenTextures(1, &textures[0].texID);
glBindTexture(GL_TEXTURE_2D, texture[0].texID);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, type, textures[0].width, textures[0].height, 0, type, GL_UNSIGNED_BYTE, textures[0].imageData);

return Status;
}
}
Textures is of type TextureImage. The red is the lines that doesnt seem to make anything for me. Either my tga-read reads only 0's or glTexture generator is screwed or I am so screwed. Can you help me please? [edited by - parazyte on March 31, 2003 10:39:29 AM]

Share on other sites
try this:

glTexImage2D(GL_TEXTURE_2D, 0, 3, textures[0].width, textures[0].height, 0, GL_RGB, GL_UNSIGNED_BYTE, textures[0].imageData);

it might just be that little 3 in the third paramter. you may also have to change it to 4 if your going to use a tga with an alpha channel.

I hope this helps.

Share on other sites
grab the load tga function from lesson 32. Probalby the same but its the lesson i get my tga code from.

Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com

Share on other sites
Thanks for trying to help me out, very much appreciated.

Unfortunately it still doesn''t work (I tried both tips and all combinations of them...)
What really bothers me is that the font tutorial (lesson24) works fine, so I know the TGA loading is good.

Grateful for any other hints...
/Para

Share on other sites
I wanted to add I got it working.

I just thought I''d post what was wrong if anyone else gets the same problem. I am not sure exactly what went wrong, but I''ll list some pointers.

1) Make sure the TGA is 24 bit UNCOMPRESSED TGA
2) Make sure you understand the TextureImage structure (texID too)
3) Make sure LoadGLTextures works as it should (it''s TRUE in lesson6 and FALSE in lesson24 so make sure if you use tga-load from lesson24 you edit LoadGLTextures accordingly)

/Para

• 48
• 12
• 10
• 10
• 9
• Forum Statistics

• Total Topics
631374
• Total Posts
2999661
×