我修改了我的代码以使用ETC1纹理来帮助降低内存使用量,同时纹理加载时,它不再自动生成mipmap。 ETC1图像不支持吗?我的继承人代码:使用具有ETC1纹理的mipmapps
//Generate three texture pointers...
gl.glGenTextures(3, textures, 0);
//...and bind it to our array
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
//Create Nearest Filtered Texture
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
// gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR_MIPMAP_NEAREST); //problem child
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
//gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_TRUE); problem child.
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
//Get the texture from the Android resource directory
Log.e("Sys", "ETC1 texture support: " + ETC1Util.isETC1Supported());
InputStream input = context.getResources().openRawResource(R.drawable.testtile);
try {
ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, input);
Log.w("sys", "loaded!");
} catch (IOException e) {
Log.w("sys", "Could not load texture: " + e);
} finally {
try {
input.close();
} catch (IOException e) {
// ignore exception thrown from close.
}
}
这就是我最终做的。 – jfisk