在我的应用程序中,我尝试使用纹理,但我收到了错误
:0: SGXQueueTransfer: all paths failed
:0: HardwareMipGen: Failed to generate texture mipmap levels (error=3)
在我的Galaxy Nexus上。我的EVO 4G没有出现这些错误。
以下是相关的加载代码。
private static int load(Context context, int resID) {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),
resID);
int[] texts = new int[1];
GLES20.glGenTextures(1, texts, 0);
int texID = texts[0];
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texID);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_REPEAT);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
return texID;
}
private static int loadWithMipmap(Context context, int resID) {
int texID = load(context, resID);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);
GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
return texID;
}
任何想法是什么以及我如何解决它?
编辑:只有一个图像导致错误,它是1024x2048 png。
答案 0 :(得分:1)
弗里金吓人的。在Galaxy Nexus 7上测试。
您需要执行以下操作:
GLES20.glTexParameterf(
GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_LINEAR_MIPMAP_NEAREST);
this.context.checkError("GL_TEXTURE_MIN_FILTER");
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_LINEAR);
严格来说,我猜GL_LINEAR_MIPMAP_NEAREST不是有效的MAG_FILTER。无论如何,Nexus 7都这么认为。并且它随着变化而精美地制作。
答案 1 :(得分:1)
我看到了这一点,一旦我把图像压成方形,它就起作用了。 OpenGL不会出错。
答案 2 :(得分:0)
狂野的猜测,因为我没有对你提到的硬件有任何访问权限,但是非<2> 尺寸的纹理会出现错误吗?