5 #define GL_GLEXT_PROTOTYPES
11 static void Init( void )
13 static const char *modulate2D
=
16 "MUL R0, fragment.color, {3.14}.x; \n"
17 "COS result.color.x, R0.x; \n"
18 "COS result.color.y, R0.y; \n"
19 "COS result.color.z, R0.z; \n"
24 if (!glutExtensionSupported("GL_ARB_fragment_program")) {
25 printf("Error: GL_ARB_fragment_program not supported!\n");
28 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
30 /* Setup the fragment program */
31 glGenProgramsARB(1, &modulateProg
);
32 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, modulateProg
);
33 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
34 strlen(modulate2D
), (const GLubyte
*)modulate2D
);
36 printf("glGetError = 0x%x\n", (int) glGetError());
37 printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
38 (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
40 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
42 glClearColor(.3, .3, .3, 0);
45 static void Reshape(int width
, int height
)
48 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
50 glMatrixMode(GL_PROJECTION
);
52 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
53 glMatrixMode(GL_MODELVIEW
);
56 static void Key(unsigned char key
, int x
, int y
)
69 static void Draw(void)
71 glClear(GL_COLOR_BUFFER_BIT
);
73 glBegin(GL_TRIANGLES
);
75 glVertex3f( 0.9, -0.9, -30.0);
77 glVertex3f( 0.9, 0.9, -30.0);
79 glVertex3f(-0.9, 0.0, -30.0);
89 int main(int argc
, char **argv
)
93 glutInit(&argc
, argv
);
96 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
100 glutInitDisplayMode(type
);
102 if (glutCreateWindow("First Tri") == GL_FALSE
) {
108 glutReshapeFunc(Reshape
);
109 glutKeyboardFunc(Key
);
110 glutDisplayFunc(Draw
);