Texture problem help needed

Hello world!!!
I have a big problem programming a card game. I want to apply two textures: one on the front of my card and another to the back of my card.
Here is my code:

// lets place the sarting point of cards on the draw stack
gl.glTranslatef(1.9F, 12.4F, 0F);

   //draw
   gl.glPushMatrix();
   com.sun.opengl.util.texture.Texture texFrontFace = TexLoader.load(this.cardTopTexturePath);
   texFrontFace.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
   texFrontFace.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
   TextureCoords tcFrontFace = texFrontFace.getImageTexCoords();

   com.sun.opengl.util.texture.Texture texBackFace = TexLoader.load(this.cardBackTexturePath);
   texBackFace.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
   texBackFace.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
   TextureCoords tcBackFace = texBackFace.getImageTexCoords();

   float xrot= 90f;
   float yrot= 180f;
   float zrot= 0f;

   gl.glTranslatef(0, 0, 0);
   gl.glRotatef(xrot, 1.0F, 0.0F, 0.0F);
   gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
   gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
   gl.glScalef(0.31F, 0.31F, 0.31F); //TOO BIG


   gl.glEnable(GL.GL_BLEND);
   gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
   gl.glEnable(GL.GL_ALPHA_TEST);
   gl.glAlphaFunc(GL.GL_GREATER, 0);

   gl.glEnable(GL.GL_TEXTURE_2D);
   texFrontFace.bind();

   // replace the quad colours with the texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_REPLACE);

   //cardModel.opengldraw(gl);

   gl.glBegin(GL.GL_QUADS);
            gl.glNormal3f(0.0f, 0.0f, 1.0f);
            gl.glTexCoord2f(tcFrontFace.left(), tcFrontFace.bottom());
            gl.glVertex3f(-6.1f, 0f, -9f);
            gl.glTexCoord2f(tcFrontFace.right(), tcFrontFace.bottom());
            gl.glVertex3f(6f, 0f, -9f);
            gl.glTexCoord2f(tcFrontFace.right(), tcFrontFace.top());
            gl.glVertex3f(6f, 0f, 9f);
            gl.glTexCoord2f(tcFrontFace.left(), tcFrontFace.top());
            gl.glVertex3f(-6.1f, 0f, 9f);
   gl.glEnd();

   gl.glDisable(GL.GL_TEXTURE_2D);
   // switch back to modulation of quad colours and texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_MODULATE);
   gl.glDisable(GL.GL_ALPHA);  // switch off transparency
   gl.glDisable(GL.GL_BLEND);




   gl.glEnable(GL.GL_BLEND);
   gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
   gl.glEnable(GL.GL_ALPHA_TEST);
   gl.glAlphaFunc(GL.GL_GREATER, 0);

   gl.glEnable(GL.GL_TEXTURE_2D);
   texBackFace.bind();

   // replace the quad colours with the texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_REPLACE);

   //cardModel.opengldraw(gl);

   gl.glBegin(GL.GL_QUADS);
            gl.glNormal3f(0.0f, 0.0f, -1.0f);
            gl.glTexCoord2f(tcBackFace.left(), tcBackFace.bottom());
            gl.glVertex3f(-6.1f, 0f, -9f);
            gl.glTexCoord2f(tcBackFace.right(), tcBackFace.bottom());
            gl.glVertex3f(6f, 0f, -9f);
            gl.glTexCoord2f(tcBackFace.right(), tcBackFace.top());
            gl.glVertex3f(6f, 0f, 9f);
            gl.glTexCoord2f(tcBackFace.left(), tcBackFace.top());
            gl.glVertex3f(-6.1f, 0f, 9f);
   gl.glEnd();

   gl.glDisable(GL.GL_TEXTURE_2D);
   // switch back to modulation of quad colours and texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_MODULATE);
   gl.glDisable(GL.GL_ALPHA);  // switch off transparency
   gl.glDisable(GL.GL_BLEND);

   gl.glPopMatrix();

The fact is that jogl print the front face but not the back face (i see front face from each point of vue but reverse from the opposite point of vue, like if it was transparent)

Thanks for help

Hi!

Do you use glCullFace anywhere?

You should ask your questions here:
http://jogamp.org/forum.html

No but i don’t know how to use it.
What is this method about?

I solved my problem with this:

