I tried setting the background color to a transparent one using the functions - glClearColor() and glClear(). But, the alpha values passed to glClearColor() simply doesn't change anything.
Here is the code I tried running:
#include<GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(float)glutGet(GLUT_WINDOW_WIDTH),0.0,(float)glutGet(GLUT_WINDOW_HEIGHT));
glBegin(GL_LINES);
glVertex2i(200,200);
glVertex2i(300,305);
glEnd();
glFlush();
}
int main(int argc, char *argv[const])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA);
glutInitWindowSize(1100,620);
glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-1100)/2,(glutGet(GLUT_SCREEN_HEIGHT)-620)/2);
glutCreateWindow("GLUT Programming");
glClearColor(0.0f,0.0f,0.0f,0.5f); // I have tried experimenting with this part, but, nothing happens
glutDisplayFunc(display);
glutMainLoop();
}
I am using freeglut and freeglut-devel on my machine running Fedora 26, if it helps.
EDIT :
Result I am getting :
Result I am trying to obtain :