mesa-demos: NOTE! Default branch is now main
[mesa-demos.git] / src / trivial / tri-edgeflag-array.c
blobf5bcc34f4c781e68cc9b47910ee5bf0f7bc8dc54
1 /*
2 * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that (i) the above copyright notices and this permission notice appear in
7 * all copies of the software and related documentation, and (ii) the name of
8 * Silicon Graphics may not be used in any advertising or
9 * publicity relating to the software without the specific, prior written
10 * permission of Silicon Graphics.
12 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
13 * ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include "glut_wrap.h"
30 static GLenum frontface = GL_CCW;
33 static void
34 Init(void)
36 fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
37 fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
38 fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
39 fflush(stderr);
43 static void
44 Reshape(int width, int height)
46 glViewport(0, 0, (GLint)width, (GLint)height);
47 glMatrixMode(GL_PROJECTION);
48 glLoadIdentity();
49 glMatrixMode(GL_MODELVIEW);
53 static void
54 Key(unsigned char key, int x, int y)
56 switch (key) {
57 case 'f':
58 frontface = (frontface == GL_CCW) ? GL_CW : GL_CCW;
59 glFrontFace(frontface);
60 break;
61 case 27:
62 exit(1);
63 default:
64 return;
66 glutPostRedisplay();
70 static void
71 Draw(void)
73 static GLboolean flags[3] = { 1, 0, 1};
74 static GLfloat color[3][3] = {
75 { 0.3, 0.3, 0.9 },
76 { 0.8, 0.0, 0.0 },
77 { 0.0, 0.9, 0.0 }
79 static GLfloat vert[3][3] = {
80 { 0.9, -0.9, 0.0 },
81 { 0.9, 0.9, 0.0 },
82 { -0.9, 0.0, 0.0 }
85 glClear(GL_COLOR_BUFFER_BIT);
86 glPolygonMode(GL_FRONT, GL_LINE);
87 glPolygonMode(GL_BACK, GL_POINT);
89 glVertexPointer(3, GL_FLOAT, 0, vert);
90 glColorPointer(3, GL_FLOAT, 0, color);
91 glEdgeFlagPointer(0, flags);
92 glEnableClientState(GL_VERTEX_ARRAY);
93 glEnableClientState(GL_COLOR_ARRAY);
94 glEnableClientState(GL_EDGE_FLAG_ARRAY);
96 glDrawArrays(GL_TRIANGLES, 0, 3);
98 glutSwapBuffers();
103 main(int argc, char **argv)
105 glutInit(&argc, argv);
107 glutInitWindowPosition(0, 0);
108 glutInitWindowSize( 250, 250);
109 glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE);
110 if (!glutCreateWindow(*argv)) {
111 exit(1);
113 glutReshapeFunc(Reshape);
114 glutKeyboardFunc(Key);
115 glutDisplayFunc(Draw);
116 Init();
117 glutMainLoop();
118 return 0;