Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Building open this tutorial - I have constructed a class for generating polygon meshes. But i cannot figure out how to render semi transparency, even though the mesh in the tutorial takes a color object with an alpha channel.

I am rendering with squareMesh.render(GL10.GL_TRIANGLE_STRIP, 0, 4); This is the code used for initializing the mesh

if (squareMesh == null) {
    squareMesh = new Mesh(true, 4, 4, 
                 new VertexAttribute(Usage.Position,    3, "a_position"),
                 new VertexAttribute(Usage.ColorPacked, 4, "a_color"));

    squareMesh.setVertices(new float[] {
        -0.5f, -0.5f, 0, Color.toFloatBits(128, 0, 0, 255),
         0.5f, -0.5f, 0, Color.toFloatBits(192, 0, 0, 255),
        -0.5f,  0.5f, 0, Color.toFloatBits(192, 0, 0, 255),
         0.5f,  0.5f, 0, Color.toFloatBits(255, 0, 0, 255) });   
    squareMesh.setIndices(new short[] { 0, 1, 2, 3});
share|improve this question
up vote 0 down vote accepted

In Color.toFloatBits(128, 0, 0, 255), the "255" is the alpha channel (where 255 means completely opaque and 0 means completely transparent = invisible).
Make sure you've enabled transparency in OpenGL with;, GL10.GL_ONE_MINUS_SRC_ALPHA);

to disable transparency again, simple use;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.