2011-07-25 44 views
3

我正在使用openGL ES 2.0创建动态壁纸。 该应用程序在我的Nexus One的伟大工程,但它并不没有表现出一台Nexus S.Nexus S中的glError 1282但不支持Nexus One

事情到目前为止,我还测试了什么:

  • 我已经检查this question。我的纹理是128x128,所以我想这不是问题。

  • 我在代码中使用了checkGlError方法,我发现它通过了onSurfaceCreatedonSurfaceChanged没有问题。如果我在onDrawFrame()方法的第一行中调用它,该方法会抛出异常。

checkGlError代码如下:

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); 
    } 
} 

我注意到,在这两种设备发生错误,但它会在Nexus S的关键,而它绘制在Nexus One的罚款。我的猜测是着色器编译不正确,那里有一个问题。

你知道链接S和链接之间的其他不兼容吗? 有没有调试着色器代码的方法?

回答

0

在结束我的问题涉及到this question

从资源中读取时,Android调整了我的纹理。我解决它从原始文件夹读取纹理:

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 
     ... 
    } 
1

您是否知道nexus S与nexus one之间的其他不兼容性?

不是我所知道的,尽管肯定有OpenGL ES驱动程序不同于电话的可能性。

有没有调试着色器代码的方法?

我还没有尝试着色器自己,但不过,我可以在我的GLSurfaceView上定期检查平移,旋转等,调试

尝试设置此您GLSurfaceView和检查,如果你能看到logcat的变化:

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