progs/util: minor updates to glutskel.c
This commit is contained in:
parent
a068e098e2
commit
7dd6fa12e1
|
@ -11,6 +11,7 @@
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
static int Win;
|
static int Win;
|
||||||
|
static int WinWidth = 400, WinHeight = 400;
|
||||||
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
||||||
static GLboolean Anim = GL_FALSE;
|
static GLboolean Anim = GL_FALSE;
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ Draw(void)
|
||||||
static void
|
static void
|
||||||
Reshape(int width, int height)
|
Reshape(int width, int height)
|
||||||
{
|
{
|
||||||
|
WinWidth = width;
|
||||||
|
WinHeight = height;
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -63,23 +66,23 @@ Key(unsigned char key, int x, int y)
|
||||||
(void) x;
|
(void) x;
|
||||||
(void) y;
|
(void) y;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'a':
|
case 'a':
|
||||||
Anim = !Anim;
|
Anim = !Anim;
|
||||||
if (Anim)
|
if (Anim)
|
||||||
glutIdleFunc(Idle);
|
glutIdleFunc(Idle);
|
||||||
else
|
else
|
||||||
glutIdleFunc(NULL);
|
glutIdleFunc(NULL);
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
Zrot -= step;
|
Zrot -= step;
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
Zrot += step;
|
Zrot += step;
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
glutDestroyWindow(Win);
|
glutDestroyWindow(Win);
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
@ -92,18 +95,18 @@ SpecialKey(int key, int x, int y)
|
||||||
(void) x;
|
(void) x;
|
||||||
(void) y;
|
(void) y;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case GLUT_KEY_UP:
|
case GLUT_KEY_UP:
|
||||||
Xrot -= step;
|
Xrot -= step;
|
||||||
break;
|
break;
|
||||||
case GLUT_KEY_DOWN:
|
case GLUT_KEY_DOWN:
|
||||||
Xrot += step;
|
Xrot += step;
|
||||||
break;
|
break;
|
||||||
case GLUT_KEY_LEFT:
|
case GLUT_KEY_LEFT:
|
||||||
Yrot -= step;
|
Yrot -= step;
|
||||||
break;
|
break;
|
||||||
case GLUT_KEY_RIGHT:
|
case GLUT_KEY_RIGHT:
|
||||||
Yrot += step;
|
Yrot += step;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
@ -123,8 +126,7 @@ int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
glutInitWindowPosition(0, 0);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitWindowSize(400, 400);
|
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|
Loading…
Reference in New Issue