summaryrefslogtreecommitdiffstats
path: root/progs/demos/renormal.c
diff options
context:
space:
mode:
authorjtg <jtg>1999-08-19 00:55:39 +0000
committerjtg <jtg>1999-08-19 00:55:39 +0000
commitafb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1c (patch)
tree59d65b4da12fb5379224cf5f6b808fde91523c7f /progs/demos/renormal.c
parentf2544d4920ce168bec9cd94d774b7ea5103a3d74 (diff)
Initial revision
Diffstat (limited to 'progs/demos/renormal.c')
-rw-r--r--progs/demos/renormal.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/progs/demos/renormal.c b/progs/demos/renormal.c
new file mode 100644
index 00000000000..bd099dcdc80
--- /dev/null
+++ b/progs/demos/renormal.c
@@ -0,0 +1,123 @@
+/* $Id: renormal.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
+
+/*
+ * Test GL_EXT_rescale_normal extension
+ * Brian Paul January 1998 This program is in the public domain.
+ */
+
+/*
+ * $Id: renormal.c,v 1.1 1999/08/19 00:55:40 jtg Exp $
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLfloat Phi = 0.0;
+
+
+static void Idle(void)
+{
+ Phi += 0.1;
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ GLfloat scale = 0.6 + 0.5 * sin(Phi);
+ glClear( GL_COLOR_BUFFER_BIT );
+ glPushMatrix();
+ glScalef(scale, scale, scale);
+ glutSolidSphere(2.0, 20, 20);
+ glPopMatrix();
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+
+static void Init( void )
+{
+ static GLfloat mat[4] = { 0.8, 0.8, 0.0, 1.0 };
+ static GLfloat pos[4] = { -1.0, 1.0, 1.0, 0.0 };
+
+ /* setup lighting, etc */
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat);
+ glLightfv(GL_LIGHT0, GL_POSITION, pos);
+
+ glEnable(GL_CULL_FACE);
+
+ glDisable(GL_RESCALE_NORMAL_EXT);
+ glDisable(GL_NORMALIZE);
+}
+
+
+#define UNSCALED 1
+#define NORMALIZE 2
+#define RESCALE 3
+#define QUIT 4
+
+
+static void ModeMenu(int entry)
+{
+ if (entry==UNSCALED) {
+ glDisable(GL_RESCALE_NORMAL_EXT);
+ glDisable(GL_NORMALIZE);
+ }
+ else if (entry==NORMALIZE) {
+ glEnable(GL_NORMALIZE);
+ glDisable(GL_RESCALE_NORMAL_EXT);
+ }
+ else if (entry==RESCALE) {
+ glDisable(GL_NORMALIZE);
+ glEnable(GL_RESCALE_NORMAL_EXT);
+ }
+ else if (entry==QUIT) {
+ exit(0);
+ }
+ glutPostRedisplay();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( 400, 400 );
+
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+
+ glutCreateWindow(argv[0]);
+
+ Init();
+
+ glutIdleFunc( Idle );
+ glutReshapeFunc( Reshape );
+ glutDisplayFunc( Display );
+
+ glutCreateMenu(ModeMenu);
+ glutAddMenuEntry("Unscaled", UNSCALED);
+ glutAddMenuEntry("Normalize", NORMALIZE);
+ glutAddMenuEntry("Rescale EXT", RESCALE);
+ glutAddMenuEntry("Quit", QUIT);
+ glutAttachMenu(GLUT_RIGHT_BUTTON);
+
+ glutMainLoop();
+ return 0;
+}