2 * Test flat shading and clipping.
12 #include "glut_wrap.h"
15 static GLfloat Scale
= 2.0, Zrot
= 50;
16 static GLenum Mode
= GL_LINE_LOOP
;
17 static GLboolean Smooth
= 0;
18 static GLenum PolygonMode
= GL_FILL
;
24 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
27 glShadeModel(GL_SMOOTH
);
29 glShadeModel(GL_FLAT
);
32 glScalef(Scale
, Scale
, 1);
33 glRotatef(Zrot
, 0, 0, 1);
35 glPolygonMode(GL_FRONT_AND_BACK
, PolygonMode
);
47 glScalef(0.9, 0.9, 1);
68 Reshape(int width
, int height
)
70 glViewport(0, 0, width
, height
);
71 glMatrixMode(GL_PROJECTION
);
73 glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
74 glMatrixMode(GL_MODELVIEW
);
76 glTranslatef(0.0, 0.0, -15.0);
81 Key(unsigned char key
, int x
, int y
)
87 if (Mode
== GL_TRIANGLES
)
93 if (PolygonMode
== GL_POINT
)
94 PolygonMode
= GL_LINE
;
95 else if (PolygonMode
== GL_LINE
)
96 PolygonMode
= GL_FILL
;
98 PolygonMode
= GL_POINT
;
99 printf("PolygonMode = 0x%x\n", PolygonMode
);
117 glutDestroyWindow(Win
);
129 printf(" z/Z: change triangle size\n");
130 printf(" r/R: rotate\n");
131 printf(" p: toggle line/fill mode\n");
132 printf(" s: toggle smooth/flat shading\n");
133 printf(" f: switch polygon fill mode\n");
138 main(int argc
, char *argv
[])
140 glutInit(&argc
, argv
);
141 glutInitWindowPosition(0, 0);
142 glutInitWindowSize(400, 400);
143 glutInitDisplayMode(GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
);
144 Win
= glutCreateWindow(argv
[0]);
145 glutReshapeFunc(Reshape
);
146 glutKeyboardFunc(Key
);
147 glutDisplayFunc(Draw
);