Hi!
I have a problem trying to mask an image. The mask won't work, I have no clue what's wrong.
The rendering code looks like:
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glBlendFunc(GL11.GL_DST_COLOR,GL11.GL_ZERO);
GL11.glBindTexture(GL11.GL_TEXTURE_2D,hero.getCurrentImageMask());
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0.0f,0.0f); GL11.glVertex2f(v1.x,v1.y);
GL11.glTexCoord2f(1.0f,0.0f); GL11.glVertex2f(v2.x,v2.y);
GL11.glTexCoord2f(1.0f,1.0f); GL11.glVertex2f(v3.x,v3.y);
GL11.glTexCoord2f(0.0f,1.0f); GL11.glVertex2f(v4.x,v4.y);
GL11.glEnd();
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
GL11.glBindTexture(GL11.GL_TEXTURE_2D,hero.getCurrentImage());
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0.0f,0.0f); GL11.glVertex2f(v1.x,v1.y);
GL11.glTexCoord2f(1.0f,0.0f); GL11.glVertex2f(v2.x,v2.y);
GL11.glTexCoord2f(1.0f,1.0f); GL11.glVertex2f(v3.x,v3.y);
GL11.glTexCoord2f(0.0f,1.0f); GL11.glVertex2f(v4.x,v4.y);
GL11.glEnd();
GL11.glEnable(GL11.GL_DEPTH_TEST);
and the initing part goes like this:
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
GL11.glClearDepth(1.0f);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0,800, 0, 600, 0, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
What's wrong here? The mask makes no difference whatsoever. Pictures are loaded, and the mask is correctly made.
The code only shows the picture with no mask applied.
- Sip
Heh, looks like the images weren't correctly made after all. My bad :)
That (as near as I can tell) requires 2 rendering passes (one for the mask and one for the texture). Have you thought about generating a texture based on the mask and the alpha value is 1.0 or 0.0 according to the mask? That way it would only require one rendering pass.
Just a thought ;D