Using java Syntax Highlighting
- public void draw(GL10 gl, float alpha, float x, float y, float width) {
- gl.glColor4f(1.0f, 1.0f, 1.0f, alpha);
- float[] coordinates = new float[] {
- 0, width/_width,
- width/_width, width/_width,
- 0, 0,
- width/_width, 0};
- float height=width;
- float[] vertices = new float[] {
- x, y, .0f,
- x + width, y, .0f,
- x, y + height, .0f,
- x + width, y + height, .0f };
- FloatBuffer verticeBuff = FloatBuffer.wrap(vertices), coordBuff = FloatBuffer.wrap(coordinates);
- gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
- gl.glVertexPointer(3, GL10.GL_FLOAT, 0, verticeBuff);
- gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, coordBuff);
- gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
In this code I already have a texture created and everything works actually. My problem comes when I draw textures using this code in a loop, in a tile-like fashion. When I move these on the screen I see flickers of the background everywhere. Is this because of it not double-buffering? That is the only explanation I can see. Is there anyone that could link a good tutorial about duble buffering in OpenGL, or maybe just edit my code, that would be great!
Thanks!

