Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

104 строки
1.8 KiB

  1. /*
  2. * Simple trackball-like motion adapted (ripped off) from projtex.c
  3. * (written by David Yu and David Blythe). See the SIGGRAPH '96
  4. * Advanced OpenGL course notes.
  5. *
  6. *
  7. * Usage:
  8. *
  9. * o call tbInit() in before any other tb call
  10. * o call tbReshape() from the reshape callback
  11. * o call tbMatrix() to get the trackball matrix rotation
  12. * o call tbStartMotion() to begin trackball movememt
  13. * o call tbStopMotion() to stop trackball movememt
  14. * o call tbMotion() from the motion callback
  15. * o call tbAnimate(GL_TRUE) if you want the trackball to continue
  16. * spinning after the mouse button has been released
  17. * o call tbAnimate(GL_FALSE) if you want the trackball to stop
  18. * spinning after the mouse button has been released
  19. *
  20. * Typical setup:
  21. *
  22. *
  23. void
  24. init(void)
  25. {
  26. tbInit(GLUT_MIDDLE_BUTTON);
  27. tbAnimate(GL_TRUE);
  28. . . .
  29. }
  30. void
  31. reshape(int width, int height)
  32. {
  33. tbReshape(width, height);
  34. . . .
  35. }
  36. void
  37. display(void)
  38. {
  39. glPushMatrix();
  40. tbMatrix();
  41. . . . draw the scene . . .
  42. glPopMatrix();
  43. }
  44. void
  45. mouse(int button, int state, int x, int y)
  46. {
  47. tbMouse(button, state, x, y);
  48. . . .
  49. }
  50. void
  51. motion(int x, int y)
  52. {
  53. tbMotion(x, y);
  54. . . .
  55. }
  56. int
  57. main(int argc, char** argv)
  58. {
  59. . . .
  60. init();
  61. glutReshapeFunc(reshape);
  62. glutDisplayFunc(display);
  63. glutMouseFunc(mouse);
  64. glutMotionFunc(motion);
  65. . . .
  66. }
  67. *
  68. * */
  69. /* functions */
  70. #ifdef __cplusplus
  71. extern "C" {
  72. #endif
  73. void
  74. tbInit(GLuint button);
  75. void
  76. tbMatrix(void);
  77. void
  78. tbReshape(int width, int height);
  79. void
  80. tbMouse(int button, int state, int x, int y);
  81. void
  82. tbMotion(int x, int y);
  83. void
  84. tbAnimate(GLboolean animate);
  85. #ifdef __cplusplus
  86. }
  87. #endif