X11 Display with Grid

This is a simple X11 template code-snippet for visualising grids (e.g. for spatial simulations, simple games), easy to adapt to any C/C++ code. If you want a fast and responsive display, use this one. I’ve tried a lot of different programming languages, but it’s never anywhere near as fast as this.

README:

/*************************************************/
/*	Author: Bram van Dijk (November 2016)    */
/*************************************************/
///////////////////////////////////////////////////
///////////////////////////////////////////////////
//         Displaying a grid in C or C++         //
///////////////////////////////////////////////////
///////////////////////////////////////////////////

///////////////////////////////////////////////////
//              Compiling C / CPP                //
///////////////////////////////////////////////////
gcc -o XGrid Grid.c -lX11 -ljpeg
	or
g++ -o XGrid Grid.c -lX11 -ljpeg

///////////////////////////////////////////////////
//      Getting it to work in your program       //
///////////////////////////////////////////////////

// See Grid.c for a minimal example
In the sourcefile containing the main function:

///////////////////////////////////////////////////
//                 More options                  //
///////////////////////////////////////////////////

// I added some keyboard responses too. (see CatchEvents)
Press 's' to save a JPG of your display
Press 't' to show text (maybe a timestamp?)
Press 'q' to close the program.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 NOTE FOR C++ OOP PROGRAMS: 
 If you want to use it in an object oriented C++ program
 it is best if you split X11_With_Color.c into a header
 file (declarations) and a source file (definitions).
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!