Android openGL attempt to increase FPS by using the same vertices for multiple meshes -


i developing game similar objects rendered on screen. problem every time new object added, more vertices needs handled, fps decrease.

since beginner opengl, have general ideas improving performance, don't know opengl allows me do.

  1. since of objects identical(same number of vertices, same colors, same uvs , same normals), position , rotation of objects different, possible send vertices similar objects once, on each frame render , , call drawelements objects , modify objects positions?

  2. is possible go further, , upload similar vertices, once when scene 1st created, , on each frame render call drawelements each object?

currently, sending vertices each object this:

....... gl.glnormalpointer(gl10.gl_float, 0, normals); gl.glcolorpointer(4, gl10.gl_unsigned_byte, 0, colors); gl.glvertexpointer(3, gl10.gl_float, 0, vertices); gl.glpushmatrix(); gl.gltranslatef(position); gl.glrotatef(rotation); gl.glscalef(scale);     gl.gldrawelements(rendertype,nr,gl10.gl_unsigned_short, faces); gl.glpopmatrix(); ........ 

i thinking should someting this:

....... gl.glnormalpointer(gl10.gl_float, 0, normals); gl.glcolorpointer(4, gl10.gl_unsigned_byte, 0, colors); gl.glvertexpointer(3, gl10.gl_float, 0, vertices); for(eachobject) { gl.glpushmatrix(); gl.gltranslatef(position); gl.glrotatef(rotation); gl.glscalef(scale); gl.gldrawelements(rendertype,nr,gl10.gl_unsigned_short, faces); gl.glpopmatrix(); ........ } 

  1. yes
  2. yes (even better)

your second code example looks should doing.

there's no reason you'd need upload vertices more once, doing on initialization should sufficient. after set pointers time want render. can call gldrawelements many times want different translations/rotations.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -