10 static void Init( void )
12 /* scale of 10.0 gives me a visible result on nv hardware.
14 static const char *modulate2D
=
17 "MUL R0, fragment.position.z, {10.0}.x;\n"
18 "MOV result.color, R0; \n"
23 if (!GLEW_ARB_fragment_program
) {
24 printf("Error: GL_ARB_fragment_program not supported!\n");
27 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
29 /* Setup the fragment program */
30 glGenProgramsARB(1, &modulateProg
);
31 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, modulateProg
);
32 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
33 strlen(modulate2D
), (const GLubyte
*)modulate2D
);
35 printf("glGetError = 0x%x\n", (int) glGetError());
36 printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
37 (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
39 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
41 glClearColor(.3, .3, .3, 0);
44 static void Reshape(int width
, int height
)
47 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
49 glMatrixMode(GL_PROJECTION
);
51 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
52 glMatrixMode(GL_MODELVIEW
);
55 static void Key(unsigned char key
, int x
, int y
)
68 static void Draw(void)
70 glClear(GL_COLOR_BUFFER_BIT
|GL_DEPTH_BUFFER_BIT
);
71 glEnable(GL_DEPTH_TEST
);
73 glBegin(GL_TRIANGLES
);
75 glVertex3f( 0.9, -0.9, -30.0);
76 glVertex3f( 0.9, 0.9, -30.0);
77 glVertex3f(-0.9, 0.0, -30.0);
79 glVertex3f(-0.9, -0.9, -40.0);
80 glVertex3f(-0.9, 0.9, -40.0);
81 glVertex3f( 0.9, 0.0, -25.0);
90 int main(int argc
, char **argv
)
94 glutInit(&argc
, argv
);
98 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
100 type
= GLUT_RGB
| GLUT_DEPTH
;
102 glutInitDisplayMode(type
);
104 if (glutCreateWindow("First Tri") == GL_FALSE
) {
112 glutReshapeFunc(Reshape
);
113 glutKeyboardFunc(Key
);
114 glutDisplayFunc(Draw
);