
Untitled
By: a guest on
Jul 17th, 2012 | syntax:
None | size: 1.11 KB | hits: 20 | expires: Never
Android OpenGL ES texture TextImage2D error
public static void loadGLTexture(GL10 gl, Context context){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDensity = 240;// needed so that the image will be 512x512
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.glasstexture, options);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Log.i("GridLoginSquare.loadGLTexture 96", "Bitmap:{w:" + width + " h:" + height + "}");
gl.glGenTextures(1, textures, 0);
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_MAG_FILTER, GL10.GL_LINEAR);
// Use Android GLUtils to specify a two-dimensional texture image from our bitmap
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); //error is on this line
Log.e("GridLoginSquare.loadGLTexture 102", " ERR "+gl.glGetError());
// Clean up
bitmap.recycle();
}