title: OpenGL - texture not visible with blending enabled
body: <p>When I try to display texture on object it works but only with <code>GL_BLEND</code> disabled. When I enable blending:</p>
  
  <pre><code>glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  </code></pre>
  
  <p>The texture is just not visible anymore. Black screen.
  I have really no idea whats going on. Its same for JPG and for PNG with alpha channel.</p>
  
  <p>EDIT (more details):</p>
  
  <p>Well, its hard to paste the code (objects, objects eveywhere and huge) but it goes something like this:</p>
  
  <p>//initialization - i commented everything else</p>
  
  <pre><code>glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  </code></pre>
  
  <p>//preparing texture</p>
  
  <pre><code>glEnable(GL_TEXTURE_2D);
  glGenTextures(1, &amp;texture_id);
  glBindTexture(GL_TEXTURE_2D, texture_id);
  
  int Mode = GL_BGR;
  
  int nOfColors = image-&gt;format-&gt;BytesPerPixel;
  if (nOfColors == 4) {
      if (image-&gt;format-&gt;Rmask == 0x000000ff)
          Mode = GL_RGBA;
      else
          Mode = GL_BGRA;
  } else if (nOfColors == 3) {
      if (image-&gt;format-&gt;Rmask == 0x000000ff)
          Mode = GL_RGB;
      else
          Mode = GL_BGR;
  }
  
  // glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  
  glTexImage2D(GL_TEXTURE_2D, 0, nOfColors, image-&gt;w, image-&gt;h, 0, Mode, GL_UNSIGNED_BYTE, image-&gt;pixels);
  glDisable(GL_TEXTURE_2D);
  </code></pre>
  
  <p>//drawing</p>
  
  <pre><code>glColor4f(1.0f,1.0f,1.0f,1.0f);
  glEnable(GL_TEXTURE_2D);
  glBindTexture( GL_TEXTURE_2D, _i );
  
  glBegin(GL_QUADS);
  glTexCoord2f(0, 0);
  glVertex2f(x, y);
  glTexCoord2f(1, 0);
  glVertex2f(x + width, y);
  glTexCoord2f(1, 1);
  glVertex2f(x + width, y + height);
  glTexCoord2f(0, 1);
  glVertex2f(x, y + height);
  glEnd();
  
  glBindTexture( GL_TEXTURE_2D, NULL );
  glDisable(GL_TEXTURE_2D);
  </code></pre>
  
  <p>EDIT2</p>
  
  <p>"black screen" may be little confusing - i meant that nothing is displayed (my background is black but it doesnt matter) - if i turn blending off i get nice texture on screen - with blending on nothing but background color</p>