chmod a-x **/glslnoise.c
[mesa-demos.git] / src / fp / tri-depth.c
bloba1f0579c8e11d792ea86595c58115843d2b28af8
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #define GL_GLEXT_PROTOTYPES
6 #include <GL/glut.h>
7 #include "GL/gl.h"
11 static void Init( void )
13 /* scale of 10.0 gives me a visible result on nv hardware.
15 static const char *modulate2D =
16 "!!ARBfp1.0\n"
17 "MUL result.color, fragment.position.z, {10.0}.x; \n"
18 "END"
20 GLuint modulateProg;
22 if (!glutExtensionSupported("GL_ARB_fragment_program")) {
23 printf("Error: GL_ARB_fragment_program not supported!\n");
24 exit(1);
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);
49 glLoadIdentity();
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)
57 switch (key) {
58 case 27:
59 exit(1);
60 default:
61 return;
64 glutPostRedisplay();
67 static void Draw(void)
69 glClear(GL_COLOR_BUFFER_BIT);
71 glBegin(GL_TRIANGLES);
72 glColor3f(0,0,1);
73 glVertex3f( 0.9, -0.9, -40.0);
74 glColor3f(1,0,0);
75 glVertex3f( 0.9, 0.9, -40.0);
76 glColor3f(0,1,0);
77 glVertex3f(-0.9, 0.0, -25.0);
78 glEnd();
80 glFlush();
86 int main(int argc, char **argv)
88 GLenum type;
90 glutInit(&argc, argv);
94 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
96 type = GLUT_RGB;
97 type |= GLUT_SINGLE;
98 glutInitDisplayMode(type);
100 if (glutCreateWindow("First Tri") == GL_FALSE) {
101 exit(1);
104 Init();
106 glutReshapeFunc(Reshape);
107 glutKeyboardFunc(Key);
108 glutDisplayFunc(Draw);
109 glutMainLoop();
110 return 0;