8 #define GL_GLEXT_PROTOTYPES
19 { 0x00, 0x00, 0xff, 0x00 }
23 { 0x00, 0xff, 0x00, 0x00 }
27 { 0xff, 0x00, 0x00, 0x00 }
30 { { -0.9, -0.9, 0.0 },
31 { 0xff, 0xff, 0xff, 0x00 }
35 GLuint indices
[] = { 1, 2, 3 };
37 GLuint arrayObj
, elementObj
;
39 static void Init( void )
44 static const char *prog1
=
46 "MOV result.color, vertex.color;\n"
47 "MOV result.position, vertex.position;\n"
50 glGenProgramsARB(1, &prognum
);
51 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
52 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
53 strlen(prog1
), (const GLubyte
*) prog1
);
55 assert(glIsProgramARB(prognum
));
57 printf("glGetError = %d\n", errno
);
58 if (errno
!= GL_NO_ERROR
)
62 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
63 printf("errorpos: %d\n", errorpos
);
64 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
68 glEnableClientState( GL_VERTEX_ARRAY
);
69 glEnableClientState( GL_COLOR_ARRAY
);
71 glGenBuffersARB(1, &arrayObj
);
72 glBindBufferARB(GL_ARRAY_BUFFER_ARB
, arrayObj
);
73 glBufferDataARB(GL_ARRAY_BUFFER_ARB
, sizeof(verts
), verts
, GL_STATIC_DRAW_ARB
);
76 glGenBuffersARB(1, &elementObj
);
77 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, elementObj
);
78 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, sizeof(indices
), indices
, GL_STATIC_DRAW_ARB
);
81 glVertexPointer( 3, GL_FLOAT
, sizeof(verts
[0]), 0 );
82 glColorPointer( 4, GL_UNSIGNED_BYTE
, sizeof(verts
[0]), (void *)(3*sizeof(float)) );
88 static void Display( void )
90 glClearColor(0.3, 0.3, 0.3, 1);
91 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
93 glEnable(GL_VERTEX_PROGRAM_ARB
);
96 glDrawRangeElements( GL_TRIANGLES
, 1, 3, 3, GL_UNSIGNED_INT
, NULL
);
98 glDrawRangeElements( GL_TRIANGLES
, 1, 3, 3, GL_UNSIGNED_INT
, indices
);
105 static void Reshape( int width
, int height
)
107 glViewport( 0, 0, width
, height
);
108 glMatrixMode( GL_PROJECTION
);
110 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
111 glMatrixMode( GL_MODELVIEW
);
113 /*glTranslatef( 0.0, 0.0, -15.0 );*/
117 static void Key( unsigned char key
, int x
, int y
)
132 int main( int argc
, char *argv
[] )
134 glutInit( &argc
, argv
);
135 glutInitWindowPosition( 0, 0 );
136 glutInitWindowSize( 250, 250 );
137 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
| GLUT_DEPTH
);
138 glutCreateWindow(argv
[0]);
139 glutReshapeFunc( Reshape
);
140 glutKeyboardFunc( Key
);
141 glutDisplayFunc( Display
);