5 #define GL_GLEXT_PROTOTYPES
10 static void Init( void )
12 static const char *modulate2D
=
15 "SWZ result.color, fragment.color, 1, 0, 0, 1; \n"
20 if (!glutExtensionSupported("GL_ARB_fragment_program")) {
21 printf("Error: GL_ARB_fragment_program not supported!\n");
24 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
26 /* Setup the fragment program */
27 glGenProgramsARB(1, &modulateProg
);
28 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, modulateProg
);
29 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
30 strlen(modulate2D
), (const GLubyte
*)modulate2D
);
32 printf("glGetError = 0x%x\n", (int) glGetError());
33 printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
34 (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
36 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
38 glClearColor(.3, .3, .3, 0);
41 static void Reshape(int width
, int height
)
44 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
46 glMatrixMode(GL_PROJECTION
);
48 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
49 glMatrixMode(GL_MODELVIEW
);
52 static void Key(unsigned char key
, int x
, int y
)
65 static void Draw(void)
67 glClear(GL_COLOR_BUFFER_BIT
);
69 glBegin(GL_TRIANGLES
);
71 glVertex3f( 0.9, -0.9, -30.0);
73 glVertex3f( 0.9, 0.9, -30.0);
75 glVertex3f(-0.9, 0.0, -30.0);
84 int main(int argc
, char **argv
)
88 glutInit(&argc
, argv
);
92 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
96 glutInitDisplayMode(type
);
98 if (glutCreateWindow("First Tri") == GL_FALSE
) {
104 glutReshapeFunc(Reshape
);
105 glutKeyboardFunc(Key
);
106 glutDisplayFunc(Draw
);