1/* Test rebasing */ 2 3#include <assert.h> 4#include <string.h> 5#include <stdio.h> 6#include <stdlib.h> 7#include <math.h> 8#include <GL/glew.h> 9#include "glut_wrap.h" 10 11#define NR_VERTS 20000 12GLfloat verts[NR_VERTS][4]; 13GLushort indices[NR_VERTS*2]; 14 15 16 17static void Init( void ) 18{ 19 GLint errnum; 20 GLuint prognum; 21 GLint i; 22 23 static const char *prog1 = 24 "!!ARBvp1.0\n" 25 "MOV result.color, {1.0}.xxxx;\n" 26 "MOV result.position, vertex.position;\n" 27 "END\n"; 28 29 glGenProgramsARB(1, &prognum); 30 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); 31 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, 32 strlen(prog1), (const GLubyte *) prog1); 33 34 assert(glIsProgramARB(prognum)); 35 errnum = glGetError(); 36 printf("glGetError = %d\n", errnum); 37 if (errnum != GL_NO_ERROR) 38 { 39 GLint errorpos; 40 41 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); 42 printf("errorpos: %d\n", errorpos); 43 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); 44 } 45 46 47 glEnableClientState( GL_VERTEX_ARRAY ); 48 glEnableClientState( GL_COLOR_ARRAY ); 49 glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts ); 50 51 52 for (i = 0; i < NR_VERTS; i++) { 53 verts[i][0] = cos(i / (float)NR_VERTS * 2.0 * 3.141592); 54 verts[i][1] = sin(i / (float)NR_VERTS * 2.0 * 3.141592); 55 verts[i][2] = 0.0; 56 verts[i][3] = 1.0; 57 58 indices[2*i+0] = i; 59 indices[2*i+1] = (i+1 == NR_VERTS) ? 0 : i+1; 60 } 61} 62 63 64 65static void Display( void ) 66{ 67 glClearColor(0.3, 0.3, 0.3, 1); 68 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 69 70 glEnable(GL_VERTEX_PROGRAM_NV); 71 72 /* Should have min_index == 1, maybe force a rebase: 73 */ 74 glDrawElements( GL_LINES, NR_VERTS*2, GL_UNSIGNED_SHORT, indices ); 75 76 glFlush(); 77} 78 79 80static void Reshape( int width, int height ) 81{ 82 glViewport( 0, 0, width, height ); 83 glMatrixMode( GL_PROJECTION ); 84 glLoadIdentity(); 85 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); 86 glMatrixMode( GL_MODELVIEW ); 87 glLoadIdentity(); 88 /*glTranslatef( 0.0, 0.0, -15.0 );*/ 89} 90 91 92static void Key( unsigned char key, int x, int y ) 93{ 94 (void) x; 95 (void) y; 96 switch (key) { 97 case 27: 98 exit(0); 99 break; 100 } 101 glutPostRedisplay(); 102} 103 104 105 106 107int main( int argc, char *argv[] ) 108{ 109 glutInit( &argc, argv ); 110 glutInitWindowPosition( 0, 0 ); 111 glutInitWindowSize( 250, 250 ); 112 glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); 113 glutCreateWindow(argv[0]); 114 glewInit(); 115 glutReshapeFunc( Reshape ); 116 glutKeyboardFunc( Key ); 117 glutDisplayFunc( Display ); 118 Init(); 119 glutMainLoop(); 120 return 0; 121} 122