teapot_test.bmx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ' Test program for the UTAH Teapot.
  2. ' BlitzMax versio by Peter Scheutz 2004.12.18
  3. Strict
  4. Import "teapot.bmx"
  5. Type ogld_color4f
  6. Field r#,g#,b#,a#
  7. End Type
  8. Type ogld_pos4f
  9. Field x#,y#,z#,w#
  10. End Type
  11. Local teapot
  12. Local z#=-4
  13. Local xrot#=0
  14. Local yrot#=0
  15. GLGraphics 800,600
  16. glClearColor(0.2, 0.0, 0.4, 0.0)
  17. glEnable(GL_DEPTH_TEST)
  18. glEnable GL_AUTO_NORMAL
  19. glEnable GL_NORMALIZE
  20. teapot= ogld_TeaPot(16)
  21. ResizeViewport 800,600
  22. initlights
  23. gldisable(GL_CULL_FACE)
  24. While Not KeyHit(Key_Escape)
  25. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  26. glMatrixMode GL_MODELVIEW
  27. glLoadIdentity
  28. glTranslatef 0,0,-8
  29. glRotatef yrot,1,0,0
  30. glRotatef xrot,0,1,0
  31. glTranslatef 0.0,-1.0,0.0
  32. glCallList teapot
  33. Flip
  34. xrot = xrot +1
  35. yrot = yrot +.1
  36. Wend
  37. Function ResizeViewport(w,h)
  38. Local aspect#
  39. If w = 0 Then h = 1
  40. glViewport 0,0,w,h
  41. glMatrixMode GL_PROJECTION
  42. glLoadIdentity
  43. aspect#=Float(w)/Float(h)
  44. gluPerspective 45.0,aspect,1.0,100.0
  45. glMatrixMode GL_MODELVIEW
  46. End Function
  47. Function initlights()
  48. Local ambient:ogld_color4f = New ogld_color4f
  49. Local position:ogld_pos4f = New ogld_pos4f
  50. Local mat_ambient:ogld_color4f = New ogld_color4f
  51. Local mat_diffuse:ogld_color4f = New ogld_color4f
  52. Local mat_specular:ogld_color4f = New ogld_color4f
  53. Local mat_shininess:ogld_color4f = New ogld_color4f
  54. ambient.r=0.2
  55. ambient.g=0.2
  56. ambient.b=0.2
  57. ambient.a=1
  58. position.x=-2
  59. position.y=5
  60. position.z=0
  61. position.w=1
  62. mat_ambient.r=1
  63. mat_ambient.g=0
  64. mat_ambient.b=0
  65. mat_diffuse.a=1
  66. mat_diffuse.r=1
  67. mat_diffuse.g=0
  68. mat_diffuse.b=0
  69. mat_diffuse.a=1
  70. mat_specular.r=1
  71. mat_specular.g=1
  72. mat_specular.b=1
  73. mat_specular.a=1
  74. mat_shininess.r=50.0
  75. mat_shininess.g=50.0
  76. mat_shininess.b=50.0
  77. mat_shininess.a=0
  78. glEnable(GL_LIGHTING);
  79. glEnable(GL_LIGHT0);
  80. glLightfv GL_LIGHT0, GL_AMBIENT, Varptr(ambient.r)
  81. glLightfv GL_LIGHT0, GL_POSITION, Varptr(position.x)
  82. glMaterialfv GL_FRONT, GL_DIFFUSE, Varptr(mat_diffuse.r)
  83. glMaterialfv GL_FRONT, GL_AMBIENT, Varptr(mat_ambient.r)
  84. glMaterialfv GL_FRONT, GL_SPECULAR, Varptr(mat_specular.r)
  85. glMaterialfv GL_FRONT, GL_SHININESS, Varptr(mat_shininess.r)
  86. End Function