mvarray.c revision 32001f49
1/* 2 * Copyright (c) 1993-2003, Silicon Graphics, Inc. 3 * All Rights Reserved 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose and without fee is hereby granted, provided that the above 7 * copyright notice appear in all copies and that both the copyright 8 * notice and this permission notice appear in supporting documentation, 9 * and that the name of Silicon Graphics, Inc. not be used in 10 * advertising or publicity pertaining to distribution of the software 11 * without specific, written prior permission. 12 * 13 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" AND 14 * WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR 16 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON 17 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, 18 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 19 * OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, LOSS OF 20 * PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD 21 * PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF 22 * THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE 24 * OR PERFORMANCE OF THIS SOFTWARE. 25 * 26 * US Government Users Restricted Rights 27 * Use, duplication, or disclosure by the Government is subject to 28 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph 29 * (c)(1)(ii) of the Rights in Technical Data and Computer Software 30 * clause at DFARS 252.227-7013 and/or in similar or successor clauses 31 * in the FAR or the DOD or NASA FAR Supplement. Unpublished - rights 32 * reserved under the copyright laws of the United States. 33 * 34 * Contractor/manufacturer is: 35 * Silicon Graphics, Inc. 36 * 1500 Crittenden Lane 37 * Mountain View, CA 94043 38 * United State of America 39 * 40 * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. 41 */ 42 43/* 44 * mvarray.c 45 * This program demonstrates multiple vertex arrays, 46 * specifically the OpenGL routine glMultiDrawElements(). 47 */ 48 49#include <GL/glew.h> 50#include "glut_wrap.h" 51#include <stdlib.h> 52#include <stdio.h> 53 54#ifdef GL_VERSION_1_3 55 56static void setupPointer(void) 57{ 58 static GLint vertices[] = {25, 25, 59 75, 75, 60 100, 125, 61 150, 75, 62 200, 175, 63 250, 150, 64 300, 125, 65 100, 200, 66 150, 250, 67 200, 225, 68 250, 300, 69 300, 250}; 70 71 glEnableClientState (GL_VERTEX_ARRAY); 72 glVertexPointer (2, GL_INT, 0, vertices); 73} 74 75static void init(void) 76{ 77 glClearColor (0.0, 0.0, 0.0, 0.0); 78 glShadeModel (GL_SMOOTH); 79 setupPointer (); 80} 81 82static void display(void) 83{ 84 static GLubyte oneIndices[] = {0, 1, 2, 3, 4, 5, 6}; 85 static GLubyte twoIndices[] = {1, 7, 8, 9, 10, 11}; 86 static GLsizei count[] = {7, 6}; 87 static GLvoid * indices[2] = {oneIndices, twoIndices}; 88 89 glClear (GL_COLOR_BUFFER_BIT); 90 glColor3f (1.0, 1.0, 1.0); 91 glMultiDrawElementsEXT (GL_LINE_STRIP, count, GL_UNSIGNED_BYTE, 92 (const GLvoid **) indices, 2); 93 glFlush (); 94} 95 96static void reshape (int w, int h) 97{ 98 glViewport (0, 0, (GLsizei) w, (GLsizei) h); 99 glMatrixMode (GL_PROJECTION); 100 glLoadIdentity (); 101 gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); 102} 103 104static void keyboard(unsigned char key, int x, int y) 105{ 106 switch (key) { 107 case 27: 108 exit(0); 109 break; 110 } 111} 112 113int main(int argc, char** argv) 114{ 115 glutInit(&argc, argv); 116 glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 117 glutInitWindowSize (350, 350); 118 glutInitWindowPosition (100, 100); 119 glutCreateWindow (argv[0]); 120 glewInit(); 121 init (); 122 glutDisplayFunc(display); 123 glutReshapeFunc(reshape); 124 glutKeyboardFunc (keyboard); 125 glutMainLoop(); 126 return 0; 127} 128#else 129int main(int argc, char** argv) 130{ 131 fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); 132 fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); 133 fprintf (stderr, "you may be able to modify this program to make it run.\n"); 134 return 0; 135} 136#endif 137