title: Display images on a transparent background with no border in C++ / OpenGL
body: <p>I am looking for a way to display two png images (in fact, it will be numbers, my aim is to create an overlay for live streaming to display players score and some further additional content) on a window with transparent background with no border. So that we just see the score over the window placed behind.</p>
  
  <p>Is there any way to do something like that ? I have already tried many things with SDL, textures, but nothing led me to any satisfying result. The best I found was some dirty code almost working but completely unusable.</p>
  
  <p>If possible, the solution may let possible to add the functionality that when you click left or right on one of the 2 scores, it is incremented or decremented.</p>
  
  <p><strong>Edit:</strong> Here is my current code. I started new without any bit of the dirty code I had before, because I would like to understand what I am doing. I have my 2 numbers displayed as textures, now I would like to remove borders and title bar of my window, and make my background transparent.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;windowsx.h&gt;
  #include &lt;math.h&gt;
  
  #include &lt;GL/gl.h&gt;
  #include &lt;GL/glu.h&gt;
  #include &lt;GL/glut.h&gt;
  
  #include "sdlglutils.h"
  
  #include &lt;assert.h&gt;
  #include &lt;tchar.h&gt;
  
  using namespace std;
  
  int overlay;
  int TimerEnabled;
  GLfloat posX, posY, posZ;
  GLuint texture_0, texture_1, texture_2, texture_3;
  
  void Initialize()
  {
      glEnable(GL_ALPHA_TEST);
      glEnable(GL_DEPTH_TEST);
      glEnable(GL_COLOR_MATERIAL);
  
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glClearColor(0, 0, 0, 0);
  
      glEnable(GL_TEXTURE_2D);
  }
  
  void Reshape(int w, int h)
  {
      glViewport(0, 0, (GLsizei) w, (GLsizei) h);
  
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluPerspective(45.0f, (GLfloat)w/(GLfloat)h,0.1f,100.0f);
  
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      texture_0 = loadTexture("0.png");
      texture_1 = loadTexture("1.png");
      texture_2 = loadTexture("2.png");
      texture_3 = loadTexture("3.png");
  
      return;
  }
  
  void Draw()
  {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  
      glTranslatef(posX,posY,posZ);
  
      glScalef(1.0f,1.0f,1.0f);
      glPushMatrix();
          glTranslated(-6, 8, 0);
          glBindTexture(GL_TEXTURE_2D, texture_1);
          glBegin(GL_QUADS);
              glTexCoord2d(0,0);      glVertex2d(0,0);
              glTexCoord2d(1,0);      glVertex2d(1,0);
              glTexCoord2d(1,1);      glVertex2d(1,1);
              glTexCoord2d(0,1);      glVertex2d(0,1);
          glEnd();
      glPopMatrix();
  
      glPushMatrix();
          glTranslated(6, 8, 0);
          glBindTexture(GL_TEXTURE_2D, texture_2);
          glBegin(GL_QUADS);
              glTexCoord2d(0,0);      glVertex2d(0,0);
              glTexCoord2d(1,0);      glVertex2d(1,0);
              glTexCoord2d(1,1);      glVertex2d(1,1);
              glTexCoord2d(0,1);      glVertex2d(0,1);
          glEnd();
      glPopMatrix();
  
      glFlush();
  }
  
  void Display()
  {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glLoadIdentity();
      Draw();
  
      glutSwapBuffers();
  }
  
  void KeyboardSpecialEvent( int key, int x, int y)
  {
      switch(key)
      {
          case(GLUT_KEY_UP) :
          {
              posY += 0.3;
          }break;
  
          case(GLUT_KEY_DOWN) :
          {
              posY -= 0.3;
          }break;
  
          case(GLUT_KEY_LEFT) :
          {
              posX -= 0.3;
          }break;
  
          case(GLUT_KEY_RIGHT) :
          {
              posX += 0.3;
          }break;
      }
  }
  void MouseEvent( int button, int state, int x, int y){ };
  void MotionMouseEvent( int x, int y ){  };
  void IdleEvent(){  };
  void TimerEvent(int time)
  {
      glutPostRedisplay();
  
      if(TimerEnabled)
          glutTimerFunc(10, TimerEvent, time);
  }
  
  void KeyboardEvent( unsigned char key, int x, int y)
  {
      switch(key)
      {
          case ' ' :
          {
              TimerEnabled = !TimerEnabled;
              if (TimerEnabled)
                  glutTimerFunc(40, TimerEvent, 0);
          }
          break;
  
          case 'q' :
          {
              exit(0);
          }
          break;
      }
  }
  
  int main(int argc, char** argv)
  {
      posX = 0;
      posY = 0;
      posZ = -25;
      TimerEnabled = 1;
  
      glutInit(&amp;argc,argv);
      glutInitDisplayMode(GLUT_RGBA);
  
      glutInitWindowSize(1600,900);
      glutInitWindowPosition(0,0);
  
      overlay = glutCreateWindow("ScoreOverlay");
      //glutFullScreen();
  
      Initialize();
  
      glutDisplayFunc(Display);
      glutReshapeFunc(Reshape);
      glutKeyboardFunc(KeyboardEvent);
      glutSpecialFunc(KeyboardSpecialEvent);
      glutMouseFunc(MouseEvent);
      glutMotionFunc(MotionMouseEvent);
      glutIdleFunc(IdleEvent);
      glutTimerFunc(40, TimerEvent, 0);
  
      glutMainLoop();
  
      return 0;
  }
  </code></pre>