vertex2f.monkey2 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Namespace mojo.graphics
  2. Struct Vertex2f
  3. Const Format:=New Vertex2fFormat
  4. Const Pitch:=28
  5. Field position:Vec2f
  6. Field texCoord0:Vec2f
  7. Field texCoord1:Vec2f
  8. Field color:UInt
  9. Method New()
  10. End
  11. Method New( x:Float,y:Float,s0:Float=0,t0:Float=0,s1:Float=0,t1:Float=0,color:UInt=~0 )
  12. position.x=x
  13. position.y=y
  14. texCoord0.x=s0
  15. texCoord0.y=t0
  16. texCoord1.x=s1
  17. texCoord1.y=t1
  18. Self.color=color
  19. End
  20. Method New( position:Vec2f,texCoord0:Vec2f=Null,texCoord1:Vec2f=Null,color:UInt=~0 )
  21. Self.position=position
  22. Self.texCoord0=texCoord0
  23. Self.texCoord1=texCoord1
  24. Self.color=color
  25. End
  26. Operator To:String()
  27. Return "Vertex2f("+position+")"
  28. End
  29. End
  30. Class Vertex2fFormat Extends VertexFormat
  31. Property Pitch:Int() Override
  32. Return Vertex2f.Pitch
  33. End
  34. Method UpdateGLAttribs() Override
  35. glEnableVertexAttribArray( A_POSITION ) ; glVertexAttribPointer( A_POSITION,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 0 ) )
  36. glEnableVertexAttribArray( A_TEXCOORD0 ) ; glVertexAttribPointer( A_TEXCOORD0,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 8 ) )
  37. glEnableVertexAttribArray( A_TEXCOORD1 ) ; glVertexAttribPointer( A_TEXCOORD1,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 16 ) )
  38. glEnableVertexAttribArray( A_COLOR ) ; glVertexAttribPointer( A_COLOR,4,GL_UNSIGNED_BYTE,True,Pitch,Cast<Void Ptr>( 24 ) )
  39. 'Need these to shut up android emulator.
  40. glDisableVertexAttribArray( A_NORMAL )
  41. glDisableVertexAttribArray( A_TANGENT )
  42. glDisableVertexAttribArray( A_WEIGHTS )
  43. glDisableVertexAttribArray( A_BONES )
  44. End
  45. End