title: Texture Transparency in OpenGL
body: <p>I am making a texture in my environment that excludes all white pixels. I read in a ppm file and the fourth value is always set to 0 if it is a white pixel. Everything seems to be in order, I have set up my view correctly and so forth. The texture image is visible with my current code, however the image as a whole is not fully opaque. It is highly see through. Is this a problem with how I am setting up my GL_Blend? Why is the entire texture not opaque as it should be only excluding the white pixels?</p>
  
  <p>first three values are read in as rgb values and fourth value is not in file, it is selected depending on the total value of the three previous numbers from rgb. This texture is not loaded every time I render it is in a display list so only done once. </p>
  
  <pre><code>glPushMatrix();
  
      FILE *inFile3;
      char dump3[3];
      int max3, k3 = 0;
  
      inFile3 = fopen("tree.ppm", "r");
      int x3;
      int y3;
  
      fscanf(inFile3, "%s", dump3);
      fscanf(inFile3, "%d %d", &amp;x3, &amp;y3);
  
  
      fscanf(inFile3, "%d", &amp;max3);
      int arraySize3 = y3*(4*x3);
      int pixel3, rgb = 0;
      GLubyte data3[arraySize3];
  
      for (int i = 0; i &lt; x3; i++) {
          for (int j = 0; j &lt; y3; j++) {
              fscanf(inFile3, "%d", &amp;pixel3);
              data3[k3++] = pixel3;
              rgb += pixel3;
  
              fscanf(inFile3, "%d", &amp;pixel3);
              data3[k3++] = pixel3;
              rgb += pixel3;
  
              fscanf(inFile3, "%d", &amp;pixel3);
              data3[k3++] = pixel3;
              rgb += pixel3;
  
              data3[k3++] = ((rgb) &gt; 760) ? 0 : 255;
              rgb = 0;
          }
      }
  
  
      fclose(inFile3);
  
      glGenTextures(1,&amp;texture3);
      glBindTexture(GL_TEXTURE_2D,texture3);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);
  
  
      gluBuild2DMipmaps(GL_TEXTURE_2D,4,x3,y3,GL_RGBA,GL_UNSIGNED_BYTE,data3);
  
  
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
      glEnable( GL_TEXTURE_2D );
      glBindTexture( GL_TEXTURE_2D, texture3 );
      glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
  
      glRotatef(180, 0, 0, 0);
      glTranslatef(0, -19, 0);
  
      glBegin(GL_QUADS);
  
      glTexCoord2d(0,0); glVertex3f(30,0,10);
      glTexCoord2d(0,1); glVertex3f(30,20,10);
      glTexCoord2d(1,1); glVertex3f(30,20,-10);
      glTexCoord2d(1,0); glVertex3f(30,0,-10);
  
      glEnd();
  
      glDisable(GL_TEXTURE_2D);
      glDisable(GL_BLEND);
      glPopMatrix();
  </code></pre>
  
  <p>Screen shots:
  <img src="https://i.stack.imgur.com/KUOI1.png" alt="Tree is not solid"></p>
  
  <p><img src="https://i.stack.imgur.com/Lkbyh.jpg" alt="enter image description here"></p>