diff --git a/src/io/window.c b/src/io/window.c index 830c669..6eb7021 100644 --- a/src/io/window.c +++ b/src/io/window.c @@ -2,6 +2,10 @@ // Licensed under the MIT Licence. See LICENSE for details #include "window.h" +#include + +#include "../error.h" + // include before GLFW #define GLAD_GL_IMPLEMENTATION #include @@ -21,22 +25,37 @@ static GLFWwindow* win = NULL; int window_init(void) { +#ifndef NDEBUG + glfwWindowHint(GLFW_CONTEXT_DEBUG, GLFW_TRUE); +#endif + // initialize the window glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // sets the profile to "core", so old, deprecated functions are disabled. glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); + glfwWindowHint(GLFW_RED_BITS, 8); + glfwWindowHint(GLFW_GREEN_BITS, 8); + glfwWindowHint(GLFW_BLUE_BITS, 8); + glfwWindowHint(GLFW_ALPHA_BITS, 0); win = glfwCreateWindow(WIN_DEFAULT_WIDTH, WIN_DEFAULT_HEIGHT, WIN_NAME, NULL, NULL); if (!win) return 1; + // setup OpenGL + glfwMakeContextCurrent(win); + if (!gladLoadGL(glfwGetProcAddress)) return 1; + // configure callbacks glfwSetKeyCallback(win, key_callback); glfwSwapInterval(1); // wait 1 screen update for a redraw a.k.a. "vsync". (not really applicable in this case but eh) - // setup OpenGL - glfwMakeContextCurrent(win); - if (!gladLoadGL(glfwGetProcAddress)) return 1; + // print the OpenGL version information + debug("version info:"); + debug("\tvendor: %s", glGetString(GL_VENDOR)); + debug("\trenderer: %s", glGetString(GL_RENDERER)); + debug("\tversion: %s", glGetString(GL_VERSION)); + debug("\tshading lang: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); return 0; }