Android Question OpenGL and Vertex Buffer Objects

obscure

Member
Licensed User
Longtime User
Hi folks!

I have a little performance problem here.
At the moment I'm uploading the vertices and texture coordinates
data on each call to the draw event of GLSurfaceView.

B4X:
Sub glSv_Draw(gl As GL1)
  gl.glClear(Bit.OR(gl.GL_COLOR_BUFFER_BIT, gl.GL_DEPTH_BUFFER_BIT))
  ' left out the transformations
  gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
  gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
  gl.glFrontFace(gl.GL_CW)
  gl.glVertexPointerf(3,vertices2)
  gl.glTexCoordPointerf(2,0,texture2)   
  Dim b As Int
  Do While b<5036
    gl.glBindTexture(gl.GL_TEXTURE_2D, textures(texturesToUse.Get(Floor(b/24))))
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,b, 4)
    b=b+4
  Loop
 
  gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
  gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
End Sub

Of course this is good enough if you want to display a single rotationg cube
or something similar. My scene got quite complex though and the rendering is
noticeably jerky.
Now I heard about something magic called Vertex Buffer Objects, which essentially
uploads and keeps the geometry on the GPU.
Unfortunately I didn't find a way to convert the Java code to Basic4Android.

Does anybody have any experience with this?

Thanks!
 

obscure

Member
Licensed User
Longtime User
Hi Informatix.

Thanks for pointing me to that wrapper. I'll surely take a look at it soon!
I'm trying to gain more knowledge though, so simply replacing everything
with something different that I need to understand first is no option. ;)
You didn't use VBO with Basic4Android yet, did you?

Cheers!
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I consider that using directly OpenGL is just completely crazy. ;) There's an excellent engine for 2d (libGDX) and another for 3d (jpCT-AE), and their code is far superior to what I would be able to produce, so I have no reason to handle VBO or implement any advanced technique for my projects. And using the lgMesh and lgGL classes of libGDX is easier than using the OpenGL libraries (lgMesh uses automatically the VRAM if the hardware supports it) so I cannot advise you to continue on the way you chose. I think that you are going to lose a lot of time.
 
Upvote 0
Top