I am trying to make a simple textured square on Android 2.2 using GLSurfaceView . I upload a BMP image (128x128) using BitmapFactory.decodeResource() - this seems to work. But whenever I try to put this bitmap into an OpenGL texture using GLUtils.glTexImage2D , I get an OpenGL error: glGetError() returns 1280, GL_INVALID_ENUM . What am I doing wrong? This is the code for my Renderer:
public class MyRenderer implements GLSurfaceView.Renderer { Context context; int texId; public MyRenderer(Context c) { this.context = c; } @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glEnable(GL10.GL_TEXTURE_2D); this.texId = loadTexture(gl); } int loadTexture(GL10 gl) { int[] tmp = new int[1]; gl.glGenTextures(1, tmp, 0); int id = tmp[0]; Bitmap bmp = BitmapFactory.decodeResource(this.context.getResources(), R.drawable.myimage); gl.glGetError(); GLUtils.texImage2D(id, 0, bmp, 0); int err = gl.glGetError(); if (err != 0) {
android opengl-es
Marvin killing
source share