1 /* $Id: renormal.c,v 1.3 1999/09/17 12:27:01 brianp Exp $ */
4 * Test GL_EXT_rescale_normal extension
5 * Brian Paul January 1998 This program is in the public domain.
9 * $Id: renormal.c,v 1.3 1999/09/17 12:27:01 brianp Exp $
19 static GLfloat Phi
= 0.0;
22 static void Idle(void)
29 static void Display( void )
31 GLfloat scale
= 0.6 + 0.5 * sin(Phi
);
32 glClear( GL_COLOR_BUFFER_BIT
);
34 glScalef(scale
, scale
, scale
);
35 glutSolidSphere(2.0, 20, 20);
41 static void Reshape( int width
, int height
)
43 glViewport( 0, 0, width
, height
);
44 glMatrixMode( GL_PROJECTION
);
46 glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
47 glMatrixMode( GL_MODELVIEW
);
49 glTranslatef( 0.0, 0.0, -15.0 );
54 static void Init( void )
56 static GLfloat mat
[4] = { 0.8, 0.8, 0.0, 1.0 };
57 static GLfloat pos
[4] = { -1.0, 1.0, 1.0, 0.0 };
59 /* setup lighting, etc */
60 glEnable(GL_LIGHTING
);
62 glMaterialfv(GL_FRONT
, GL_AMBIENT_AND_DIFFUSE
, mat
);
63 glLightfv(GL_LIGHT0
, GL_POSITION
, pos
);
65 glEnable(GL_CULL_FACE
);
67 glDisable(GL_RESCALE_NORMAL_EXT
);
68 glDisable(GL_NORMALIZE
);
78 static void ModeMenu(int entry
)
80 if (entry
==UNSCALED
) {
81 glDisable(GL_RESCALE_NORMAL_EXT
);
82 glDisable(GL_NORMALIZE
);
84 else if (entry
==NORMALIZE
) {
85 glEnable(GL_NORMALIZE
);
86 glDisable(GL_RESCALE_NORMAL_EXT
);
88 else if (entry
==RESCALE
) {
89 glDisable(GL_NORMALIZE
);
90 glEnable(GL_RESCALE_NORMAL_EXT
);
92 else if (entry
==QUIT
) {
99 key(unsigned char k
, int x
, int y
)
104 case 27: /* Escape */
113 int main( int argc
, char *argv
[] )
115 glutInit( &argc
, argv
);
116 glutInitWindowSize( 400, 400 );
118 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
120 glutCreateWindow(argv
[0]);
124 glutIdleFunc( Idle
);
125 glutReshapeFunc( Reshape
);
126 glutDisplayFunc( Display
);
127 glutKeyboardFunc(key
);
129 glutCreateMenu(ModeMenu
);
130 glutAddMenuEntry("Unscaled", UNSCALED
);
131 glutAddMenuEntry("Normalize", NORMALIZE
);
132 glutAddMenuEntry("Rescale EXT", RESCALE
);
133 glutAddMenuEntry("Quit", QUIT
);
134 glutAttachMenu(GLUT_RIGHT_BUTTON
);