I feel there is a problem with the Z-BUFFER!
I can not make the faces of the cubes are properly textured visible or not.
Here is what I obtain:
http://www.liveatblocks.fr/eer.png
and here is my code:
@Override
public void init(GLAutoDrawable gLDrawable)
{
System.out.println("init() called");
GL2 gl = gLDrawable.getGL().getGL2();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glEnable(GL2.GL_DEPTH_TEST); // Enables Depth Testing
gl.glDepthFunc(GL2.GL_LESS);
}
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
texPack.getTexture(numtex).getTop().enable();
texPack.getTexture(numtex).getTop().bind();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
gl.glBegin(GL2.GL_QUADS);
gl.glNormal3f(0.0f, 1.0f, 0.0f);
gl.glTexCoord2d(0.0f, 0.0f); gl.glVertex3f(x, y + CUBESIZE, z);
gl.glTexCoord2d(1.0f, 0.0f); gl.glVertex3f(x + CUBESIZE, y + CUBESIZE, z);
gl.glTexCoord2d(1.0f, 1.0f); gl.glVertex3f(x + CUBESIZE, y + CUBESIZE, z + CUBESIZE);
gl.glTexCoord2d(0.0f, 1.0f); gl.glVertex3f(x, y + CUBESIZE, z + CUBESIZE);
gl.glEnd();
texPack.getTexture(numtex).getTop().disable();
texPack.getTexture(numtex).getBottom().enable();
texPack.getTexture(numtex).getBottom().bind();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
gl.glNormal3f(0.0f, -1.0f, 0.0f);
gl.glTexCoord2d(0.0f, 0.0f); gl.glVertex3f(x + CUBESIZE, y, z);
gl.glTexCoord2d(1.0f, 0.0f); gl.glVertex3f(x, y, z);
gl.glTexCoord2d(1.0f, 1.0f); gl.glVertex3f(x, y, z + CUBESIZE);
gl.glTexCoord2d(0.0f, 1.0f); gl.glVertex3f(x + CUBESIZE, y, z + CUBESIZE);
gl.glEnd();
texPack.getTexture(numtex).getBottom().disable();
texPack.getTexture(numtex).getRight().enable();
texPack.getTexture(numtex).getRight().bind();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
gl.glBegin(GL2.GL_QUADS);
gl.glNormal3f(1.0f, 0.0f, 0.0f);
gl.glTexCoord2d(0.0f, 0.0f); gl.glVertex3f(x + CUBESIZE, y + CUBESIZE, z + CUBESIZE);
gl.glTexCoord2d(1.0f, 0.0f); gl.glVertex3f(x + CUBESIZE, y + CUBESIZE, z);
gl.glTexCoord2d(1.0f, 1.0f); gl.glVertex3f(x + CUBESIZE, y, z);
gl.glTexCoord2d(0.0f, 1.0f); gl.glVertex3f(x + CUBESIZE, y, z + CUBESIZE);
gl.glEnd();
texPack.getTexture(numtex).getRight().disable();
texPack.getTexture(numtex).getLeft().enable();
texPack.getTexture(numtex).getLeft().bind();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
gl.glBegin(GL2.GL_QUADS);
gl.glNormal3f(-1.0f, 0.0f, 0.0f);
gl.glTexCoord2d(0.0f, 0.0f); gl.glVertex3f(x, y + CUBESIZE, z);
gl.glTexCoord2d(1.0f, 0.0f); gl.glVertex3f(x, y + CUBESIZE, z + CUBESIZE);
gl.glTexCoord2d(1.0f, 1.0f); gl.glVertex3f(x, y, z + CUBESIZE);
gl.glTexCoord2d(0.0f, 1.0f); gl.glVertex3f(x, y, z);
gl.glEnd();
texPack.getTexture(numtex).getLeft().disable();
texPack.getTexture(numtex).getFront().enable();
texPack.getTexture(numtex).getFront().bind();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
gl.glBegin(GL2.GL_QUADS);
gl.glNormal3f(0.0f, 0.0f, 1.0f);
gl.glTexCoord2d(0.0f, 0.0f); gl.glVertex3f(x, y + CUBESIZE, z + CUBESIZE);
gl.glTexCoord2d(1.0f, 0.0f); gl.glVertex3f(x + CUBESIZE, y + CUBESIZE, z + CUBESIZE);
gl.glTexCoord2d(1.0f, 1.0f); gl.glVertex3f(x + CUBESIZE, y, z + CUBESIZE);
gl.glTexCoord2d(0.0f, 1.0f); gl.glVertex3f(x, y, z + CUBESIZE);
gl.glEnd();
texPack.getTexture(numtex).getFront().disable();
texPack.getTexture(numtex).getBack().enable();
texPack.getTexture(numtex).getBack().bind();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
gl.glBegin(GL2.GL_QUADS);
gl.glNormal3f(0.0f, 0.0f, -1.0f);
gl.glTexCoord2d(0.0f, 0.0f); gl.glVertex3f(x + CUBESIZE, y + CUBESIZE, z);
gl.glTexCoord2d(1.0f, 0.0f); gl.glVertex3f(x, y + CUBESIZE, z);
gl.glTexCoord2d(1.0f, 1.0f); gl.glVertex3f(x, y, z);
gl.glTexCoord2d(0.0f, 1.0f); gl.glVertex3f(x + CUBESIZE, y, z);
gl.glEnd();
texPack.getTexture(numtex).getBack().disable();
gl.glDisable(GL2.GL_BLEND);
texPack.getTexture(numtex).getTop() // Renvoi l’objet Texture ou est charger le fichier top.png
texPack.getTexture(numtex).getBottom() // Renvoi l’objet Texture ou est charger le fichier bottom.png
texPack.getTexture(numtex).getRight() // Renvoi l’objet Texture ou est charger le fichier right.png
texPack.getTexture(numtex).getLeft() // Renvoi l’objet Texture ou est charger le fichier left.png
texPack.getTexture(numtex).getFront() // Renvoi l’objet Texture ou est charger le fichier front.png
texPack.getTexture(numtex).getBack() // Renvoi l’objet Texture ou est charger le fichier back.png
Please HELP ME !!