Jump to content
  • Advertisement

Archived

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

executor_2k2

Can't load TGAs

This topic is 6017 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 am using NeHe''s Tga.h for TGA support in my particles system, but I am having some problems. First, if I do "free(&texture);" I get a breakpoint error. If I remove the above line I can run the app, but I get no particles. The texture does not appear. I am loading a TGA file I made in photoshop that is 32bit and the picture is set on a transparent backgournd. The following is my TGA loading code: void CBubbles::InitializeSystem() { bool tgaFileToLoad = TRUE; // get a texture object glGenTextures(1, &m_texture); glBindTexture(GL_TEXTURE_2D, m_texture); // enables the texture object. // the following fucntions affect the // texture specified by the 2nd parameter if (tgaFileToLoad) { Texture texture; texture.texID = m_texture; LoadTGA(&texture, "bubbletransparent1.tga"); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); MessageBox(NULL, "Texture is Loaded", "Textures",MB_OK | MB_ICONEXCLAMATION); glTexImage2D(GL_TEXTURE_2D, 0, texture.type, texture.width, texture.height, 0, texture.type, GL_UNSIGNED_BYTE, texture.imageData); gluBuild2DMipmaps(GL_TEXTURE_2D, texture.type, texture.width, texture.height, GL_RGBA, GL_UNSIGNED_BYTE, texture.imageData); // we''re done with the TGA data //free(&texture); } The following is my render code: void CBubbles::Render() { // enable alpha blending and texturing glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // set the blend mode glBlendFunc(GL_SRC_ALPHA, GL_ONE); // select the bubble texture glBindTexture(GL_TEXTURE_2D, m_texture); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // to avoid constant dereferecning... vector3_t partPos; float size; // draw the quads glBegin(GL_QUADS); for(int i = 0; i < m_numParticles; ++i) { partPos = m_particleList.m_pos; size = m_particleList[i].m_size; glTexCoord2f(0.0, 1.0); glVertex3f(partPos.x, partPos.y, partPos.z); glTexCoord2f(1.0, 1.0); glVertex3f(partPos.x + size, partPos.y, partPos.z); glTexCoord2f(1.0, 0.0); glVertex3f(partPos.x + size, partPos.y - size, partPos.z); glTexCoord2f(0.0, 0.0); glVertex3f(partPos.x, partPos.y - size, partPos.z); } glEnd(); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); } Any ideas? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
glTexImage2D(GL_TEXTURE_2D, 0, texture.type, texture.width, texture.height, 0, texture.type, GL_UNSIGNED_BYTE, texture.imageData);

OR

gluBuild2DMipmaps(GL_TEXTURE_2D, texture.type, texture.width, texture.height, GL_RGBA, GL_UNSIGNED_BYTE, texture.imageData);

not both, i cant see much wrong perhaps its your image loading code. also did u disable lighting + have a glColor4f(1,1,1,1)

http://uk.geocities.com/sloppyturds/gotterdammerung.html

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!