| 258 | |
| 259 | |
| 260 | Window::Window() { |
| 261 | internal = new Internal; |
| 262 | int err; |
| 263 | |
| 264 | // Set window hints |
| 265 | #if defined NANOVG_GL2 |
| 266 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); |
| 267 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); |
| 268 | #elif defined NANOVG_GL3 |
| 269 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); |
| 270 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); |
| 271 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); |
| 272 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); |
| 273 | #endif |
| 274 | glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); |
| 275 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); |
| 276 | |
| 277 | #if defined ARCH_MAC |
| 278 | glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE); |
| 279 | #endif |
| 280 | |
| 281 | // Create window |
| 282 | win = glfwCreateWindow(1024, 720, "", NULL, NULL); |
| 283 | if (!win) { |
| 284 | osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not open GLFW window. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); |
| 285 | throw Exception("Could not create Window"); |
| 286 | } |
| 287 | |
| 288 | float contentScale; |
| 289 | glfwGetWindowContentScale(win, &contentScale, NULL); |
| 290 | INFO("Window content scale: %f", contentScale); |
| 291 | |
| 292 | glfwSetWindowSizeLimits(win, WINDOW_SIZE_MIN.x, WINDOW_SIZE_MIN.y, GLFW_DONT_CARE, GLFW_DONT_CARE); |
| 293 | if (settings::windowSize.x > 0 && settings::windowSize.y > 0) { |
| 294 | glfwSetWindowSize(win, settings::windowSize.x, settings::windowSize.y); |
| 295 | } |
| 296 | if (settings::windowPos.x > -32000 && settings::windowPos.y > -32000) { |
| 297 | glfwSetWindowPos(win, settings::windowPos.x, settings::windowPos.y); |
| 298 | } |
| 299 | if (settings::windowMaximized) { |
| 300 | glfwMaximizeWindow(win); |
| 301 | } |
| 302 | glfwShowWindow(win); |
| 303 | |
| 304 | glfwSetWindowUserPointer(win, contextGet()); |
| 305 | glfwSetInputMode(win, GLFW_LOCK_KEY_MODS, 1); |
| 306 | |
| 307 | glfwMakeContextCurrent(win); |
| 308 | glfwSwapInterval(0); |
| 309 | const GLFWvidmode* monitorMode = glfwGetVideoMode(glfwGetPrimaryMonitor()); |
| 310 | if (monitorMode->refreshRate > 0) { |
| 311 | internal->monitorRefreshRate = monitorMode->refreshRate; |
| 312 | } |
| 313 | else { |
| 314 | // Some monitors report 0Hz refresh rate for some reason, so as a workaround, assume 60Hz. |
| 315 | internal->monitorRefreshRate = 60; |
| 316 | } |
| 317 |
nothing calls this directly
no test coverage detected