start implementing relational operators
[mesa.git] / progs / fp / point-position.c
1
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"
8
9
10
11 static void Init( void )
12 {
13 static const char *modulate2D =
14 "!!ARBfp1.0\n"
15 "MUL result.color, fragment.position, {.005}.x; \n"
16 "END"
17 ;
18 GLuint modulateProg;
19
20 if (!glutExtensionSupported("GL_ARB_fragment_program")) {
21 printf("Error: GL_ARB_fragment_program not supported!\n");
22 exit(1);
23 }
24 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
25
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);
31
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));
35
36 glEnable(GL_FRAGMENT_PROGRAM_ARB);
37
38 glClearColor(.3, .3, .3, 0);
39 }
40
41 static void Reshape(int width, int height)
42 {
43
44 glViewport(0, 0, (GLint)width, (GLint)height);
45
46 glMatrixMode(GL_PROJECTION);
47 glLoadIdentity();
48 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
49 glMatrixMode(GL_MODELVIEW);
50 }
51
52 static void Key(unsigned char key, int x, int y)
53 {
54
55 switch (key) {
56 case 27:
57 exit(1);
58 default:
59 return;
60 }
61
62 glutPostRedisplay();
63 }
64
65 static void Draw(void)
66 {
67 glClear(GL_COLOR_BUFFER_BIT);
68
69 #if 0
70 glBegin(GL_QUADS);
71 glTexCoord2f(1,0);
72 glVertex3f( 0.9, -0.9, -30.0);
73 glTexCoord2f(1,1);
74 glVertex3f( 0.9, 0.9, -30.0);
75 glTexCoord2f(0,1);
76 glVertex3f(-0.9, 0.9, -30.0);
77 glTexCoord2f(0,0);
78 glVertex3f(-0.9, -0.9, -30.0);
79 glEnd();
80 #else
81 glPointSize(100);
82 glBegin(GL_POINTS);
83 glColor3f(0,0,1);
84 glVertex3f( 0, 0, -30.0);
85 glEnd();
86 #endif
87
88 glFlush();
89
90
91 }
92
93
94 int main(int argc, char **argv)
95 {
96 GLenum type;
97
98 glutInit(&argc, argv);
99
100
101
102 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
103
104 type = GLUT_RGB;
105 type |= GLUT_SINGLE;
106 glutInitDisplayMode(type);
107
108 if (glutCreateWindow("First Tri") == GL_FALSE) {
109 exit(1);
110 }
111
112 Init();
113
114 glutReshapeFunc(Reshape);
115 glutKeyboardFunc(Key);
116 glutDisplayFunc(Draw);
117 glutMainLoop();
118 return 0;
119 }