drawprimitives.bmx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. SuperStrict
  2. Framework mky.mojo2
  3. ?Not opengles
  4. Import brl.GLGraphics
  5. ?opengles
  6. Import sdl.sdlgraphics
  7. ?
  8. Import brl.pngloader
  9. Import brl.random
  10. Graphics 800, 600, 0
  11. Local canvas:TCanvas = New TCanvas.CreateCanvas()
  12. Local vertices:Float[] = New Float[4*2*100]
  13. Local indices:Int[]
  14. Local sz:Float=20.0
  15. Local p:Int=0
  16. For Local i:Int=0 Until 100
  17. Local x:Float=Rnd(GraphicsWidth())-sz/2-GraphicsWidth()/2
  18. Local y:Float=Rnd(GraphicsHeight())-sz/2-GraphicsHeight()/2
  19. vertices[p+0]=x
  20. vertices[p+1]=y
  21. vertices[p+2]=x+sz
  22. vertices[p+3]=y
  23. vertices[p+4]=x+sz
  24. vertices[p+5]=y+sz
  25. vertices[p+6]=x
  26. vertices[p+7]=y+sz
  27. p:+8
  28. Next
  29. 'quick test of indices...
  30. indices = New Int[400]
  31. For Local i:Int=0 Until 400
  32. indices[i]=i
  33. Next
  34. While Not KeyDown(key_escape)
  35. canvas.Clear 0,0,1
  36. canvas.SetColor Sin( MilliSecs()*.01 )*.5+.5,Cos( MilliSecs()*.03 )*.5+.5,Sin( MilliSecs()*.05 )*.5+.5
  37. canvas.PushMatrix
  38. canvas.Translate MouseX(),MouseY()
  39. canvas.DrawIndexedPrimitives 4,100,vertices,indices 'should draw same thing...
  40. canvas.PopMatrix
  41. canvas.Flush
  42. Flip
  43. Wend