132001f49Smrg/* 232001f49Smrg * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. 332001f49Smrg * 432001f49Smrg * Permission to use, copy, modify, distribute, and sell this software and 532001f49Smrg * its documentation for any purpose is hereby granted without fee, provided 632001f49Smrg * that (i) the above copyright notices and this permission notice appear in 732001f49Smrg * all copies of the software and related documentation, and (ii) the name of 832001f49Smrg * Silicon Graphics may not be used in any advertising or 932001f49Smrg * publicity relating to the software without the specific, prior written 1032001f49Smrg * permission of Silicon Graphics. 1132001f49Smrg * 1232001f49Smrg * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF 1332001f49Smrg * ANY KIND, 1432001f49Smrg * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 1532001f49Smrg * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 1632001f49Smrg * 1732001f49Smrg * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR 1832001f49Smrg * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 1932001f49Smrg * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 2032001f49Smrg * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 2132001f49Smrg * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 2232001f49Smrg * OF THIS SOFTWARE. 2332001f49Smrg */ 2432001f49Smrg 2532001f49Smrg#include <stdio.h> 2632001f49Smrg#include <string.h> 2732001f49Smrg#include <stdlib.h> 2832001f49Smrg#include "glut_wrap.h" 2932001f49Smrg 3032001f49Smrgstatic GLenum frontface = GL_CCW; 3132001f49Smrg 3232001f49Smrg 3332001f49Smrgstatic void 3432001f49SmrgInit(void) 3532001f49Smrg{ 3632001f49Smrg fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); 3732001f49Smrg fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); 3832001f49Smrg fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); 3932001f49Smrg fflush(stderr); 4032001f49Smrg} 4132001f49Smrg 4232001f49Smrg 4332001f49Smrgstatic void 4432001f49SmrgReshape(int width, int height) 4532001f49Smrg{ 4632001f49Smrg glViewport(0, 0, (GLint)width, (GLint)height); 4732001f49Smrg glMatrixMode(GL_PROJECTION); 4832001f49Smrg glLoadIdentity(); 4932001f49Smrg glMatrixMode(GL_MODELVIEW); 5032001f49Smrg} 5132001f49Smrg 5232001f49Smrg 5332001f49Smrgstatic void 5432001f49SmrgKey(unsigned char key, int x, int y) 5532001f49Smrg{ 5632001f49Smrg switch (key) { 5732001f49Smrg case 'f': 5832001f49Smrg frontface = (frontface == GL_CCW) ? GL_CW : GL_CCW; 5932001f49Smrg glFrontFace(frontface); 6032001f49Smrg break; 6132001f49Smrg case 27: 6232001f49Smrg exit(1); 6332001f49Smrg default: 6432001f49Smrg return; 6532001f49Smrg } 6632001f49Smrg glutPostRedisplay(); 6732001f49Smrg} 6832001f49Smrg 6932001f49Smrg 7032001f49Smrgstatic void 7132001f49SmrgDraw(void) 7232001f49Smrg{ 7332001f49Smrg static GLboolean flags[3] = { 1, 0, 1}; 7432001f49Smrg static GLfloat color[3][3] = { 7532001f49Smrg { 0.3, 0.3, 0.9 }, 7632001f49Smrg { 0.8, 0.0, 0.0 }, 7732001f49Smrg { 0.0, 0.9, 0.0 } 7832001f49Smrg }; 7932001f49Smrg static GLfloat vert[3][3] = { 8032001f49Smrg { 0.9, -0.9, 0.0 }, 8132001f49Smrg { 0.9, 0.9, 0.0 }, 8232001f49Smrg { -0.9, 0.0, 0.0 } 8332001f49Smrg }; 8432001f49Smrg 8532001f49Smrg glClear(GL_COLOR_BUFFER_BIT); 8632001f49Smrg glPolygonMode(GL_FRONT, GL_LINE); 8732001f49Smrg glPolygonMode(GL_BACK, GL_POINT); 8832001f49Smrg 8932001f49Smrg glVertexPointer(3, GL_FLOAT, 0, vert); 9032001f49Smrg glColorPointer(3, GL_FLOAT, 0, color); 9132001f49Smrg glEdgeFlagPointer(0, flags); 9232001f49Smrg glEnableClientState(GL_VERTEX_ARRAY); 9332001f49Smrg glEnableClientState(GL_COLOR_ARRAY); 9432001f49Smrg glEnableClientState(GL_EDGE_FLAG_ARRAY); 9532001f49Smrg 9632001f49Smrg glDrawArrays(GL_TRIANGLES, 0, 3); 9732001f49Smrg 9832001f49Smrg glutSwapBuffers(); 9932001f49Smrg} 10032001f49Smrg 10132001f49Smrg 10232001f49Smrgint 10332001f49Smrgmain(int argc, char **argv) 10432001f49Smrg{ 10532001f49Smrg glutInit(&argc, argv); 10632001f49Smrg 10732001f49Smrg glutInitWindowPosition(0, 0); 10832001f49Smrg glutInitWindowSize( 250, 250); 10932001f49Smrg glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE); 11032001f49Smrg if (!glutCreateWindow(*argv)) { 11132001f49Smrg exit(1); 11232001f49Smrg } 11332001f49Smrg glutReshapeFunc(Reshape); 11432001f49Smrg glutKeyboardFunc(Key); 11532001f49Smrg glutDisplayFunc(Draw); 11632001f49Smrg Init(); 11732001f49Smrg glutMainLoop(); 11832001f49Smrg return 0; 11932001f49Smrg} 120