Jade Dungeon

OpenGL

sudo apt-get install cmake make g++ libx11-dev libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxext-dev freeglut3-dev freeglut3 freeglut3-dbg 
# libxi-dev x11proto-xf86vidmode-dev
// gcc opengl.c -lGL -lglut -o opengl

// #include "GL/glut.h"
#include <GL/freeglut.h>
#include <GL/gl.h>

void display();

int main(int argc, char **argv)
{
     glutInit(&argc, argv);
 
     glutCreateWindow("example");
     glutDisplayFunc(display);
     glutMainLoop();
 
     return 0;
}

void display()
{
     glClear(GL_COLOR_BUFFER_BIT);
 
     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();
}
// g++ opengl-cpp.cpp -lGL -lglut -o opengl-cpp

// #include "GL/glut.h"
#include "GL/freeglut.h"
#include "GL/gl.h"

/* display function - code from:
     http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html
This is the actual usage of the OpenGL library.
The following code is the same for any platform */
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();
}

/* Main method - main entry point of application
the freeglut library does the window creation work for us,
regardless of the platform. */
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;
}