I like to draw a rectangle with the OpenGL ES 1.0 function "drawArray" and over this rectangele I want to draw a texture with alpha. (A Hud element and the drawArray rectangle shows the "fill state" of that element).
Basically it works but the texture with alpha which I draw over the drawArray rectangle is affected by the color of the rectangle. the drawArray draws a blue rectangle and the texture shows after drawing also blueish.
Here the functions I'm using:
SOLVED -- See "START SOLUTION"
private void bagFillState(GL10 gl) {
// fill state background
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glPushMatrix();
gl.glScalef(0.25f, 0.25f, 0f);
gl.glTranslatef(0.0f, 3.0f, 0f);
gl.glDisable(GL10.GL_TEXTURE_2D);
// Draw background
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, _vertsGUIFillBuffer);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glColorPointer(4, GL10.GL_FLOAT, 0, _colorGUIFillBuffer);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
// START SOLUTION - Add the following Line
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
// END SOLTUTION
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glPopMatrix();
gl.glLoadIdentity();
}
The method who draws the texture over it:
private void bagChoosing(GL10 gl) {
// HUD
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glPushMatrix();
gl.glScalef(0.25f, 1.0f, 1f);
gl.glTranslatef(0.0f, 0.0f, 0f);
gl.glMatrixMode(GL10.GL_TEXTURE);
gl.glLoadIdentity();
_gui.draw(gl);
gl.glPopMatrix();
gl.glLoadIdentity();
}
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_STENCIL_BUFFER_BIT);
background1(gl);
movePlayer1(gl);
bagFillState(gl);
bagChoosing(gl);
// All other game drawing will be called here
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
}
Is there something special I have to do while loading the texture or drawing with "drawArray", so the drawArray rectangle doesn't affect the textures color? Thanks for any hint or link.