Hi mannewalis,
This can be solved in 2 ways,
1. The texture should be binded before you do any operation on
the texture. To be in safer side, the texture size should be in
power
of 2.
To generate the texture, use glGenTextures(int n, IntBuffer
textures)
To bind the texture, use glBindTexture(int target, int texture).
Eg:
// Our texture.
int[] textures = new int[1];
//Generate one texture pointer...
gl.glGenTextures(1, textures, 0);
//...and bind it to our array
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
The above texture creation and binding should be called only
once when the surface is created. Now u should be able to call your
glTexImage2D() any number of times in draw().
2. The second solution is as follows,
try using below code inside some function say
public void loadGLTexture(){
..
//your code that sets all texture parameters.
..
int textureWidthInPowerOf2 = 512;
int textureHeightInPowerOf2= 512;
/** Create a bitMap which has width and height in
power of 2. */
Bitmap b = Bitmap.createBitmap(textureWidthInPowerOf2,
textureHeightInPowerOf2, Bitmap.Config.RGB_565);
/** This function creates a texture of size
textureWidthInPowerOf2*textureHeightInPowerOf2. */
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, b, 0);
}
The above function should be called only once and good if it is called
in onSurfaceCreated(). The above code draws a bitMap with texture as
specified.The texture is now set.
And in
public void draw(){
..
// Your code that may or may not crop the image.
..
GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0,0,0, aBitmap);
}
Now, you can draw bitmap any number of times on the texture that was
created.
The solution 2 is demo to draw bitMaps, u can use the same logic to
draw anything.
Also, you get error code 1280 if the parameters passed to any openGL
function call is invalid or not appropriate.