Jump to content
  • Advertisement

Archived

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

parazyte

lesson06 - LoadTGA and glTexture

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

If you intended to correct an error in the post then please contact us.

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;

	if (!LoadTGA(&textures[0],"Data/Nehe.TGA"))			{
		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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!