0

I doesn't have experience with OpenGL (and my question proof this) but I need a little snipplet to solve a problem. I have a mesh, a square and I need to apply 2 Texture: 1 FrontSide and 1 BackSide. This is the code to apply the texture frontside:

mTextureIds = new int[1];
gl.glGenTextures(1, mTextureIds, 0);
// Set texture attributes.
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureIds[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureIds[0]);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mBitmapFrontSide, 0);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexCoords);

Someone can help me?
1] Is it possible to aply 2 different texture 1 frontside and 1 backside?
2] Some one can post a snipplet or indicate a tutorial or other material?
Thanks.

Neo1975
  • 124
  • 11

1 Answers1

2

Since you don't appear to be using shaders, the easiest thing you can do is use backface culling to your advantage. Render the object with one face culling, then change the texture and render it with the opposite faces being rendered.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • The solution to change the texture to rander is not the solution becouse the mesh is a "flexible" sqare and is possible to see both side at the same time. So the only other solution is use shaders? – Neo1975 Aug 27 '11 at 13:04
  • @Neo1975: Triangles are, by definition, planar. You can only ever see one side of any individual triangle. Therefore, a triangle that is rendered with one face culling will _necessarily_ not be rendered with the other. As such, you are guaranteed to be able to render the mesh as I described, because each triangle component of the mesh will be visible in only one of the two passes. – Nicol Bolas Aug 27 '11 at 13:05
  • @Nicole You are right. I have to investigate about this. Do you fan suggest something TO read? By other band do you thing use 2 square with the same coordinate can solve my questi on? – Neo1975 Aug 27 '11 at 13:43