-1

I have issue with texture with alpha channel. I'm rendering a palm tree with leaves: enter image description here

but as you can see, sky is over leaves on the left side of the picture.

In my code, sky is rendered, then i render the trees. Here is my code which renders one palm tree:

        RenderFrame(0);//trunk
        //glColor3f(0.0, 0.6, 0.0);
        glEnable(GL_BLEND);
        glDisable(GL_CULL_FACE);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        leaves.RenderFrame(0);
        glEnable(GL_CULL_FACE);
        glDisable(GL_BLEND);
Barcio77
  • 36
  • 8
  • Do you have depth testing enabled? If yes, the leaves might just be behind the sky, and eliminated by the depth test. – Reto Koradi Apr 22 '15 at 16:05
  • It's even worse. I see leaves which are behind other objects. I think it has to be sorted (from furthest to nearest camera)... – Barcio77 Apr 22 '15 at 18:55

1 Answers1

0

Like others stated, it seems that the order of rendering is wrong. I've had this issue in the past and it isn't a simple solution, especially since you are using deprecated immediate mode. Take a look at these solutions in this question: OpenGL ES2 Alpha test problems

Community
  • 1
  • 1
sgtHale
  • 1,507
  • 1
  • 16
  • 28