17 { 0x00, 0x00, 0xff, 0x00 }
21 { 0x00, 0xff, 0x00, 0x00 }
25 { 0xff, 0x00, 0x00, 0x00 }
28 { { -0.9, -0.9, 0.0 },
29 { 0xff, 0xff, 0xff, 0x00 }
33 GLuint indices
[] = { 0, 1, 2, 3 };
35 GLuint arrayObj
, elementObj
;
37 static void Init( void )
42 static const char *prog1
=
44 "MOV result.color, vertex.color;\n"
45 "MOV result.position, vertex.position;\n"
48 glGenProgramsARB(1, &prognum
);
49 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
50 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
51 strlen(prog1
), (const GLubyte
*) prog1
);
53 assert(glIsProgramARB(prognum
));
55 printf("glGetError = %d\n", errno
);
56 if (errno
!= GL_NO_ERROR
)
60 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
61 printf("errorpos: %d\n", errorpos
);
62 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
66 glEnableClientState( GL_VERTEX_ARRAY
);
67 glEnableClientState( GL_COLOR_ARRAY
);
69 glGenBuffersARB(1, &arrayObj
);
70 glGenBuffersARB(1, &elementObj
);
72 glBindBufferARB(GL_ARRAY_BUFFER_ARB
, arrayObj
);
73 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, elementObj
);
75 glBufferDataARB(GL_ARRAY_BUFFER_ARB
, sizeof(verts
), verts
, GL_STATIC_DRAW_ARB
);
76 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, sizeof(indices
), indices
, GL_STATIC_DRAW_ARB
);
78 glVertexPointer( 3, GL_FLOAT
, sizeof(verts
[0]), 0 );
79 glColorPointer( 4, GL_UNSIGNED_BYTE
, sizeof(verts
[0]), (void *)(3*sizeof(float)) );
85 static void Display( void )
87 glClearColor(0.3, 0.3, 0.3, 1);
88 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
90 glEnable(GL_VERTEX_PROGRAM_ARB
);
91 glDrawElements( GL_TRIANGLES
, 3, GL_UNSIGNED_INT
, NULL
);
97 static void Reshape( int width
, int height
)
99 glViewport( 0, 0, width
, height
);
100 glMatrixMode( GL_PROJECTION
);
102 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
103 glMatrixMode( GL_MODELVIEW
);
105 /*glTranslatef( 0.0, 0.0, -15.0 );*/
109 static void Key( unsigned char key
, int x
, int y
)
124 int main( int argc
, char *argv
[] )
126 glutInit( &argc
, argv
);
127 glutInitWindowPosition( 0, 0 );
128 glutInitWindowSize( 250, 250 );
129 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
| GLUT_DEPTH
);
130 glutCreateWindow(argv
[0]);
132 glutReshapeFunc( Reshape
);
133 glutKeyboardFunc( Key
);
134 glutDisplayFunc( Display
);