0
\$\begingroup\$

I am binding a texture to draw over some geometry (using the ImmediateModeRenderer20) but the alpha channel of the texture turns into colour black when drawn. Why is that happening?

My draw call loop looks sort of like this:

immediateModeRenderer20.begin(renderer.getUiCamera().combined, GL20.GL_TRIANGLE_STRIP);
immediateModeRenderer20.color(new Color(1, 1, 1, 1));
immediateModeRenderer20.texCoord(distance, tc.y);
immediateModeRenderer20.vertex(point.x, point.y, 0f);
immediateModeRenderer20.end();
\$\endgroup\$
3
  • \$\begingroup\$ Most likely because you set the internalFormat parameter to GL_RGB when loading the texture. \$\endgroup\$ Commented Jul 10, 2017 at 17:05
  • \$\begingroup\$ @LeComteduMerde-fou I have not, but if that's the default then it might be the case. Can you help me with changing it? \$\endgroup\$
    – kacpr
    Commented Jul 10, 2017 at 18:03
  • \$\begingroup\$ Look at your glTexImage call. \$\endgroup\$ Commented Jul 10, 2017 at 18:57

1 Answer 1

2
\$\begingroup\$

Make sure blending is enabled. Otherwise OpenGL will not blend between overlapping fragments.

glEnable(GL_BLEND);

Also you need to specify which factors are used for the blending calculation. This would be additive blending:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

After your end() function you should disable blending again, as it may not be wanted for other calls.

glDisable(GL_BLEND);
\$\endgroup\$
0

You must log in to answer this question.

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