<commit_before>#include "GameWindow.hpp"
#include <al.h>
#include <glm/detail/setup.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "Game.hpp"
#include "GlobalProperties.hpp"
#include "GLFWHandler.hpp"
#include "GameState.hpp"
#include "MessageState.hpp"
#include "Audio.hpp"

namespace Diggler {

int GameWindow::InstanceCount = 0;

GameWindow::GameWindow(Game *G) : G(G) {
	if (InstanceCount++ == 0) {
		int glfwStatus = glfwInit();
		if (glfwStatus != GL_TRUE) {
			std::string err("GLFW init failed: ");
			err += glfwStatus;
			throw std::runtime_error(err);
		}
		getOutputStreamRaw() << "GLFW " << glfwGetVersionString() << std::endl;
	}

	GLFWHandler::getInstance().setWindow(this, m_window);

	m_w = 640; m_h = 480;

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
	glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
	glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere
	//glfwWindowHint(GLFW_STENCIL_BITS, 8);<commit_msg>GameWindow: add GLFW error callback<commit_after>#include "GameWindow.hpp"
#include <al.h>
#include <glm/detail/setup.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "Game.hpp"
#include "GlobalProperties.hpp"
#include "GLFWHandler.hpp"
#include "GameState.hpp"
#include "MessageState.hpp"
#include "Audio.hpp"

namespace Diggler {

int GameWindow::InstanceCount = 0;

static void glfwErrorCallback(int error, const char *description) {
	getErrorStream() << "GLFW Error " << error << ": " << description << std::endl;
}

GameWindow::GameWindow(Game *G) : G(G) {
	if (InstanceCount++ == 0) {
		int glfwStatus = glfwInit();
		if (glfwStatus != GL_TRUE) {
			std::string err("GLFW init failed: ");
			err += glfwStatus;
			throw std::runtime_error(err);
		}
		glfwSetErrorCallback(glfwErrorCallback);
		getOutputStreamRaw() << "GLFW " << glfwGetVersionString() << std::endl;
	}

	GLFWHandler::getInstance().setWindow(this, m_window);

	m_w = 640; m_h = 480;

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
	glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
	glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere
	//glfwWindowHint(GLFW_STENCIL_BITS, 8);
{'fraction_non_alphanumeric': 0.1476923076923077, 'fraction_numerical': 0.01054945054945055, 'mean_word_length': 6.1347962382445145, 'pattern_counts': {'":': 1, '<': 33, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '612768', 'n_tokens_mistral': 894, 'n_tokens_neox': 848, 'n_words': 159}