3 #include <OpenGL/glu.h>
9 #include "glancillary.h"
13 /****************************
15 ***************************/
19 glClearColor(0.0, 0.0, 0.0, 0.0);
20 glShadeModel(GL_FLAT);
21 //glShadeModel(GL_SMOOTH);
24 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
26 // Init Model/view transformation
27 glMatrixMode(GL_MODELVIEW);
36 /****************************
37 * GL camera simulation helpers
38 ***************************/
40 void glaCameraRotatef(GLfloat *cmat, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
44 glRotatef(angle, x, y, z);
46 glGetFloatv(GL_MODELVIEW_MATRIX, cmat);
50 void glaCameraTranslatef(GLfloat *cmat, GLfloat x, GLfloat y, GLfloat z)
54 glTranslatef(x, y, z);
56 glGetFloatv(GL_MODELVIEW_MATRIX, cmat);
63 /****************************
64 * GL box drawing example
65 ***************************/
67 void glaDrawExample(void)
69 // Draw the corner dots
71 glColor3f(1.0, 1.0, 0.0);
73 glVertex3f(-1.0, -1.0, -1.0);
74 glVertex3f(1.0, -1.0, -1.0);
75 glVertex3f(1.0, 1.0, -1.0);
76 glVertex3f(-1.0, 1.0, -1.0);
77 glVertex3f(-1.0, -1.0, -1.0);
78 glVertex3f(-1.0, -1.0, 1.0);
79 glVertex3f(-1.0, 1.0, 1.0);
82 // Draw a line with fixed vertices
83 glColor3f(0.5, 1.0, 0.5);
84 glBegin(GL_LINE_STRIP);
85 glVertex3f(0.0, 0.0, 0.0);
86 glVertex3f(0.0, 0.5, 0.0);
87 glVertex3f(0.5, 0.5, 0.5);
90 // Draw the box boundaries
91 glColor3f(1.0, 0.0, 0.0);
92 glBegin(GL_LINE_STRIP);
93 glVertex3f(-1.0, -1.0, -1.0);
94 glVertex3f(1.0, -1.0, -1.0);
95 glVertex3f(1.0, 1.0, -1.0);
96 glVertex3f(-1.0, 1.0, -1.0);
97 glVertex3f(-1.0, -1.0, -1.0);
98 glVertex3f(-1.0, -1.0, 1.0);
99 glVertex3f(-1.0, 1.0, 1.0);
100 glVertex3f(-1.0, 1.0, -1.0);
113 /****************************
114 * GL selection (currently defunct)
115 ***************************/
117 // Selection helper, currently defunct.
118 void glaSelect(int x, int y)
121 GLuint namebuf[64] = {0};
125 // Account for inverse Y coordinate
126 glGetIntegerv(GL_VIEWPORT, view);
129 glSelectBuffer(64, namebuf);
130 glRenderMode(GL_SELECT);
136 // Restrict projection matrix to selection area
137 glGetFloatv(GL_PROJECTION_MATRIX, projmat);
138 glMatrixMode(GL_PROJECTION);
141 gluPickMatrix(x, y, 1.0, 1.0, view);
142 glMultMatrixf(projmat);
144 // Redraw points to fill selection buffer
145 glMatrixMode(GL_MODELVIEW);
150 glMatrixMode(GL_PROJECTION);
153 hits = glRenderMode(GL_RENDER);
155 for (i = 0; i < hits; i++)
156 // Do something with the namebuf element here
159 glMatrixMode(GL_MODELVIEW);