Hi folks,
Making an Android app. Whenever I set GL10.GL_TEXTURE_MIN_FILTER to GL_LINEAR_MIPMAP_NEAREST and GL_TEXTURE_MAG_FILTER to GL_LINEAR my textures disappear and only a white cube is generated in it’s place. Same if I don’t set them and use the default values. But if both are either GL_LINEAR or GL_NEAREST (or a combination of the two) it works fine.
This is my code…any advice? Below works, but not if I change GL10.GL_TEXTURE_MIN_FILTER to GL_LINEAR_MIPMAP_NEAREST. (Note: I tried both methods shown below of loading the bitmap with the same results)
public void loadTexture(GL10 gl, Context context) {
gl.glGenTextures(1, textureIDs, 0);
// final BitmapFactory.Options options = new BitmapFactory.Options();
// options.inScaled = false;
// final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.myTexture, options);
InputStream is = context.getResources().openRawResource(R.drawable.myTexture);
Bitmap bitmap;
try {
bitmap = BitmapFactory.decodeStream(is);
} finally {
try {
is.close();
} catch(IOException e) {
}
}
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureIDs[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();
}