4 #include <assimp/version.h>
6 #include <GLFW/glfw3.h>
10 #include "performance.h"
14 // static const int EXIT_OK = 0;
15 static const int EXIT_LIB_FAIL = 1;
16 static const int EXIT_CTX_FAIL = 2;
18 static GLFWwindow* window;
20 static void onGlfwError(int error, const char* description);
26 logError("init called more than once");
30 logInfo("Assimp %u.%u", aiGetVersionMajor(), aiGetVersionMinor());
31 logInfo("GLEW %s", (const char*) glewGetString(GLEW_VERSION));
32 logInfo("GLFW %s", glfwGetVersionString());
34 glfwSetErrorCallback(onGlfwError);
37 logError("GLFW init failed");
40 // glutInitContextVersion(4,5); TODO establish correct context
41 // glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
42 // glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
44 window = glfwCreateWindow(1280, 720, "shadowclad", NULL, NULL);
46 logError("Window or context creation failed");
51 glfwMakeContextCurrent(window);
53 logInfo("OpenGL %s", (const char*) glGetString(GL_VERSION));
54 logInfo("GLSL %s", (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
55 logInfo("%s", (const char*) glGetString(GL_RENDERER));
57 GLenum glewInitStatus = glewInit();
58 if (glewInitStatus != GLEW_OK) {
59 logError("GLEW init failed: %s", (const char*) glewGetErrorString(glewInitStatus));
63 logInfo("Setting swap interval to 1");
67 glfwGetFramebufferSize(window, &width, &height);
68 resizeStage(window, width, height);
70 glfwSetFramebufferSizeCallback(window, resizeStage);
71 glfwSetKeyCallback(window, onKeyboardEvent);
74 //initPerformanceMetering();
77 void run(void (*updateFn) (float)) {
79 logError("No update function provided");
83 float lastTime = glfwGetTime();
86 while (!glfwWindowShouldClose(window)) {
87 float time = glfwGetTime();
88 delta = time - lastTime;
102 static void onGlfwError(int error, const char* description) {
103 logError("GLFW error: %s", description);