title: OpenGL translucent texture over other texture
body: <p>I got a 2 png images, being used as textures in a Qt/C++ 2D OpenGL application. The first is used as some kind of "middle" ground and the second is used as an "object" being rendered "ontop" (Note: they all have the same z-value atm, I get the desired behaviour be rendering it in a defined order). The "object"-texture is partly translucent. The "middleground" texture is mostly solid.
  The problem is that, the translucent part of my "object" texture does the solid background color and not the "middleground" texture.</p>
  
  <p>Any tips how to achieve this?</p>
  
  <p>Following OpenGL falgs are used for my textures rendering</p>
  
  <pre><code>glEnable (GL_TEXTURE_2D);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glEnable (GL_BLEND);
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  </code></pre>
  
  <p>Thanks for any help.</p>
  
  <p>Edit:</p>
  
  <p>More code:</p>
  
  <pre><code>glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  
  glEnable(GL_DEPTH_TEST);
  glDepthMask(GL_TRUE);
  
  glEnable(GL_ALPHA_TEST);
  glAlphaFunc(GL_GREATER, 0.1f);
  
  glEnable(GL_TEXTURE_2D);
  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glBindTexture(GL_TEXTURE_2D, c-&gt;_texture);
  
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  
  glBegin(GL_QUADS);
  {
      glTexCoord2i(0,0);
      glVertex2i(-128,-128);
  
      glTexCoord2i(0,1);
      glVertex2i(-128,128);
  
      glTexCoord2i(1,1);
      glVertex2i(128,128);
  
      glTexCoord2i(1,0);
      glVertex2i(128,-128);
  
  }
  glEnd();
  
  glDisable(GL_TEXTURE_2D);
  
  glDisable(GL_ALPHA_TEST);
  glDisable(GL_DEPTH_TEST);
  </code></pre>
  
  <p>Edit: How I load my texture and as far as I can say it loads it <em>with</em> alpha channel</p>
  
  <pre><code>QImage img("./images/dummycar.png","PNG");
  QImage t(QGLWidget::convertToGLFormat(img));
  glGenTextures(1, &amp;_texture);
  glBindTexture(GL_TEXTURE_2D, _texture);
  glTexImage2D( GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits() );
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  </code></pre>
  
  <p>Screenshot: <a href="http://img824.imageshack.us/img824/1912/blackbox.png" rel="noreferrer">http://img824.imageshack.us/img824/1912/blackbox.png</a></p>
  
  <p>The Skyimage is the "middleground" the background is solid black.</p>