3 * A tri-strip w/ two tris is drawn so that the first tri is front-facing
4 * but the second tri is back-facing.
5 * Set glPolygonMode differently for the front/back faces
16 static GLfloat Zrot
= 0;
17 static GLboolean FrontFillBackUnfilled
= GL_TRUE
;
18 static GLboolean Lines
= GL_TRUE
;
24 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
26 if (FrontFillBackUnfilled
) {
28 printf("FrontMode = FILL, BackMode = LINE\n");
29 glPolygonMode(GL_BACK
, GL_LINE
);
32 printf("FrontMode = FILL, BackMode = POINT\n");
33 glPolygonMode(GL_BACK
, GL_POINT
);
35 glPolygonMode(GL_FRONT
, GL_FILL
);
39 printf("FrontMode = LINE, BackMode = FILL\n");
40 glPolygonMode(GL_FRONT
, GL_LINE
);
43 printf("FrontMode = POINT, BackMode = FILL\n");
44 glPolygonMode(GL_FRONT
, GL_POINT
);
46 glPolygonMode(GL_BACK
, GL_FILL
);
50 glRotatef(Zrot
, 0, 0, 1);
52 glBegin(GL_TRIANGLE_STRIP
);
66 Reshape(int width
, int height
)
68 glViewport(0, 0, width
, height
);
69 glMatrixMode(GL_PROJECTION
);
71 glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
72 glMatrixMode(GL_MODELVIEW
);
74 glTranslatef(0.0, 0.0, -15.0);
79 Key(unsigned char key
, int x
, int y
)
81 const GLfloat step
= 3.0;
86 FrontFillBackUnfilled
= !FrontFillBackUnfilled
;
98 glutDestroyWindow(Win
);
109 printf("GL_RENDERER = %s\n", (char*) glGetString(GL_RENDERER
));
114 glColor4f(1, 1, 1, 0.8);
116 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
118 printf("Press 'p' to toggle polygon mode\n");
123 main(int argc
, char *argv
[])
125 glutInit(&argc
, argv
);
126 glutInitWindowPosition(0, 0);
127 glutInitWindowSize(400, 400);
128 glutInitDisplayMode(GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
);
129 Win
= glutCreateWindow(argv
[0]);
130 glutReshapeFunc(Reshape
);
131 glutKeyboardFunc(Key
);
132 glutDisplayFunc(Draw
);