Initializing OpenGL in X11
In the last post, we created a simple program to open an X11 window. Today, we will learn how to initialize and use OpenGL to clear the window with a color.
And the result: Linking with OpenGL In order to use OpenGL we need to include the following headers:
#include <X11/Xutil.h> // Required to use XVisualInfo #include <GL/gl.h> // OpenGL types and functions like GLuint or glClear #include <GL/glx.h> // OpenGL X Window bindings like glXCreateContext And we also need to tell the compiler to link with OpenGL:
# using pkg-config gcc -o x11_opengl `pkg-config --libs x11 gl` x11_opengl.