我的应用程序出了点小问题。我使用三星galaxy S3开发了我的应用程序,并对其进行了测试,结果一切正常!但问题是,在我完成应用程序后,我开始在其他设备上测试。这个应用程序在其他的Galaxy S3和Galaxy S上运行得很好,但是当我尝试在Sony Xperia和LG Optimus Net Dual上运行它时,屏幕就变成了黑色!
更有趣的是,这些设备上的应用程序,声音功能正常,广告出现,应用程序对触摸的反应完美,但只画了一个黑屏!这真的很奇怪。就像他们不支持opengles 2一样,但他们确实支持,而且android版本在Xperia上是4.0ICS,在LG上是2.2!
有人知道这是什么吗?或者遇到类似的问题?如果任何人想要代码,只需说并在这里发布!谢谢你的帮助!
编辑:
我的load纹理:
public static int loadTexture(final int ResourceId, final int min_filter, final int mag_filter) {
for (int i=0;i<nTextures;i++) if (Textures[i*2]==ResourceId) return Textures[i*2+1];
int[] textureHandle = new int[1];
GLES20.glGenTextures(1, textureHandle, 0);
if (textureHandle[0] != 0)
{
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false;
final Bitmap bitmap = BitmapFactory.decodeResource(GLRenderer.mContext.getResources(), ResourceId, options);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, min_filter);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, mag_filter);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0,GLES20.GL_RGBA, bitmap, 0);
bitmap.recycle();
}
if (textureHandle[0] == 0) throw new RuntimeException("Error loading texture.");
Textures[nTextures*2]=ResourceId;
Textures[nTextures*2+1]=textureHandle[0];
nTextures++;
return textureHandle[0];
}编辑2:
我的GLSurfaceView的创建:
GLActivityView(GLActivity context) {
super(context);
setEGLContextClientVersion(2);
// getHolder().setFormat(PixelFormat.TRANSLUCENT);
// setEGLConfigChooser(8, 8, 8, 8, 8, 8);
renderer = new GLRenderer(context);
setRenderer(renderer);
}发布于 2012-11-02 02:20:49
可能这些电话不支持NPOT功能。如果not不被支持,那么你可能想要确保你的纹理尺寸都是2的幂。
你可以像这样检查
static public boolean isNPOTSupported(GL10 gl) {
String extensions = gl.glGetString(GL10.GL_EXTENSIONS);
return extensions.indexOf("GL_OES_texture_npot") != -1;
}https://stackoverflow.com/questions/13183121
复制相似问题