Rendering multiple squares fast ?

Problems with Canvas, OpenGL, etc...

Rendering multiple squares fast ?

Postby sciepy » Sun Oct 28, 2012 12:51 pm

Hey all,

so I'm doing my first steps with openGL development on android and I'm kinda stuck at some serious performance issues...

What I'm trying to do is render a whole grid of single colored squares on to the screen and I'm getting framerates of ~4FPS. The squares are 9px in size right now with one pixel border in between, so I get a few thousand of them.
I have a class "Square" and the Renderer iterates over all Squares every frame and calls the draw() method of each (just the iteration is fast enough, with no openGL code the whole thing runs smootlhy at 60FPS). Right now the draw() method looks like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        // Prepare the square coordinate data
  2.        GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX,
  3.                                      GLES20.GL_FLOAT, false,
  4.                                      vertexStride, vertexBuffer);
  6.         // Set color for drawing the square
  7.         GLES20.glUniform4fv(mColorHandle, 1, color, 0);
  9.         // Draw the square
  10.         GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length,
  11.                               GLES20.GL_UNSIGNED_SHORT, drawListBuffer);
Parsed in 0.016 seconds, using GeSHi

So its actually only 3 openGL calls. Everything else (loading shaders, filling buffers, getting appropriate handles, etc.) is done in the Constructor and things like the Program and the handles are also static attrbutes.
What am I missing here, why is it rendering so slow?

Any help greatly appreciated! :)
Once Poster
Once Poster
Posts: 1
Joined: Sun Oct 28, 2012 12:23 pm


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

Who is online

Users browsing this forum: No registered users and 2 guests