// lets place the sarting point of cards on the draw stack
gl.glTranslatef(1.9F, 12.4F, 0F);

  [b]gl.glEnable(GL.GL_CULL_FACE);[/b]

   //draw
   gl.glPushMatrix();
   com.sun.opengl.util.texture.Texture texFrontFace = TexLoader.load(this.cardTopTexturePath);
   texFrontFace.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
   texFrontFace.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
   TextureCoords tcFrontFace = texFrontFace.getImageTexCoords();

   com.sun.opengl.util.texture.Texture texBackFace = TexLoader.load(this.cardBackTexturePath);
   texBackFace.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
   texBackFace.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
   TextureCoords tcBackFace = texBackFace.getImageTexCoords();

   float xrot= 90f;
   float yrot= 180f;
   float zrot= 0f;

   gl.glTranslatef(0, 0, 0);
   gl.glRotatef(xrot, 1.0F, 0.0F, 0.0F);
   gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
   gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
   gl.glScalef(0.31F, 0.31F, 0.31F); //TOO BIG


   [b]gl.glCullFace(GL.GL_FRONT);[/b]
   gl.glEnable(GL.GL_BLEND);
   gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
   gl.glEnable(GL.GL_ALPHA_TEST);
   gl.glAlphaFunc(GL.GL_GREATER, 0);

   gl.glEnable(GL.GL_TEXTURE_2D);
   texFrontFace.bind();

   // replace the quad colours with the texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_REPLACE);

   //cardModel.opengldraw(gl);

   gl.glBegin(GL.GL_QUADS);
            gl.glNormal3f(0.0f, 0.0f, 1.0f);
            gl.glTexCoord2f(tcFrontFace.left(), tcFrontFace.bottom());
            gl.glVertex3f(-6.1f, 0f, -9f);
            gl.glTexCoord2f(tcFrontFace.right(), tcFrontFace.bottom());
            gl.glVertex3f(6f, 0f, -9f);
            gl.glTexCoord2f(tcFrontFace.right(), tcFrontFace.top());
            gl.glVertex3f(6f, 0f, 9f);
            gl.glTexCoord2f(tcFrontFace.left(), tcFrontFace.top());
            gl.glVertex3f(-6.1f, 0f, 9f);
   gl.glEnd();

   gl.glDisable(GL.GL_TEXTURE_2D);
   // switch back to modulation of quad colours and texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_MODULATE);
   gl.glDisable(GL.GL_ALPHA);  // switch off transparency
   gl.glDisable(GL.GL_BLEND);




   [b]gl.glCullFace(GL.GL_BACK);[/b]
   gl.glEnable(GL.GL_BLEND);
   gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
   gl.glEnable(GL.GL_ALPHA_TEST);
   gl.glAlphaFunc(GL.GL_GREATER, 0);

   gl.glEnable(GL.GL_TEXTURE_2D);
   texBackFace.bind();

   // replace the quad colours with the texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_REPLACE);

   //cardModel.opengldraw(gl);

   gl.glBegin(GL.GL_QUADS);
            gl.glNormal3f(0.0f, 0.0f, -1.0f);
            gl.glTexCoord2f(tcBackFace.left(), tcBackFace.bottom());
            gl.glVertex3f(-6.1f, 0f, -9f);
            gl.glTexCoord2f(tcBackFace.right(), tcBackFace.bottom());
            gl.glVertex3f(6f, 0f, -9f);
            gl.glTexCoord2f(tcBackFace.right(), tcBackFace.top());
            gl.glVertex3f(6f, 0f, 9f);
            gl.glTexCoord2f(tcBackFace.left(), tcBackFace.top());
            gl.glVertex3f(-6.1f, 0f, 9f);
   gl.glEnd();

   gl.glDisable(GL.GL_TEXTURE_2D);
   // switch back to modulation of quad colours and texture
   gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,GL.GL_MODULATE);
   gl.glDisable(GL.GL_ALPHA);  // switch off transparency
   gl.glDisable(GL.GL_BLEND);

   gl.glPopMatrix();

Anyway thanks for help!!!

Sorry for asking but, how come? It’s a pretty generic OpenGL question and I don’t think you should send everyone away from JG any less than all people using the other libraries should…

Mike

Ok that is what I meant, the use of glCullFace has solved your problem :slight_smile:

It is a pretty generic OpenGL question asked into the JOGL section. If he has a specific problem with JOGL, more people will answer on the official forum of JogAmp than here. Sorry to tell you this but I don’t mind people using the other OpenGL binding as we are in the JOGL section.