5 #define GL_GLEXT_PROTOTYPES
11 static void Init( void )
13 static const char *modulate2D
=
16 "MUL R0, fragment.color, {3.0}.x; \n"
17 "FRC result.color, R0; \n"
22 if (!glutExtensionSupported("GL_ARB_fragment_program")) {
23 printf("Error: GL_ARB_fragment_program not supported!\n");
26 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
28 /* Setup the fragment program */
29 glGenProgramsARB(1, &modulateProg
);
30 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, modulateProg
);
31 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
32 strlen(modulate2D
), (const GLubyte
*)modulate2D
);
34 printf("glGetError = 0x%x\n", (int) glGetError());
35 printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
36 (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
38 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
40 glClearColor(.3, .3, .3, 0);
43 static void Reshape(int width
, int height
)
46 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
48 glMatrixMode(GL_PROJECTION
);
50 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
51 glMatrixMode(GL_MODELVIEW
);
54 static void Key(unsigned char key
, int x
, int y
)
67 static void Draw(void)
69 glClear(GL_COLOR_BUFFER_BIT
);
71 glBegin(GL_TRIANGLES
);
73 glVertex3f( 0.9, -0.9, -30.0);
75 glVertex3f( 0.9, 0.9, -30.0);
77 glVertex3f(-0.9, 0.0, -30.0);
86 int main(int argc
, char **argv
)
90 glutInit(&argc
, argv
);
94 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
98 glutInitDisplayMode(type
);
100 if (glutCreateWindow("First Tri") == GL_FALSE
) {
106 glutReshapeFunc(Reshape
);
107 glutKeyboardFunc(Key
);
108 glutDisplayFunc(Draw
);