Hi,
I've been playing more (now using v1.3 of your library). The triangles aren't disappearing, they're just being drawn over by triangles behind. I didn't want to make the mistake of thinking I knew what I was doing, especially as I wasn't setting specific surface normals, so I've taken an example from the Hello Android book by Ed Burnette, and translated it into B4A. It's a spinning cube and I know it should work as I've tried it in Eclipse and it worked perfectly. However, on B4A it doesn't seem to be correctly z-buffering.
I've put the code below in case it helps, and maybe it's useful for anyone who needs a GL example.
Thanks,
Andrew.
<textarea cols="80" rows="30">
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Timer1 As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim glsv As GLSurfaceView
Dim eyeangle As Float
Dim coords(0) As Float
eyeangle=0
End Sub
Sub Timer1_Tick
eyeangle=eyeangle+0.1
If eyeangle>(2*3.14159) Then eyeangle=eyeangle-(2*3.14159)
glsv.RequestRender
End Sub
Sub Activity_Create(FirstTime As Boolean)
glsv.Initialize(glsv.RENDERMODE_WHEN_DIRTY, "glsv")
Activity.AddView(glsv,0,0,Activity.Width,Activity.Height)
End Sub
Sub Activity_Resume
glsv.Resume ' Must call GLSurfaceView.Resume to restart the rendering thread
Timer1.Initialize("Timer1", 100)
Timer1.Enabled = True
Dim half As Float
half=0.5
coords = Array As Float(-half,-half,half,half,-half,half,-half,half,half,half,half,half,-half,-half,-half,-half,half,-half,half,-half,-half,half,half,-half,-half,-half,half,-half,half,half,-half,-half,-half,-half,half,-half,half,-half,-half,half,half,-half,half,-half,half,half,half,half,-half,half,half,half,half,half,-half,half,-half,half,half,-half,-half,-half,half,-half,-half,-half,half,-half,half,half,-half,-half)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
glsv.Pause ' Must call GLSurfaceView.Pause to halt the rendering thread
Timer1.Enabled = False
End Sub
Sub glsv_Draw(gl As GL1)
gl.glClear(Bit.Or(gl.GL_COLOR_BUFFER_BIT, gl.GL_DEPTH_BUFFER_BIT))
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity
gl.gluLookAt(0,0,5, 0,0,0, 0,1,0)
gl.glRotatef((eyeangle/(2*3.14159))*360,0,1,0)
gl.glRotatef((eyeangle/(2*3.14159))*360,1,0,0)
gl.glVertexPointerf(3, coords)
gl.glColor4f(1,1,1,1)
gl.glNormal3f(0,0,1)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,0,4)
gl.glNormal3f(0,0,-1)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,4,4)
gl.glNormal3f(-1,0,0)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,8,4)
gl.glNormal3f(1,0,0)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,12,4)
gl.glNormal3f(0,1,0)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,16,4)
gl.glNormal3f(0,-1,0)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP,20,4)
End Sub
Sub glsv_SurfaceChanged(gl As GL1, width As Int, height As Int)
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity
Dim ratio As Float
ratio = width/height
gl.gluPerspective(45,ratio,1,100)
End Sub
Sub glsv_SurfaceCreated(gl As GL1)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glDepthFunc(gl.GL_LESS)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
Dim lightAmbient(0),lightDiffuse(0),lightPos(0) As Float
lightAmbient=Array As Float(0.2,0.2,0.2,1)
lightDiffuse=Array As Float(1,1,1,1)
lightPos=Array As Float(1,1,1,1)
gl.glEnable(gl.GL_LIGHTING)
gl.glEnable(gl.GL_LIGHT0)
gl.glLightfv(gl.GL_LIGHT0,gl.GL_AMBIENT,lightAmbient,0)
gl.glLightfv(gl.GL_LIGHT0,gl.GL_DIFFUSE,lightDiffuse,0)
gl.glLightfv(gl.GL_LIGHT0,gl.GL_POSITION,lightPos,0)
Dim matAmbient(0),matDiffuse(0) As Float
matAmbient=Array As Float(1,1,1,1)
matDiffuse=Array As Float(1,1,1,1)
gl.glMaterialfv(gl.GL_FRONT_AND_BACK,gl.GL_AMBIENT,matAmbient,0)
gl.glMaterialfv(gl.GL_FRONT_AND_BACK,gl.GL_DIFFUSE,matDiffuse,0)
End Sub
</textarea>