2
votes

I have a problem where the colors of any textures that I use are bleached, if that's a good word to use to describe it, on two different phones but the textures show up just fine on the emulator.

Here are the images. The first image is the texture that I'm using. The second image is how the texture shows up on the emulator and the way it is supposed to show up on the phones. The third image is how the texture actually shows up on the phone.

Should I include the code where I draw the rectangle? The rectangle is just a vertex buffer and texcoord buffer. Anything that actually is done with the texture is gl.glBindTexture and gl.glBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA). gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f) is also called.

The following code is where I believe my error could exist. I hope someone can help me out here. Thanks!

This is in my GLSurfaceView.Renderer implementation

@Override
public void onSurfaceCreated(final GL10 gl, final EGLConfig config) {
    DebugLog.d("onSurfaceCreated");

    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
    gl.glShadeModel(GL10.GL_FLAT);

    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_DITHER);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_MULTISAMPLE);

    gl.glEnable(GL10.GL_BLEND);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glFrontFace(GL10.GL_CW);
    gl.glCullFace(GL10.GL_BACK);
}

This is in my BitmapTexture class.

@Override
public void loadBitmapToHardware(final GL10 gl) throws IOException {
    final Bitmap bitmap = loadBitmap();

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, bitmap, GL10.GL_UNSIGNED_BYTE, 0);

    bitmap.recycle();
}

@Override
public Bitmap loadBitmap() {
    InputStream is = null;
    try {
        is = mContext.getAssets().open(mBitmapPath);
        return BitmapFactory.decodeStream(is);
    } catch (final IOException e) {
        DebugLog.e("Failed to load Bitmap in " + this.getClass().getSimpleName() + " from path: " + mBitmapPath, e);
        return null;
    } finally {
        try {
            is.close();
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
}

@Override
public void loadTexture() throws IOException {
    gl.glGenTextures(1, TEXTURE_CONTAINER, 0);
    mTextureId = TEXTURE_CONTAINER[0];
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureId);

    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.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);

    loadBitmapToHardware();
}
1

1 Answers

0
votes

It looks like an overexposure issue to me. It is likely that the screen settings for the emulator and your phone handles this problem differently, especially since dither is disabled in your code.

You should try to:
1: Remove the glColor4f() call, and see if that works (from what I know of GL10, it sets the color to white in your case, which might cause problems with blending).
or
2: Turn of blending and turn on depth-test to see if your blending give this result.