开发者

glError 1282 in the Nexus S but not in the Nexus One

I am creating a live wallpaper using openGL ES 2.0. The app works great in my nexus one but it doesn't not show anything in a Nexus S.

Things I have tested so far:

  • I have already checked this question. My texture is 128x128 so I guess this isn't the issue.

  • I have used the checkGlError method in my code and I found that it passes the onSurfaceCreated and onSurfaceChanged without issues. The method throws an exception if I call it in the first line of the onDrawFrame() method.

The 开发者_如何学运维checkGlError code is the following:

private void checkGlError(String op) {
    int error;
    while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
        Log.e(TAG, op + ": glError " + error);
        throw new RuntimeException(op + ": glError " + error);
    }
}

I notice that the error occurs in both devices, but it looks critical in the nexus S while it draws fine in the nexus one. My guess is that the shader is not compiled correctly and there is an issue there.

Do you know other incompatibilities between the nexus S and the nexus one? Is there a way of debugging shader's code?


Do you know other incompatibilities between the nexus S and the nexus one?

Not what I'm aware of, although there surely are possibilities where the OpenGL ES driver differs from phone to phone.

Is there a way of debugging shader's code?

I haven't experimented with shaders myself, but however, I can check regular translations, rotations, etc, with debugging on on my GLSurfaceView.

Try set this on your GLSurfaceView and check if you are able to see changes in LogCat:

mGLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR 
    | GLSurfaceView.DEBUG_LOG_GL_CALLS);


In the end my issue was related to this question.

When reading from resources Android resized my texture. I solved it reading the texture from the raw folder:

public void loadBitmap(int resourceId) {

        textureId = resourceId;

        /* Get the texture */
        InputStream is = mContext.getResources().openRawResource(textureId);
        Bitmap bitmap;

        try {
            bitmap = BitmapFactory.decodeStream(is);
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        int width = bitmap.getWidth();
        int height = bitmap.getHeight();

        Buffer data = ByteBuffer.allocateDirect(width * height * 4);
        bitmap.copyPixelsToBuffer(data);
        data.position(0);

        // Bind the texture object
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures.get(0));
        ...
        // OpenGL stuff
        ...
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