Double Buffer

Problems with Canvas, OpenGL, etc...

Double Buffer

Postby randomcracker » Wed May 11, 2011 6:57 pm

Hi, I've been searching for hours and I've found basically nothing on the subject. My problem is regarding double buffering in OpenGLES. Here is my code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void draw(GL10 gl, float alpha, float x, float y, float width) {
  2.        
  3.                
  4.                 gl.glColor4f(1.0f, 1.0f, 1.0f, alpha);
  5.                
  6.                 float[]  coordinates = new float[] {  
  7.                         0, width/_width,
  8.                         width/_width, width/_width,
  9.                         0, 0,
  10.                         width/_width, 0};
  11.                 float height=width;
  12.                 float[] vertices = new float[] {       
  13.                         x,                      y,                      .0f,
  14.                         x + width,              y,                      .0f,
  15.                         x,                      y + height,             .0f,
  16.                         x + width,              y + height,             .0f };
  17.                
  18.                 FloatBuffer verticeBuff = FloatBuffer.wrap(vertices), coordBuff = FloatBuffer.wrap(coordinates);
  19.                
  20.                 gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
  21.                 gl.glVertexPointer(3, GL10.GL_FLOAT, 0, verticeBuff);
  22.                 gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, coordBuff);
  23.                 gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
  24.                
  25.                
  26.         }
Parsed in 0.035 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!
Freedom in Death <3
randomcracker
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sat Feb 20, 2010 11:03 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests