title: How to blend RGB & BGRA raw images by opengl?
body: <p>I am very new to OpenGL</p>
  
  <p>Trying to blend RGB &amp; BGRA raw images.</p>
  
  <ul>
  <li>RGB is backgroung image </li>
  <li>RGBA is foregroubng image</li>
  </ul>
  
  <p>With the below source getting the output only ,"osd_raw" image .Blending is not happening.</p>
  
  <p>In the below code loading the 2 raw images .
  Creating 2 textures &amp; binding with it.
  Used glBlendFunc for blending. 
  The output is not getting blended.</p>
  
  <p>Please tell me where it's getting wrong.</p>
  
  <pre><code>void display()
  {
  
      GLuint texture[2];
      int width = 960;
      int height = 540;
      unsigned char *osd_raw = loadFile("./osd.raw");
      unsigned char *video_raw = loadFile("./video.raw");
  
      glClearColor(0.1, 0.1, 0.1, 0.0);
      glClear(GL_COLOR_BUFFER_BIT);
  
      glEnable(GL_TEXTURE_2D);
      glGenTextures(2, texture);
  
      glEnable( GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
      glBindTexture(GL_TEXTURE_2D, texture[0]);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, video_raw);
      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_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  
      glBindTexture(GL_TEXTURE_2D, texture[1]);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, osd_raw);
      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_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  
      glBegin(GL_QUADS);
      glTexCoord2f(0, 0);
      glVertex3f(-1, -1, 0);
      glTexCoord2f(0, 1);
      glVertex3f(-1, 1, 0);
      glTexCoord2f(1, 1);
      glVertex3f(1, 1, 0);
      glTexCoord2f(1, 0);
      glVertex3f(1, -1, 0);
      glEnd();
  
      glFlush();
  }
  
  int main(int argc, char** argv)
  {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
  
      glutInitWindowSize(960, 540);
      glutInitWindowPosition(0, 0);
      glutCreateWindow("glut test");
  
      glutDisplayFunc(display);
      glutMainLoop();
      return 0;
  }
  </code></pre>