| 57 | } |
| 58 | |
| 59 | int Window::Init() |
| 60 | { |
| 61 | if (!glfwInit()) |
| 62 | { |
| 63 | Logger::Log("GLFW initialization failed", "window", CRITICAL); |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | ShowTitleBar(false); |
| 68 | |
| 69 | #ifdef NK_VK |
| 70 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
| 71 | #endif |
| 72 | |
| 73 | this->window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL); |
| 74 | if (!this->window) |
| 75 | { |
| 76 | Logger::Log("Window creation failed", "window", CRITICAL); |
| 77 | return -1; |
| 78 | } |
| 79 | |
| 80 | SetWindowIcon("resources/Images/nuake-logo.png"); |
| 81 | glfwMakeContextCurrent(this->window); |
| 82 | //SetVSync(false); |
| 83 | |
| 84 | #ifndef NK_VK |
| 85 | |
| 86 | if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) |
| 87 | { |
| 88 | Logger::Log("glad initialization failed!", "window", CRITICAL); |
| 89 | return -1; |
| 90 | } |
| 91 | |
| 92 | Logger::Log("Driver detected " + std::string(((char*)glGetString(GL_VERSION))), "window"); |
| 93 | |
| 94 | #endif |
| 95 | |
| 96 | //if (glfwRawMouseMotionSupported()) |
| 97 | // glfwSetInputMode(this->window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); |
| 98 | // |
| 99 | //// TODO: Move this to renderer init. The window shouldnt have to do gl calls. |
| 100 | //glfwWindowHint(GLFW_SAMPLES, 4); |
| 101 | //glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); |
| 102 | //glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); |
| 103 | //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed |
| 104 | //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); |
| 105 | |
| 106 | glfwSetWindowUserPointer(window, this); |
| 107 | |
| 108 | glfwSetWindowCloseCallback(window, [](GLFWwindow* nativeWindow) |
| 109 | { |
| 110 | Window* window = reinterpret_cast<Window*>(glfwGetWindowUserPointer(nativeWindow)); |
| 111 | window->OnWindowClosed(*window); |
| 112 | }); |
| 113 | |
| 114 | glfwSetWindowFocusCallback(window, [](GLFWwindow* nativeWindow, int focused) |
| 115 | { |
| 116 | Window* window = reinterpret_cast<Window*>(glfwGetWindowUserPointer(nativeWindow)); |
nothing calls this directly
no test coverage detected