progs/fp: close file (bug 26559)
[mesa.git] / progs / fp / fp-tri.c
index bc490c05201f08f32a6b37340959edd6d5be7000..e45a799a00eb639d47c367616c7fd99538d1853d 100644 (file)
@@ -73,7 +73,7 @@ static void Init( void )
    GLuint Texture;
    GLint errno;
    GLuint prognum;
-   char buf[4096];
+   char buf[50000];
    GLuint sz;
    FILE *f;
 
@@ -89,7 +89,7 @@ static void Init( void )
    }
    fprintf(stderr, "%.*s\n", sz, buf);
 
-   if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+   if (!GLEW_ARB_fragment_program) {
       printf("Error: GL_ARB_fragment_program not supported!\n");
       exit(1);
    }
@@ -176,7 +176,19 @@ static void Init( void )
    }
 
 
+   {
+      const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 };
+      const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 };
+      const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 };
+      const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 };
+      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission);
+   }
+
    glClearColor(.1, .3, .5, 0);
+   fclose(f);
 }
 
 static void Reshape(int width, int height)
@@ -197,7 +209,7 @@ static void Key(unsigned char key, int x, int y)
       case 27:
        exit(1);
       default:
-       return;
+       break;
     }
 
     glutPostRedisplay();
@@ -210,11 +222,17 @@ static void Display(void)
    glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 1.0, 1.0, 0.0, 0.0);
    glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 0.0, 0.0, 1.0, 1.0);
    glBegin(GL_TRIANGLES);
+
    glColor3f(0,0,1);
+   glTexCoord3f(1,1,0);
    glVertex3f( 0.9, -0.9, -30.0);
+
    glColor3f(1,0,0);
+   glTexCoord3f(1,-1,0);
    glVertex3f( 0.9,  0.9, -30.0);
+
    glColor3f(0,1,0);
+   glTexCoord3f(-1,0,0);
    glVertex3f(-0.9,  0.0, -30.0);
    glEnd();