main.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. shader = require 'shader'
  2. local function drawLabel(str, x, y, z)
  3. lovr.graphics.setColor(255, 255, 255)
  4. lovr.graphics.print(str, x, y, z, .1)
  5. end
  6. function lovr.draw()
  7. lovr.graphics.setBackgroundColor(30, 30, 30)
  8. lovr.graphics.setShader(shader)
  9. local hx, hy, hz = lovr.headset.getPosition()
  10. local x, y, z
  11. -- Point
  12. x, y, z = -.6, 1.1, -1
  13. lovr.graphics.setPointSize(5)
  14. lovr.graphics.setColor(255, 255, 255)
  15. lovr.graphics.points(x, y, z)
  16. -- Line
  17. x, y, z = 0, 1.1, -1
  18. local points = {
  19. x - .1, y, z,
  20. x + .1, y, z
  21. }
  22. lovr.graphics.setColor(255, 255, 255)
  23. lovr.graphics.line(points)
  24. -- Triangle
  25. local x, y, z = .6, 1.1, -1
  26. local p1 = { x, y + .2, z }
  27. local p2 = { x - .2, y - .2, z }
  28. local p3 = { x + .2, y - .2, z }
  29. lovr.graphics.setColor(92, 107, 192)
  30. lovr.graphics.triangle('fill', p1[1], p1[2], p1[3], p2[1], p2[2], p2[3], p3[1], p3[2], p3[3])
  31. -- Plane
  32. local x, y, z = -.6, 1.7, -1.5
  33. lovr.graphics.setColor(239, 83, 80)
  34. lovr.graphics.plane('fill', x, y, z, .4, lovr.timer.getTime())
  35. -- Cube
  36. local x, y, z = 0, 1.7, -1.5
  37. lovr.graphics.setColor(126, 87, 194)
  38. lovr.graphics.cube('fill', x, y, z, .3, lovr.timer.getTime())
  39. -- Box
  40. local x, y, z = .6, 1.7, -1.5
  41. lovr.graphics.setColor(255, 167, 45)
  42. lovr.graphics.box('fill', x, y, z, .4, .2, .3, lovr.timer.getTime())
  43. -- Cylinder
  44. local x, y, z = -.6, 2.4, -2
  45. lovr.graphics.setColor(102, 187, 106)
  46. lovr.graphics.cylinder(x - .2, y, z, x + .2, y, z, .1, .1)
  47. -- Cone
  48. local x, y, z = 0, 2.4, -2
  49. lovr.graphics.setColor(255, 241, 118)
  50. lovr.graphics.cylinder(x, y + .2, z, x, y - .2, z, 0, .18)
  51. -- Sphere
  52. local x, y, z = .6, 2.4, -2
  53. lovr.graphics.setColor(77, 208, 255)
  54. lovr.graphics.sphere(x, y, z, .2)
  55. lovr.graphics.setShader()
  56. drawLabel('Point', -.6, 1.4, -1)
  57. drawLabel('Line', 0, 1.4, -1)
  58. drawLabel('Triangle', .6, 1.4, -1)
  59. drawLabel('Plane', -.6, 2.0, -1.5)
  60. drawLabel('Cube', 0, 2.0, -1.5)
  61. drawLabel('Box', .6, 2.0, -1.5)
  62. drawLabel('Cylinder', -.6, 2.7, -2)
  63. drawLabel('Cone', 0, 2.7, -2)
  64. drawLabel('Sphere', .6, 2.7, -2)
  65. end