Textures and colors are set on the pipeline before draw calls, and are then used/re-used where applicable on subsequent draw calls.
That means if you want your
Square
to have a different texture that your
Triangle
, you'll need to bind the texture before drawing the
Square
and then disable it after having drawn the
Square
.
Try changing your
loadTextures<code> method, so that it doesn't call <code>gl.glEnable(GL10.GL_TEXTURE_2D);
, then make sure you can get to the
texture id of the loaded texture.
Then you can pass the
texture id into the constructor of your
Square
class and bind it before the draw, something like this;
class Square {
private int textureId;
public Cube(int textureId) {
this.textureId = textureId;
}
public void draw(GL10 gl) {
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glBindTexture, GL10.GL_TEXTURE_20, textureId);
gl.glFrontFace(GL10.GL_CW);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, floatBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, shortBuffer);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisable(GL10.GL_TEXTURE_2D);
}
}
Where
textureId
is the id of the texture loaded.
Or you can pass the
texture id to the
draw
method.
Hope this helps,
Fredrik