lineloop-elts.c revision 32001f49
132001f49Smrg/* Test rebasing */ 232001f49Smrg 332001f49Smrg#include <assert.h> 432001f49Smrg#include <string.h> 532001f49Smrg#include <stdio.h> 632001f49Smrg#include <stdlib.h> 732001f49Smrg#include <math.h> 832001f49Smrg#include <GL/glew.h> 932001f49Smrg#include "glut_wrap.h" 1032001f49Smrg 1132001f49SmrgGLfloat verts[][4] = { 1232001f49Smrg { 0.9, -0.9, 0.0, 1.0 }, 1332001f49Smrg { 0.9, 0.9, 0.0, 1.0 }, 1432001f49Smrg { -0.9, 0.9, 0.0, 1.0 }, 1532001f49Smrg { -0.9, -0.9, 0.0, 1.0 }, 1632001f49Smrg}; 1732001f49Smrg 1832001f49SmrgGLubyte color[][4] = { 1932001f49Smrg { 0x00, 0x00, 0xff, 0x00 }, 2032001f49Smrg { 0x00, 0xff, 0x00, 0x00 }, 2132001f49Smrg { 0xff, 0x00, 0x00, 0x00 }, 2232001f49Smrg { 0xff, 0xff, 0xff, 0x00 }, 2332001f49Smrg}; 2432001f49Smrg 2532001f49SmrgGLuint indices[] = { 1, 2, 3 }; 2632001f49Smrg 2732001f49Smrgstatic void Init( void ) 2832001f49Smrg{ 2932001f49Smrg GLint errno; 3032001f49Smrg GLuint prognum; 3132001f49Smrg 3232001f49Smrg static const char *prog1 = 3332001f49Smrg "!!ARBvp1.0\n" 3432001f49Smrg "MOV result.color, vertex.color;\n" 3532001f49Smrg "MOV result.position, vertex.position;\n" 3632001f49Smrg "END\n"; 3732001f49Smrg 3832001f49Smrg glGenProgramsARB(1, &prognum); 3932001f49Smrg glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); 4032001f49Smrg glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, 4132001f49Smrg strlen(prog1), (const GLubyte *) prog1); 4232001f49Smrg 4332001f49Smrg assert(glIsProgramARB(prognum)); 4432001f49Smrg errno = glGetError(); 4532001f49Smrg printf("glGetError = %d\n", errno); 4632001f49Smrg if (errno != GL_NO_ERROR) 4732001f49Smrg { 4832001f49Smrg GLint errorpos; 4932001f49Smrg 5032001f49Smrg glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); 5132001f49Smrg printf("errorpos: %d\n", errorpos); 5232001f49Smrg printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); 5332001f49Smrg } 5432001f49Smrg 5532001f49Smrg 5632001f49Smrg glEnableClientState( GL_VERTEX_ARRAY ); 5732001f49Smrg glEnableClientState( GL_COLOR_ARRAY ); 5832001f49Smrg glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts ); 5932001f49Smrg glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color ); 6032001f49Smrg 6132001f49Smrg} 6232001f49Smrg 6332001f49Smrg 6432001f49Smrg 6532001f49Smrgstatic void Display( void ) 6632001f49Smrg{ 6732001f49Smrg glClearColor(0.3, 0.3, 0.3, 1); 6832001f49Smrg glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 6932001f49Smrg 7032001f49Smrg glEnable(GL_VERTEX_PROGRAM_NV); 7132001f49Smrg 7232001f49Smrg /* Should have min_index == 1, maybe force a rebase: 7332001f49Smrg */ 7432001f49Smrg glDrawElements( GL_LINE_LOOP, 3, GL_UNSIGNED_INT, indices ); 7532001f49Smrg 7632001f49Smrg glFlush(); 7732001f49Smrg} 7832001f49Smrg 7932001f49Smrg 8032001f49Smrgstatic void Reshape( int width, int height ) 8132001f49Smrg{ 8232001f49Smrg glViewport( 0, 0, width, height ); 8332001f49Smrg glMatrixMode( GL_PROJECTION ); 8432001f49Smrg glLoadIdentity(); 8532001f49Smrg glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); 8632001f49Smrg glMatrixMode( GL_MODELVIEW ); 8732001f49Smrg glLoadIdentity(); 8832001f49Smrg /*glTranslatef( 0.0, 0.0, -15.0 );*/ 8932001f49Smrg} 9032001f49Smrg 9132001f49Smrg 9232001f49Smrgstatic void Key( unsigned char key, int x, int y ) 9332001f49Smrg{ 9432001f49Smrg (void) x; 9532001f49Smrg (void) y; 9632001f49Smrg switch (key) { 9732001f49Smrg case 27: 9832001f49Smrg exit(0); 9932001f49Smrg break; 10032001f49Smrg } 10132001f49Smrg glutPostRedisplay(); 10232001f49Smrg} 10332001f49Smrg 10432001f49Smrg 10532001f49Smrg 10632001f49Smrg 10732001f49Smrgint main( int argc, char *argv[] ) 10832001f49Smrg{ 10932001f49Smrg glutInit( &argc, argv ); 11032001f49Smrg glutInitWindowPosition( 0, 0 ); 11132001f49Smrg glutInitWindowSize( 250, 250 ); 11232001f49Smrg glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); 11332001f49Smrg glutCreateWindow(argv[0]); 11432001f49Smrg glewInit(); 11532001f49Smrg glutReshapeFunc( Reshape ); 11632001f49Smrg glutKeyboardFunc( Key ); 11732001f49Smrg glutDisplayFunc( Display ); 11832001f49Smrg Init(); 11932001f49Smrg glutMainLoop(); 12032001f49Smrg return 0; 12132001f49Smrg} 122