Enter sudo apt-get update Enter sudo apt-get install freeglut3 Enter sudo apt-get install freeglut3-dev Enter sudo apt-get install binutils-gold Enter sudo apt-get install g++ cmake Enter sudo apt-get install libglew-dev Enter sudo apt-get install g++ Enter sudo apt-get install mesa-common-dev Enter sudo apt-get install build-essential Enter sudo apt-get install libglew1. 5-dev libglm-dev
Enter mkdir Sample-OpenGL-Programs This will create a directory to hold your OpenGL programs. Enter cd Sample-OpenGL-Programs This will change you into your directory. Enter nano main. c OR gedit main. c
#include <GL/freeglut. h> #include <GL/gl. h> void renderFunction() { glClearColor(0. 0, 0. 0, 0. 0, 0. 0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1. 0, 1. 0, 1. 0); glOrtho(-1. 0, 1. 0, -1. 0, 1. 0, -1. 0, 1. 0); glBegin(GL_POLYGON); glVertex2f(-0. 5, -0. 5); glVertex2f(-0. 5, 0. 5); glVertex2f(0. 5, 0. 5); glVertex2f(0. 5, -0. 5); glEnd(); glFlush(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE); glutInitWindowSize(500,500); glutInitWindowPosition(100,100); glutCreateWindow(“OpenGL - First window demo”); glutDisplayFunc(renderFunction); glutMainLoop(); return 0; }
g++ main. c -lglut -lGL -lGLEW -lGLU -o OpenGLExample This command will compile and link your OpenGL libraries.
Enter . /OpenGLExample