Good morning GDSE,

I am loading a TGA using loadTGA function found in superbible 4th edition source code. Here is how the image looks in Gimp

tga, as seen in Gimp

You can see I have enabled alpha channel in Gimp, I exported this to TGA image, without RLE compression, and 32bpp. But when I load the image in my OpenGL code, the part of the image which is supposed to be transparent is seen white.

bad tga transparency

Where I must be going wrong? The type of TGA is set to GL_RGBA, 32 bpp.

Here is my Fragment shader code.

out_fragColor = (vec4( ambAndDiff, 1 ) * texColor) + vec4(spec,0.0);

I have calculated ambAndDiff and spec values earlier using ADS phong shading, and both of them are vec3. Let me know if you also want to view the TGA loading code. :)

Regards, A.

  • 2
    \$\begingroup\$ It looks like you haven't enabled alpha blending. Try this: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); \$\endgroup\$
    – shade4159
    Nov 19, 2013 at 5:32
  • 1
    \$\begingroup\$ Not sure alpha blending is the problem. The Gimp sets the alpha value of fully transparent pixels to black, not white. \$\endgroup\$ Nov 19, 2013 at 8:00
  • \$\begingroup\$ Can you post your glTexImage2D call? \$\endgroup\$ Nov 19, 2013 at 10:29
  • \$\begingroup\$ @Sam Hocevar, I would like to confirm that it is not the alpha blending problem indeed, @JimmyShelter, here is my glTexImage2D code. tgaType, as mentioned about is GL_RGBA. ` glTexImage2D` ( GL_TEXTURE_2D, 0, tgaType, planeTexture.width, planeTexture.height, 0, tgaType, GL_UNSIGNED_BYTE, planeTexture.imageData ); ` \$\endgroup\$
    – 2am
    Nov 20, 2013 at 2:05
  • \$\begingroup\$ OK, that's correct. It's most likely blend states, as per Tordin's answer then. \$\endgroup\$ Nov 20, 2013 at 10:50

1 Answer 1


You have most probably not set the correct blendstates to the gpu. If you have not, the gpu dont know how to handle your Alpha values.

this link is a good resource on how blendstates works. and how you should use them.

Basicly alpha is only anohter channel containing data. the texture itself never states what blendmode will apply or how the gpu will use it. that is all done by code.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .