10 static void Init( void )
12 static const char *modulate2D
=
14 "MUL result.color, fragment.position, {.005}.x; \n"
19 if (!GLEW_ARB_fragment_program
) {
20 printf("Error: GL_ARB_fragment_program not supported!\n");
23 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
25 /* Setup the fragment program */
26 glGenProgramsARB(1, &modulateProg
);
27 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, modulateProg
);
28 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
29 strlen(modulate2D
), (const GLubyte
*)modulate2D
);
31 printf("glGetError = 0x%x\n", (int) glGetError());
32 printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
33 (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
35 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
37 glClearColor(.3, .3, .3, 0);
40 static void Reshape(int width
, int height
)
43 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
45 glMatrixMode(GL_PROJECTION
);
47 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
48 glMatrixMode(GL_MODELVIEW
);
51 static void Key(unsigned char key
, int x
, int y
)
64 static void Draw(void)
66 glClear(GL_COLOR_BUFFER_BIT
);
71 glVertex3f( 0.9, -0.9, -30.0);
73 glVertex3f( 0.9, 0.9, -30.0);
75 glVertex3f(-0.9, 0.9, -30.0);
77 glVertex3f(-0.9, -0.9, -30.0);
83 glVertex3f( 0, 0, -30.0);
93 int main(int argc
, char **argv
)
97 glutInit(&argc
, argv
);
101 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
105 glutInitDisplayMode(type
);
107 if (glutCreateWindow("First Tri") == GL_FALSE
) {
115 glutReshapeFunc(Reshape
);
116 glutKeyboardFunc(Key
);
117 glutDisplayFunc(Draw
);