3 * Test GL_EXT_rescale_normal extension
4 * Brian Paul January 1998 This program is in the public domain.
13 static GLfloat Phi
= 0.0;
16 static void Idle( void )
18 static double t0
= -1.;
19 double dt
, t
= glutGet(GLUT_ELAPSED_TIME
) / 1000.0;
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 glutInitWindowPosition(0, 0);
117 glutInitWindowSize( 400, 400 );
119 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
121 glutCreateWindow(argv
[0]);
125 glutIdleFunc( Idle
);
126 glutReshapeFunc( Reshape
);
127 glutDisplayFunc( Display
);
128 glutKeyboardFunc(key
);
130 glutCreateMenu(ModeMenu
);
131 glutAddMenuEntry("Unscaled", UNSCALED
);
132 glutAddMenuEntry("Normalize", NORMALIZE
);
133 glutAddMenuEntry("Rescale EXT", RESCALE
);
134 glutAddMenuEntry("Quit", QUIT
);
135 glutAttachMenu(GLUT_RIGHT_BUTTON
);