15 { -0.9, -0.9, 0.0 } };
18 { { 0x00, 0x00, 0xff, 0x00 },
19 { 0x00, 0xff, 0x00, 0x00 },
20 { 0xff, 0x00, 0x00, 0x00 },
21 { 0xff, 0xff, 0xff, 0x00 } };
23 static void Init( void )
28 static const char *prog1
=
30 "MOV result.color, vertex.color;\n"
31 "MOV result.position, vertex.position;\n"
34 glGenProgramsARB(1, &prognum
);
35 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
36 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
37 strlen(prog1
), (const GLubyte
*) prog1
);
39 assert(glIsProgramARB(prognum
));
41 printf("glGetError = %d\n", errno
);
42 if (errno
!= GL_NO_ERROR
)
46 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
47 printf("errorpos: %d\n", errorpos
);
48 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
52 glEnableClientState( GL_VERTEX_ARRAY
);
53 glEnableClientState( GL_COLOR_ARRAY
);
55 glVertexPointer( 3, GL_FLOAT
, sizeof(pos
[0]), pos
);
56 glColorPointer( 4, GL_UNSIGNED_BYTE
, sizeof(color
[0]), color
);
62 static void Display( void )
64 glClearColor(0.3, 0.3, 0.3, 1);
65 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
67 glEnable(GL_VERTEX_PROGRAM_ARB
);
69 /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
70 glDrawArrays( GL_TRIANGLES
, 1, 3 );
76 static void Reshape( int width
, int height
)
78 glViewport( 0, 0, width
, height
);
79 glMatrixMode( GL_PROJECTION
);
81 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
82 glMatrixMode( GL_MODELVIEW
);
84 /*glTranslatef( 0.0, 0.0, -15.0 );*/
88 static void Key( unsigned char key
, int x
, int y
)
103 int main( int argc
, char *argv
[] )
105 glutInit( &argc
, argv
);
106 glutInitWindowPosition( 0, 0 );
107 glutInitWindowSize( 250, 250 );
108 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
| GLUT_DEPTH
);
109 glutCreateWindow(argv
[0]);
111 glutReshapeFunc( Reshape
);
112 glutKeyboardFunc( Key
);
113 glutDisplayFunc( Display
);