Alpha and TGA
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
Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
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.....
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]
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]
indeed that bug has helped a lot of people with the prob... I don''t know why he never changed the bug :S it''s a really important part and it''s soooo wrong
| Panorama 3D Engine | Contact me |
| MSDN | Google | SourceForge |

| Panorama 3D Engine | Contact me |
| MSDN | Google | SourceForge |
actually, this line was fixed as I already have it in my code. Is there something in the initialization that I need to turn on? Maybe culling?
Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com
Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com
Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
Fixed the problem, for some reason I had glAlphaFunc(GL_GREATER,0.1f); turned off. urned it on and it works fine now
Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com

Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com
Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement