mesa-demos: NOTE! Default branch is now main
[mesa-demos.git] / src / trivial / lineloop-elts.c
blobe5919f65eda1e0022fcfb4b184a15746c6344422
1 /* Test rebasing */
3 #include <assert.h>
4 #include <string.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <glad/glad.h>
9 #include "glut_wrap.h"
11 GLfloat verts[][4] = {
12 { 0.9, -0.9, 0.0, 1.0 },
13 { 0.9, 0.9, 0.0, 1.0 },
14 { -0.9, 0.9, 0.0, 1.0 },
15 { -0.9, -0.9, 0.0, 1.0 },
18 GLubyte color[][4] = {
19 { 0x00, 0x00, 0xff, 0x00 },
20 { 0x00, 0xff, 0x00, 0x00 },
21 { 0xff, 0x00, 0x00, 0x00 },
22 { 0xff, 0xff, 0xff, 0x00 },
25 GLuint indices[] = { 1, 2, 3 };
27 static void Init( void )
29 GLint errnum;
30 GLuint prognum;
32 static const char *prog1 =
33 "!!ARBvp1.0\n"
34 "MOV result.color, vertex.color;\n"
35 "MOV result.position, vertex.position;\n"
36 "END\n";
38 glGenProgramsARB(1, &prognum);
39 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
40 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
41 strlen(prog1), (const GLubyte *) prog1);
43 assert(glIsProgramARB(prognum));
44 errnum = glGetError();
45 printf("glGetError = %d\n", errnum);
46 if (errnum != GL_NO_ERROR)
48 GLint errorpos;
50 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
51 printf("errorpos: %d\n", errorpos);
52 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
56 glEnableClientState( GL_VERTEX_ARRAY );
57 glEnableClientState( GL_COLOR_ARRAY );
58 glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts );
59 glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
65 static void Display( void )
67 glClearColor(0.3, 0.3, 0.3, 1);
68 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
70 glEnable(GL_VERTEX_PROGRAM_NV);
72 /* Should have min_index == 1, maybe force a rebase:
74 glDrawElements( GL_LINE_LOOP, 3, GL_UNSIGNED_INT, indices );
76 glFlush();
80 static void Reshape( int width, int height )
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 );*/
92 static void Key( unsigned char key, int x, int y )
94 (void) x;
95 (void) y;
96 switch (key) {
97 case 27:
98 exit(0);
99 break;
101 glutPostRedisplay();
107 int main( int argc, char *argv[] )
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 gladLoadGL();
115 glutReshapeFunc( Reshape );
116 glutKeyboardFunc( Key );
117 glutDisplayFunc( Display );
118 Init();
119 glutMainLoop();
120 return 0;