title: Transparency/Blending issues with OpenGL ES/iPhone
body: <p>I have a simple 16x16 particle that goes from being opaque to transparent. Unfortunately is appears different in my iPhone port and I can't see where the differences in the code are. Most of the code is essentially the same.</p>
  
  <p>I've uploaded an image to <a href="http://img196.imageshack.us/img196/262/transparencyfail.jpg" rel="nofollow noreferrer">here</a> to show the problem</p>
  
  <p>The particle on the left is the incorrectly rendered iPhone version and the right is how it appears on Mac and Windows. It's just a simple RGBA .png file. </p>
  
  <p>I've tried numerous blend functions and glTexEnv setting but I can't seem to make them the same.</p>
  
  <p>Just to be thorough, my Texture loading code on the iPhone looks like the following</p>
  
  <pre><code>
  GLuint TextureLoader::LoadTexture(const char *path)
  {
      NSString *macPath = [NSString stringWithCString:path length:strlen(path)]; 
      GLuint texture = 0;
  
      CGImageRef textureImage = [UIImage imageNamed:macPath].CGImage;
      if (textureImage == nil)
      {
          NSLog(@"Failed to load texture image");
          return 0;
      }
  
      NSInteger texWidth = CGImageGetWidth(textureImage);
          NSInteger texHeight = CGImageGetHeight(textureImage);
  
      GLubyte *textureData = new GLubyte[texWidth * texHeight * 4];
      memset(textureData, 0, texWidth * texHeight * 4);
  
      CGContextRef textureContext = CGBitmapContextCreate(textureData, texWidth, texHeight, 8, texWidth * 4, CGImageGetColorSpace(textureImage), kCGImageAlphaPremultipliedLast);
      CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)texWidth, (float)texHeight), textureImage);
  
      CGContextRelease(textureContext);
  
      //Make a texture ID, bind it, create it
      glGenTextures(1, &texture);
      glBindTexture(GL_TEXTURE_2D, texture);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
  
      delete[] textureData;
  
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
      return texture;
  }
  </code></pre>
  
  <p>The blend function I use is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);</p>
  
  <p>I'll try any ideas people throw at me, because this has been a bit of a mystery to me.</p>
  
  <p>Cheers.</p>