From 2b2e62154df4206f8340f74cb18aba4fabe4805c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Jan 2001 23:43:53 +0000 Subject: [PATCH] space-bar = pause animation --- progs/demos/reflect.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/progs/demos/reflect.c b/progs/demos/reflect.c index 0d72c9d8d67..22856b542a3 100644 --- a/progs/demos/reflect.c +++ b/progs/demos/reflect.c @@ -1,4 +1,4 @@ -/* $Id: reflect.c,v 1.5 2000/12/24 22:53:54 pesco Exp $ */ +/* $Id: reflect.c,v 1.6 2001/01/23 23:43:53 brianp Exp $ */ /* * Demo of a reflective, texture-mapped surface with OpenGL. @@ -32,8 +32,8 @@ #include #include #include "GL/glut.h" -#include "showbuffer.c" -#include "readtex.c" +#include "../util/showbuffer.c" +#include "../util/readtex.c" #define DEG2RAD (3.14159/180.0) @@ -53,6 +53,7 @@ static GLfloat spin; static GLint Width = 400, Height = 300; static GLenum ShowBuffer = GL_NONE; +static GLboolean Anim = GL_TRUE; /* performance info */ static GLint T0 = 0; @@ -313,6 +314,14 @@ static void draw_scene( void ) } +static void idle( void ) +{ + spin += 2.0; + yrot += 3.0; + glutPostRedisplay(); +} + + static void Key( unsigned char key, int x, int y ) { (void) x; @@ -323,6 +332,13 @@ static void Key( unsigned char key, int x, int y ) else if (key == 's') { ShowBuffer = GL_STENCIL; } + else if (key == ' ') { + Anim = !Anim; + if (Anim) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); + } else if (key==27) { exit(0); } @@ -359,16 +375,6 @@ static void SpecialKey( int key, int x, int y ) } - -static void idle( void ) -{ - spin += 2.0; - yrot += 3.0; - glutPostRedisplay(); -} - - - int main( int argc, char *argv[] ) { glutInit(&argc, argv); -- 2.30.2