5
#define GL_GLEXT_PROTOTYPES
11
static void Init( void )
13
static const char *modulate2D =
17
"SGE R0, fragment.color, fragment.color.yzxw; \n"
18
"SGE R1, fragment.color, fragment.color.zxyw; \n"
20
"MUL result.color, R0, fragment.color; \n"
25
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
26
printf("Error: GL_ARB_fragment_program not supported!\n");
29
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
31
/* Setup the fragment program */
32
glGenProgramsARB(1, &modulateProg);
33
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
34
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
35
strlen(modulate2D), (const GLubyte *)modulate2D);
37
printf("glGetError = 0x%x\n", (int) glGetError());
38
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
39
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
41
glEnable(GL_FRAGMENT_PROGRAM_ARB);
43
glClearColor(.3, .3, .3, 0);
46
static void Reshape(int width, int height)
49
glViewport(0, 0, (GLint)width, (GLint)height);
51
glMatrixMode(GL_PROJECTION);
53
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
54
glMatrixMode(GL_MODELVIEW);
57
static void Key(unsigned char key, int x, int y)
70
static void Draw(void)
72
glClear(GL_COLOR_BUFFER_BIT);
74
glBegin(GL_TRIANGLES);
76
glVertex3f( 0.9, -0.9, -30.0);
78
glVertex3f( 0.9, 0.9, -30.0);
80
glVertex3f(-0.9, 0.0, -30.0);
89
int main(int argc, char **argv)
93
glutInit(&argc, argv);
97
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
101
glutInitDisplayMode(type);
103
if (glutCreateWindow("First Tri") == GL_FALSE) {
109
glutReshapeFunc(Reshape);
110
glutKeyboardFunc(Key);
111
glutDisplayFunc(Draw);