4 #include "glancillary.h"
8 /****************************
10 ***************************/
14 glClearColor(0.0, 0.0, 0.0, 0.0);
15 glShadeModel(GL_FLAT);
16 //glShadeModel(GL_SMOOTH);
19 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
21 // Init Model/view transformation
22 glMatrixMode(GL_MODELVIEW);
31 /****************************
32 * GL camera simulation helpers
33 ***************************/
35 void glaCameraRotatef(GLfloat *cmat, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
39 glRotatef(angle, x, y, z);
41 glGetFloatv(GL_MODELVIEW_MATRIX, cmat);
45 void glaCameraTranslatef(GLfloat *cmat, GLfloat x, GLfloat y, GLfloat z)
49 glTranslatef(x, y, z);
51 glGetFloatv(GL_MODELVIEW_MATRIX, cmat);
58 /****************************
59 * GL box drawing example
60 ***************************/
62 void glaDrawExample(void)
64 // Draw the corner dots
66 glColor3f(1.0, 1.0, 0.0);
68 glVertex3f(-1.0, -1.0, -1.0);
69 glVertex3f(1.0, -1.0, -1.0);
70 glVertex3f(1.0, 1.0, -1.0);
71 glVertex3f(-1.0, 1.0, -1.0);
72 glVertex3f(-1.0, -1.0, -1.0);
73 glVertex3f(-1.0, -1.0, 1.0);
74 glVertex3f(-1.0, 1.0, 1.0);
77 // Draw a line with fixed vertices
78 glColor3f(0.5, 1.0, 0.5);
79 glBegin(GL_LINE_STRIP);
80 glVertex3f(0.0, 0.0, 0.0);
81 glVertex3f(0.0, 0.5, 0.0);
82 glVertex3f(0.5, 0.5, 0.5);
85 // Draw the box boundaries
86 glColor3f(1.0, 0.0, 0.0);
87 glBegin(GL_LINE_STRIP);
88 glVertex3f(-1.0, -1.0, -1.0);
89 glVertex3f(1.0, -1.0, -1.0);
90 glVertex3f(1.0, 1.0, -1.0);
91 glVertex3f(-1.0, 1.0, -1.0);
92 glVertex3f(-1.0, -1.0, -1.0);
93 glVertex3f(-1.0, -1.0, 1.0);
94 glVertex3f(-1.0, 1.0, 1.0);
95 glVertex3f(-1.0, 1.0, -1.0);
108 /****************************
109 * GL selection (currently defunct)
110 ***************************/
112 // Selection helper, currently defunct.
113 void glaSelect(int x, int y)
116 GLuint namebuf[64] = {0};
120 // Account for inverse Y coordinate
121 glGetIntegerv(GL_VIEWPORT, view);
124 glSelectBuffer(64, namebuf);
125 glRenderMode(GL_SELECT);
131 // Restrict projection matrix to selection area
132 glGetFloatv(GL_PROJECTION_MATRIX, projmat);
133 glMatrixMode(GL_PROJECTION);
136 gluPickMatrix(x, y, 1.0, 1.0, view);
137 glMultMatrixf(projmat);
139 // Redraw points to fill selection buffer
140 glMatrixMode(GL_MODELVIEW);
145 glMatrixMode(GL_PROJECTION);
148 hits = glRenderMode(GL_RENDER);
150 for (i = 0; i < hits; i++)
151 // Do something with the namebuf element here
154 glMatrixMode(GL_MODELVIEW);