progs/tests: add x/y rotation to cylwrap.c
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
static int Win;
|
static int Win;
|
||||||
static int WinWidth = 600, WinHeight = 400;
|
static int WinWidth = 600, WinHeight = 400;
|
||||||
|
static GLfloat Xrot = 0, Yrot = 0;
|
||||||
static GLboolean CylWrap = GL_TRUE;
|
static GLboolean CylWrap = GL_TRUE;
|
||||||
|
|
||||||
|
|
||||||
@@ -82,6 +83,10 @@ Draw(void)
|
|||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glRotatef(Xrot, 1, 0, 0);
|
||||||
|
glRotatef(Yrot, 0, 1, 0);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, +1.2, 0);
|
glTranslatef(0, +1.2, 0);
|
||||||
DrawSample(GL_FALSE);
|
DrawSample(GL_FALSE);
|
||||||
@@ -98,6 +103,8 @@ Draw(void)
|
|||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0);
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,17 +117,16 @@ Reshape(int width, int height)
|
|||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
glFrustum(-1.0, 1.0, -1.0, 1.0, 3.0, 25.0);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(0.0, 0.0, -15.0);
|
glTranslatef(0.0, 0.0, -10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Key(unsigned char key, int x, int y)
|
Key(unsigned char key, int x, int y)
|
||||||
{
|
{
|
||||||
const GLfloat step = 3.0;
|
|
||||||
(void) x;
|
(void) x;
|
||||||
(void) y;
|
(void) y;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -141,6 +147,30 @@ Key(unsigned char key, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
SpecialKey(int key, int x, int y)
|
||||||
|
{
|
||||||
|
const GLfloat step = 3.0;
|
||||||
|
(void) x;
|
||||||
|
(void) y;
|
||||||
|
switch (key) {
|
||||||
|
case GLUT_KEY_UP:
|
||||||
|
Xrot -= step;
|
||||||
|
break;
|
||||||
|
case GLUT_KEY_DOWN:
|
||||||
|
Xrot += step;
|
||||||
|
break;
|
||||||
|
case GLUT_KEY_LEFT:
|
||||||
|
Yrot -= step;
|
||||||
|
break;
|
||||||
|
case GLUT_KEY_RIGHT:
|
||||||
|
Yrot += step;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MakeSineWaveTexture(void)
|
MakeSineWaveTexture(void)
|
||||||
{
|
{
|
||||||
@@ -196,6 +226,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
glutSpecialFunc(SpecialKey);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Draw);
|
glutDisplayFunc(Draw);
|
||||||
Init();
|
Init();
|
||||||
|
Reference in New Issue
Block a user