Index: .gitignore
===================================================================
--- .gitignore	(revision 644a2e46738c83b6f97bec2d47aaede3076b7e49)
+++ .gitignore	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
@@ -2,4 +2,6 @@
 game
 demo
+
+gl.log
 
 # Visual Studio files
Index: me01.cpp
===================================================================
--- game01.cpp	(revision 644a2e46738c83b6f97bec2d47aaede3076b7e49)
+++ 	(revision )
@@ -1,97 +1,0 @@
-// Include standard headers
-#include <stdio.h>
-#include <stdlib.h>
-#include <iostream>
-
-// Include GLEW
-#include <GL/glew.h>
-
-// Include GLFW
-#include <GLFW/glfw3.h>
-GLFWwindow* window;
-
-// Include GLM
-#include <glm/glm.hpp>
-#include <glm/gtc/matrix_transform.hpp>
-using namespace glm;
-
-#include "common/controls.hpp"
-
-using namespace std;
-
-void framebuffer_size_callback(GLFWwindow* window, int width, int height);
-void processInput(GLFWwindow *window);
-
-// settings
-const unsigned int SCR_WIDTH = 800;
-const unsigned int SCR_HEIGHT = 600;
-
-int main()
-{
-    // glfw: initialize and configure
-    // ------------------------------
-    glfwInit();
-    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
-    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
-    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
-    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
-
-    // glfw window creation
-    // --------------------
-    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
-    if (window == NULL)
-    {
-        cout << "Failed to create GLFW window" << endl;
-        glfwTerminate();
-        return -1;
-    }
-    glfwMakeContextCurrent(window);
-    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
-
-   // Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions
-   glewExperimental = GL_TRUE;
-   // Initialize GLEW to setup the OpenGL Function pointers
-   if (glewInit() != GLEW_OK) {
-       cout << "Failed to initialize GLEW" << endl;
-      return EXIT_FAILURE;
-   }    
-
-    // render loop
-    // -----------
-    while (!glfwWindowShouldClose(window))
-    {
-        // input
-        // -----
-        processInput(window);
-      
-        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
-        glClear(GL_COLOR_BUFFER_BIT);
-
-        // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
-        // -------------------------------------------------------------------------------
-        glfwSwapBuffers(window);
-        glfwPollEvents();
-    }
-
-    // glfw: terminate, clearing all previously allocated GLFW resources.
-    // ------------------------------------------------------------------
-    glfwTerminate();
-    return 0;
-}
-
-// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
-// ---------------------------------------------------------------------------------------------------------
-void processInput(GLFWwindow *window)
-{
-    if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
-        glfwSetWindowShouldClose(window, true);
-}
-
-// glfw: whenever the window size changed (by OS or user resize) this callback function executes
-// ---------------------------------------------------------------------------------------------
-void framebuffer_size_callback(GLFWwindow* window, int width, int height)
-{
-    // make sure the viewport matches the new window dimensions; note that width and 
-    // height will be significantly larger than specified on retina displays.
-    glViewport(0, 0, width, height);
-}
Index: me02.cpp
===================================================================
--- game02.cpp	(revision 644a2e46738c83b6f97bec2d47aaede3076b7e49)
+++ 	(revision )
@@ -1,120 +1,0 @@
-// Include standard headers
-#include <stdio.h>
-#include <stdlib.h>
-
-// Include GLEW
-#include <GL/glew.h>
-
-// Include GLFW
-#include <GLFW/glfw3.h>
-GLFWwindow* window;
-
-// Include GLM
-#include <glm/glm.hpp>
-using namespace glm;
-
-#include "common/shader.hpp"
-
-int main( void )
-{
-	// Initialise GLFW
-	if( !glfwInit() )
-	{
-		fprintf( stderr, "Failed to initialize GLFW\n" );
-		getchar();
-		return -1;
-	}
-
-	glfwWindowHint(GLFW_SAMPLES, 4);
-	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
-	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
-	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
-	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
-
-	// Open a window and create its OpenGL context
-	window = glfwCreateWindow( 1024, 768, "Tutorial 02 - Red triangle", NULL, NULL);
-	if( window == NULL ){
-		fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
-		getchar();
-		glfwTerminate();
-		return -1;
-	}
-	glfwMakeContextCurrent(window);
-
-	// Initialize GLEW
-	glewExperimental = true; // Needed for core profile
-	if (glewInit() != GLEW_OK) {
-		fprintf(stderr, "Failed to initialize GLEW\n");
-		getchar();
-		glfwTerminate();
-		return -1;
-	}
-
-	// Ensure we can capture the escape key being pressed below
-	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
-
-	// Dark blue background
-	glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
-
-	GLuint VertexArrayID;
-	glGenVertexArrays(1, &VertexArrayID);
-	glBindVertexArray(VertexArrayID);
-
-	// Create and compile our GLSL program from the shaders
-	GLuint programID = LoadShaders("SimpleVertexShader.vertexshader", "SimpleFragmentShader.fragmentshader");
-
-
-	static const GLfloat g_vertex_buffer_data[] = {
-		-1.0f, -1.0f, 0.0f,
-		 1.0f, -1.0f, 0.0f,
-		 0.0f,  1.0f, 0.0f,
-	};
-
-	GLuint vertexbuffer;
-	glGenBuffers(1, &vertexbuffer);
-	glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
-	glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
-
-	do{
-
-		// Clear the screen
-		glClear( GL_COLOR_BUFFER_BIT );
-
-		// Use our shader
-		glUseProgram(programID);
-
-		// 1rst attribute buffer : vertices
-		glEnableVertexAttribArray(0);
-		glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
-		glVertexAttribPointer(
-			0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
-			3,                  // size
-			GL_FLOAT,           // type
-			GL_FALSE,           // normalized?
-			0,                  // stride
-			(void*)0            // array buffer offset
-		);
-
-		// Draw the triangle !
-		glDrawArrays(GL_TRIANGLES, 0, 3); // 3 indices starting at 0 -> 1 triangle
-
-		glDisableVertexAttribArray(0);
-
-		// Swap buffers
-		glfwSwapBuffers(window);
-		glfwPollEvents();
-
-	} // Check if the ESC key was pressed or the window was closed
-	while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
-		   glfwWindowShouldClose(window) == 0 );
-
-	// Cleanup VBO
-	glDeleteBuffers(1, &vertexbuffer);
-	glDeleteVertexArrays(1, &VertexArrayID);
-	glDeleteProgram(programID);
-
-	// Close OpenGL window and terminate GLFW
-	glfwTerminate();
-
-	return 0;
-}
Index: game06.cpp
===================================================================
--- game06.cpp	(revision 644a2e46738c83b6f97bec2d47aaede3076b7e49)
+++ game06.cpp	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
@@ -190,5 +190,5 @@
 
 		// Compute the MVP matrix from keyboard and mouse input
