X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=progs%2Fdemos%2Ftexcyl.c;h=c04d5004e37572f6ee2355ef0b220db2f442765e;hb=a1a6fa2fa18c4982aa8151042df7d04551e47981;hp=30aded2b3edd93f32b2d63b35f05095d111cf8ff;hpb=d1ff1f6798b003a820f5de9fad835ff352f31afe;p=mesa.git diff --git a/progs/demos/texcyl.c b/progs/demos/texcyl.c index 30aded2b3ed..c04d5004e37 100644 --- a/progs/demos/texcyl.c +++ b/progs/demos/texcyl.c @@ -1,4 +1,3 @@ -/* $Id: texcyl.c,v 1.4 2000/12/24 22:53:54 pesco Exp $ */ /* * Textured cylinder demo: lighting, texturing, reflection mapping. @@ -10,64 +9,13 @@ * Brian Paul May 1997 This program is in the public domain. */ -/* - * $Log: texcyl.c,v $ - * Revision 1.4 2000/12/24 22:53:54 pesco - * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util. - * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus: - * Essentially the same. - * Program files updated to include "readtex.c", not "../util/readtex.c". - * * demos/reflect.c: Likewise for "showbuffer.c". - * - * - * * Makefile.am (EXTRA_DIST): Added top-level regular files. - * - * * include/GL/Makefile.am (INC_X11): Added glxext.h. - * - * - * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include - * Mesa GGI headers in dist even if HAVE_GGI is not given. - * - * * configure.in: Look for GLUT and demo source dirs in $srcdir. - * - * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch]. - * More source list updates in various Makefile.am's. - * - * * Makefile.am (dist-hook): Remove CVS directory from distribution. - * (DIST_SUBDIRS): List all possible subdirs here. - * (SUBDIRS): Only list subdirs selected for build again. - * The above two applied to all subdir Makefile.am's also. - * - * Revision 1.3 2000/09/29 23:09:39 brianp - * added fps output - * - * Revision 1.2 1999/10/21 16:39:06 brianp - * added -info command line option - * - * Revision 1.1.1.1 1999/08/19 00:55:40 jtg - * Imported sources - * - * Revision 3.3 1999/03/28 18:24:37 brianp - * minor clean-up - * - * Revision 3.2 1998/11/05 04:34:04 brianp - * moved image files to ../images/ directory - * - * Revision 3.1 1998/06/23 03:16:51 brianp - * added Point/Linear sampling menu items - * - * Revision 3.0 1998/02/14 18:42:29 brianp - * initial rev - * - */ - - #include #include #include +#include #include -#include "readtex.c" /* I know, this is a hack. */ +#include "readtex.h" #define TEXTURE_FILE "../images/reflect.rgb" @@ -83,7 +31,7 @@ static GLuint CylinderObj = 0; static GLboolean Animate = GL_TRUE; static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; -static GLfloat DXrot = 1.0, DYrot = 2.5; +static GLfloat DXrot = 50.0, DYrot = 125.0; /* performance info */ static GLint T0 = 0; @@ -92,9 +40,16 @@ static GLint Frames = 0; static void Idle( void ) { + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + if (Animate) { - Xrot += DXrot; - Yrot += DYrot; + Xrot += DXrot * dt; + Yrot += DYrot * dt; glutPostRedisplay(); } } @@ -168,6 +123,10 @@ static void ModeMenu(int entry) { if (entry==ANIMATE) { Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); } else if (entry==POINT_FILTER) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -192,6 +151,13 @@ static void Key( unsigned char key, int x, int y ) (void) x; (void) y; switch (key) { + case ' ': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; case 27: exit(0); break; @@ -293,6 +259,7 @@ int main( int argc, char *argv[] ) { glutInit( &argc, argv ); glutInitWindowSize( 400, 400 ); + glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );