Hello! The following code is intended to render a smoothly shaded triangle, but it only clears the background to a dark blue!
Import mojo
Import opengl.gles11
Class MyApp Extends App
Field inited
Field vertices : Int[] = [-1,1,0,1,-1,0,1,1,0]
Field colors : Int[] = [255,0,0,255,0,255,0,255,0,0,255,255]
Field verticesdata := New DataBuffer(36)
Field colorsdata := New DataBuffer(48)
Method OnCreate()
SetUpdateRate 60
End
Method initGLES()
If inited Return
inited = True
verticesdata.PokeInts 0,vertices,0,9
colorsdata.PokeInts 0,colors,0,12
glMatrixMode GL_PROJECTION
glFrustumf -1,1,-1,1,3,1000
glMatrixMode GL_MODELVIEW
glDisable GL_DEPTH_TEST
glShadeModel GL_SMOOTH
glClearColor 0,0,0.1,1
glVertexPointer 3,GL_BYTE,0,verticesdata
glColorPointer 4,GL_UNSIGNED_BYTE,0,colorsdata
glEnableClientState GL_VERTEX_ARRAY
glEnableClientState GL_COLOR_ARRAY
glViewport 0,0,DeviceWidth,DeviceHeight
End
Method OnRender()
initGLES
glClear GL_COLOR_BUFFER_BIT
glLoadIdentity
glTranslatef 0,0,-5
glDrawArrays GL_TRIANGLES,0,3
End
End
Function Main()
New MyApp
End
|