116 glEnable(GL_TEXTURE_2D);
117 glShadeModel(GL_SMOOTH);
119 glClearColor(0.93f, 0.93f, 0.93f, 0.0f);
122 glEnable(GL_DEPTH_TEST);
123 glDepthFunc(GL_LEQUAL);
125 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
129 GLfloat LightAmbient[] = {0.25, 0.25, 0.25, 1.0};
130 GLfloat LightDiffuse[] = {0.4, 0.4, 0.4, 1.0};
131 GLfloat LightSpecular[] = {0.77, 0.77, 0.77, 1.0};
133 GLfloat LightPosition[] = {0.0, 0.0, 3.0, 1.0};
134 GLfloat spot_direction[] = {0.0, 0.0, -1.0};
136 glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
137 glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
138 glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
139 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
140 glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 50.0);
141 glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);
142 glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 10.0);
144 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
146 glEnable(GL_LIGHTING);
147 glEnable(GL_COLOR_MATERIAL);
149 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
173 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
179 glTranslated(0.0, 0.0, -10.0);
182 glRotatef(
xRot / 16.0, 1.0, 0.0, 0.0);
183 glRotatef(
yRot / 16.0, 0.0, 1.0, 0.0);
184 glRotatef(
zRot / 16.0, 0.0, 0.0, 1.0);
210 glRotated(90, 1.0, 0.0, 0.0);
223 glRotated(90, 0.0, 1.0, 0.0);
309 int side = qMin(width, height);
310 glViewport((width - side) / 2, (height - side) / 2, side, side);
312 glMatrixMode(GL_PROJECTION);
314 glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
315 glMatrixMode(GL_MODELVIEW);
327 if (event->buttons() & Qt::LeftButton)
347 else if (event->buttons() & Qt::RightButton)
369 *angle += 360.0 * 16.0;
370 while (*angle > 360.0 * 16.0)
371 *angle -= 360.0 * 16.0;
424 return QSize(50, 50);
430 return QSize(800, 800);