In this article, you will learn how to run OpenGL freeglut program in Dev C++. You can create the new console base C++ project in Dev C++.
Run OpenGL freeglut program in Dev C++
Go to “file” create a new project and select console base c++ project. Below is the screenshot

Don’t forget to add linker parameters. Right-click on the project, go to parameters, and add the linker parameters that are listed below. if you forget to add them. The project is not able to run successfully.
-lopengl32
-lfreeglut
-lglu32
Below is the screenshot of how you can add linker parameters.

Now copy the below code and paster into the project main file and run it. A red color square display on the console screen.
Program: Draw Square
//C++ OPenGL code to draw square
#include <windows.h>
#include <GL/glut.h>
void show() {
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-0.5f, -0.5f);
glVertex2f( 0.5f, -0.5f);
glVertex2f( 0.5f, 0.5f);
glVertex2f(-0.5f, 0.5f);
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutCreateWindow("OpenGL test program");
glutInitWindowSize(400, 300);
glutInitWindowPosition(60, 60);
glutDisplayFunc(show);
glutMainLoop();
return 0;
}
Output

You can also check more related articles