source: research/2008-rubik/colorcube/tb.h @ 3898

Last change on this file since 3898 was 2677, checked in by Sam Hocevar, 15 years ago
  • Test stuff for the Rubik's cube colour reduction.
File size: 1.8 KB
Line 
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
31    void
32    reshape(int width, int height)
33    {
34      tbReshape(width, height);
35      . . .
36    }
37
38    void
39    display(void)
40    {
41      glPushMatrix();
42
43      tbMatrix();
44      . . . draw the scene . . .
45
46      glPopMatrix();
47    }
48
49    void
50    mouse(int button, int state, int x, int y)
51    {
52      tbMouse(button, state, x, y);
53      . . .
54    }
55
56    void
57    motion(int x, int y)
58    {
59      tbMotion(x, y);
60      . . .
61    }
62
63    int
64    main(int argc, char** argv)
65    {
66      . . .
67      init();
68      glutReshapeFunc(reshape);
69      glutDisplayFunc(display);
70      glutMouseFunc(mouse);
71      glutMotionFunc(motion);
72      . . .
73    }
74 *
75 * */
76
77
78/* functions */
79#ifdef __cplusplus
80extern "C" {
81#endif
82
83void
84tbInit(GLuint button);
85
86void
87tbMatrix(void);
88
89void
90tbReshape(int width, int height);
91
92void
93tbMouse(int button, int state, int x, int y);
94
95void
96tbMotion(int x, int y);
97
98void
99tbAnimate(GLboolean animate);
100
101#ifdef __cplusplus
102}
103#endif
Note: See TracBrowser for help on using the repository browser.