-		computeMatricesFromInputs();
+		computeMatricesFromInputs(1024, 768);
 		glm::mat4 ProjectionMatrix = getProjectionMatrix();
 		glm::mat4 ViewMatrix = getViewMatrix();
Index: logger.cpp
===================================================================
--- logger.cpp	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
+++ logger.cpp	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
@@ -0,0 +1,52 @@
+#include "logger.h"
+
+#include <cstdio>
+#include <ctime>
+#include <cstdarg>
+
+bool restart_gl_log() {
+   FILE* file = fopen(GL_LOG_FILE, "w");
+   if (!file) {
+      fprintf(stderr, "ERROR: could not open GL_LOG_FILE log file %s for writing\n", GL_LOG_FILE);
+      return false;
+   }
+   time_t now = time(NULL);
+   char* date = ctime(&now);
+   fprintf(file, "GL_LOG_FILE log. local time %s\n", date);
+   fclose(file);
+   return true;
+}
+
+bool gl_log(const char* message, ...) {
+   va_list argptr;
+   FILE* file = fopen(GL_LOG_FILE, "a");
+   if (!file) {
+      fprintf(stderr, "ERROR: could not open GL_LOG_FILE log file %s for appending\n", GL_LOG_FILE);
+      return false;
+   }
+   va_start(argptr, message);
+   vfprintf(file, message, argptr);
+   va_end(argptr);
+   fprintf(file, "\n");
+   fclose(file);
+   return true;
+}
+
+bool gl_log_err(const char* message, ...) {
+   va_list argptr;
+   FILE* file = fopen(GL_LOG_FILE, "a");
+   if (!file) {
+      fprintf(stderr, "ERROR: could not open GL_LOG_FILE log file %s for appending\n", GL_LOG_FILE);
+      return false;
+   }
+   va_start(argptr, message);
+   vfprintf(file, message, argptr);
+   va_end(argptr);
+   fprintf(file, "\n");
+   va_start(argptr, message);
+   vfprintf(stderr, message, argptr);
+   va_end(argptr);
+   fprintf(stderr, "\n");
+   fclose(file);
+   return true;
+}
Index: logger.h
===================================================================
--- logger.h	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
+++ logger.h	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
@@ -0,0 +1,10 @@
+#ifndef LOGGER_H
+#define LOGGER_H
+
+#define GL_LOG_FILE "gl.log"
+
+bool restart_gl_log();
+bool gl_log(const char* message, ...);
+bool gl_log_err(const char* message, ...);
+
+#endif
Index: makefile
===================================================================
--- makefile	(revision 644a2e46738c83b6f97bec2d47aaede3076b7e49)
+++ makefile	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
@@ -10,5 +10,5 @@
 endif
 
-newgame: new-game.cpp
+newgame: new-game.cpp logger.cpp
 	$(CC) $? $(DEP) $(CFLAGS) -o $@
 
Index: new-game.cpp
===================================================================
--- new-game.cpp	(revision 644a2e46738c83b6f97bec2d47aaede3076b7e49)
+++ new-game.cpp	(revision 22b2c371823b36acd43ca7e3a7ac678f50f1f1fe)
@@ -1,7 +1,9 @@
-#include <cstdio>
-#include <iostream>
+#include "logger.h"
 
 #include <GL/glew.h>
 #include <GLFW/glfw3.h>
+
+#include <cstdio>
+#include <iostream>
 
 using namespace std;
@@ -9,4 +11,6 @@
 int main(int argc, char* argv[]) {
    cout << "New OpenGL Game" << endl;
+
+   restart_gl_log();
 
    if (!glfwInit()) {
