OK, here’s the deal. After we have fought a battle of thousand courses we finally got those snicky textures on our screen. Now, happy as we are, we noticed that we only can use the texture that has been loaded most recently.
So, basically, as soon as we load an other texture (we even tried to simply make a copy of the first byte[] so we know we got nice numbers in there), the previous seems to got forgotten and only a white square appears. The element drawn after we call binding for the other (the most recently loaded) texture, however, works perfectly.
We suspect we missed something important. The approach we use is pretty much this.
int[] fuckTures = new int[2];
this.gl.glGenTextures (2, fuckTures);
this.gl.glBindTexture (GL.GL_TEXTURE_2D, fuckTures[0]);
this.gl.glTexImage2D (GL.GL_TEXTURE_2D, 0, GL.GL_RGB, image.getWidth (), image.getHeight (), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, dataToDraw1);
this.gl.glBindTexture (GL.GL_TEXTURE_2D, fuckTures[1]);
this.gl.glTexImage2D (GL.GL_TEXTURE_2D, 0, GL.GL_RGB, image.getWidth (), image.getHeight (), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, dataToDraw2);
As we said, we ensure that the dataToDraw1 and dataToDraw2 have the same values (but are, of course, two different objects).
Here’s a more specific tricky part for us. When we’ve skipped the second call to glBindTexture (hence simply executed
[i]
glBindTexture (..., id=1)
glTexImage2D (..., byte[] b1)
glTexImage2D (..., byte[] b2)
[/i]
we still, to our grate surprise, get the second texture to be drawn (as we call on it by the ID=2 in display) while the first texture (the only texture we actually glBind-ed in init) gets somehow forgotten! What did we do stupidly this time? ???