Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Strange tga file render

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

Image and video hosting by TinyPic Here is a sample of the function.
GLuint loadTextureTGA(tImageTGA *tImageTGA) {
    GLuint textureId;
     glGenTextures(1, &textureId); //Make room for our texture
        glBindTexture(GL_TEXTURE_2D, textureId); //Tell OpenGL which texture to edit
    //Map the image to the texture
    glTexImage2D(GL_TEXTURE_2D,                //Always GL_TEXTURE_2D
                 0,                            //0 for now
                 GL_RGB,                       //Format OpenGL uses for image
                 tImageTGA->size_y, tImageTGA->size_x,  //Width and height
                 0,                            //The border of the image
                 GL_RGB, //GL_RGB, because pixels are stored in RGB format
                 GL_UNSIGNED_BYTE, //GL_UNSIGNED_BYTE, because pixels are stored
                                   //as unsigned numbers
                 tImageTGA->data);               //The actual pixel data
        return textureId; //Returns the id of the texture

Use with the init event.
	tImageTGA*  TREEi = Load_TGA("TaBase/Textures/RandomWorld/maple_tree.tga");
	TREE2 = loadTextureTGA(TREEi);
	delete  TREEi;

P.S whats the function to enable transparency in openGL? I know it's gl blend, but I forgot the other one.

Share this post

Link to post
Share on other sites
It looks like you've got the wrong parameters for GL_RGB and GL_UNSIGNED_BYTE. You can definitely see the tree in there, but it's all... messed up. Are you sure there's no alpha channel in the TGA? You probably already have this information in your tImageTGA pointer, your glTexImage2D call could use them and never fail like this again.

Share this post

Link to post
Share on other sites
Yes it's using a alpha channel, but it seems not to show up. I had to use GL_RGBA. So now the image is showing, but it seems it's alpha channel isn't working. :(

Image and video hosting by TinyPic

I remember that their was a a function for this kind of stuff for the inital area, that contains ALPHA something... That toke 2 parameters, I think.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!