public void setTextureAlpha(float alpha) { if (mTextureAlpha == alpha) return; mTextureAlpha = alpha; if (alpha >= OPAQUE_ALPHA) { // The alpha is need for those texture without alpha channel mGL.glColor4f(1, 1, 1, 1); setTexEnvMode(GL11.GL_REPLACE); } else { mGL.glColor4f(alpha, alpha, alpha, alpha); setTexEnvMode(GL11.GL_MODULATE); } }
private void setAlphaValue(float alpha) { if (mLastAlpha == alpha) return; GL11 gl = mGL; mLastAlpha = alpha; if (alpha >= 0.95f) { gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); } else { gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); gl.glColor4f(alpha, alpha, alpha, alpha); } }
public void drawColor(int x, int y, int width, int height, int color) { float alpha = mTransformation.getAlpha(); GL11 gl = mGL; if (mTexture2DEnabled) { // Set mLastAlpha to an invalid value, so that it will reset again // in setAlphaValue(float) later. mLastAlpha = -1.0f; gl.glDisable(GL11.GL_TEXTURE_2D); mTexture2DEnabled = false; } alpha /= 256.0f; gl.glColor4f( Color.red(color) * alpha, Color.green(color) * alpha, Color.blue(color) * alpha, Color.alpha(color) * alpha); drawRect(x, y, width, height); }