Jump to content
  • Advertisement

Archived

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

titan2782

Alpha and TGA

This topic is 5560 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

For some reason when I try to use the code from lesson 33 along with the images, I can see the entire image, the alpha channel does not do it''s job. any ideas? I can run the lesson 33 and it works fine, the alpha channel works. I copy the exact code and use the exact image in my code. Why cant I get it to work correctly? Maybe something in my initialization code? Do i need to turn something on? Dustin Davis Owner / CEO Programmers Unlimited www.Programmers-Unlimited.com

Share this post


Link to post
Share on other sites
Advertisement
Not sure if this is your problem, but i did find a bug in the lesson 33 code a long time ago. I emailed Nehe about it but he must not of got my email or not worried about it.

this is the problem Function.....


    
int LoadGLTextures() // Load Bitmaps And Convert To Textures

{
int Status=FALSE; // Status Indicator


// Load The Bitmap, Check For Errors.

if (LoadTGA(&texture[0], "Data/Uncompressed.tga") &&
LoadTGA(&texture[1], "Data/Compressed.tga"))
{
Status=TRUE; // Set The Status To TRUE


for (int loop=0; loop<2; loop++) // Loop Through Both Textures

{
// Typical Texture Generation Using Data From The TGA ( CHANGE )

glGenTextures(1, &texture[loop].texID); // Create The Texture ( CHANGE )

glBindTexture(GL_TEXTURE_2D, texture[loop].texID);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[loop].width, texture[loop].height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[loop].imageData);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

if (texture[loop].imageData) // If Texture Image Exists ( CHANGE )

{
free(texture[loop].imageData); // Free The Texture Image Memory ( CHANGE )

}
}
}
return Status; // Return The Status

}


the line .....

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

should actually be.....

glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[loop].width, texture[loop].height, 0, texture[loop].type, GL_UNSIGNED_BYTE, texture[loop].imageData);

This stuffed me up when i was starting out on the Alpha channel with TGA's. Hope that fixes your problem for you.

If not i am sure someone less begginnerish will know.

Werdy666

[edited by - werdy666 on March 31, 2003 6:41:17 AM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!