OpenGL ES 2.0纹理在某些设备上显示黑色

时间:2017-07-22 06:06:41

标签: android opengl-es opengl-es-2.0 overlay

我正在使用OpenGL ES 2.0将覆盖贴纸加载到我的图像中,它在某些设备(如一加和最大)中工作正常,但它不适用于某些中档设备,如moto g3。

我尝试了堆叠溢出的其他答案,但它们似乎都不适用于我。

这是我的加载代码

public void load(int i, int j, int k)
{
    Utils.printLog(TAG, (new StringBuilder()).append("startX:").append(j).append("  startY:").append(k).toString());
    if(bitmap != null)
    {

        GLES20.glActiveTexture(33984 + textureId);
        GLES20.glBindTexture(3553, i);

        GLES20.glTexParameteri(3553, 10241, 9729);
        GLES20.glTexParameteri(3553, 10240, 9729);
        GLES20.glTexParameterf(3553, 10242, 33071F);
        GLES20.glTexParameterf(3553, 10243, 33071F);

        imageWidth = bitmap.getWidth();
        imageHeight = bitmap.getHeight();



        Log.d("TAG", "Width is " + imageWidth + "H is " + imageHeight);
        int l;

        Log.d("TAG", bitmap.getConfig().toString());

        if(bitmap.getConfig() == Bitmap.Config.ALPHA_8)
        {
            GLES20.glPixelStorei(3317, 1);
            GLUtils.texSubImage2D(3553, 0, j, k, bitmap);
            GLES20.glPixelStorei(3317, 4);
        } else
        {
            GLUtils.texSubImage2D(3553, 0, j, k, bitmap);
        }
        l = GLES20.glGetError();
        if(l != 0)
        {
            Log.e("SubOverlay", (new StringBuilder()).append("load: texSubImage2D() ").append(l).toString());

            (new Throwable()).printStackTrace();
        }
        startX = j;
        startY = k;
        widthRatio = imageWidth / displayWidth;
        heightRatio = imageHeight / displayHeight;
        bitmap.recycle();
        initPos();
    }
}

请帮我解决这个问题。

0 个答案:

没有答案
相关问题