Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* $Id: renormal.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
  2. /*
  3. * Test GL_EXT_rescale_normal extension
  4. * Brian Paul January 1998 This program is in the public domain.
  5. */
  6. /*
  7. * $Id: renormal.c,v 1.1 1999/08/19 00:55:40 jtg Exp $
  8. */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <math.h>
  12. #include <GL/glut.h>
  13. static GLfloat Phi = 0.0;
  14. static void Idle(void)
  15. {
  16. Phi += 0.1;
  17. glutPostRedisplay();
  18. }
  19. static void Display( void )
  20. {
  21. GLfloat scale = 0.6 + 0.5 * sin(Phi);
  22. glClear( GL_COLOR_BUFFER_BIT );
  23. glPushMatrix();
  24. glScalef(scale, scale, scale);
  25. glutSolidSphere(2.0, 20, 20);
  26. glPopMatrix();
  27. glutSwapBuffers();
  28. }
  29. static void Reshape( int width, int height )
  30. {
  31. glViewport( 0, 0, width, height );
  32. glMatrixMode( GL_PROJECTION );
  33. glLoadIdentity();
  34. glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
  35. glMatrixMode( GL_MODELVIEW );
  36. glLoadIdentity();
  37. glTranslatef( 0.0, 0.0, -15.0 );
  38. }
  39. static void Init( void )
  40. {
  41. static GLfloat mat[4] = { 0.8, 0.8, 0.0, 1.0 };
  42. static GLfloat pos[4] = { -1.0, 1.0, 1.0, 0.0 };
  43. /* setup lighting, etc */
  44. glEnable(GL_LIGHTING);
  45. glEnable(GL_LIGHT0);
  46. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat);
  47. glLightfv(GL_LIGHT0, GL_POSITION, pos);
  48. glEnable(GL_CULL_FACE);
  49. glDisable(GL_RESCALE_NORMAL_EXT);
  50. glDisable(GL_NORMALIZE);
  51. }
  52. #define UNSCALED 1
  53. #define NORMALIZE 2
  54. #define RESCALE 3
  55. #define QUIT 4
  56. static void ModeMenu(int entry)
  57. {
  58. if (entry==UNSCALED) {
  59. glDisable(GL_RESCALE_NORMAL_EXT);
  60. glDisable(GL_NORMALIZE);
  61. }
  62. else if (entry==NORMALIZE) {
  63. glEnable(GL_NORMALIZE);
  64. glDisable(GL_RESCALE_NORMAL_EXT);
  65. }
  66. else if (entry==RESCALE) {
  67. glDisable(GL_NORMALIZE);
  68. glEnable(GL_RESCALE_NORMAL_EXT);
  69. }
  70. else if (entry==QUIT) {
  71. exit(0);
  72. }
  73. glutPostRedisplay();
  74. }
  75. int main( int argc, char *argv[] )
  76. {
  77. glutInit( &argc, argv );
  78. glutInitWindowSize( 400, 400 );
  79. glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
  80. glutCreateWindow(argv[0]);
  81. Init();
  82. glutIdleFunc( Idle );
  83. glutReshapeFunc( Reshape );
  84. glutDisplayFunc( Display );
  85. glutCreateMenu(ModeMenu);
  86. glutAddMenuEntry("Unscaled", UNSCALED);
  87. glutAddMenuEntry("Normalize", NORMALIZE);
  88. glutAddMenuEntry("Rescale EXT", RESCALE);
  89. glutAddMenuEntry("Quit", QUIT);
  90. glutAttachMenu(GLUT_RIGHT_BUTTON);
  91. glutMainLoop();
  92. return 0;
  93. }