MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / Window

Method Window

Source/Falcor/Core/Window.cpp:379–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379Window::Window(const Desc& desc, ICallbacks* pCallbacks)
380 : mDesc(desc), mMouseScale(1.0f / (float)desc.width, 1.0f / (float)desc.height), mpCallbacks(pCallbacks)
381{
382 // Set error callback
383 glfwSetErrorCallback(ApiCallbacks::errorCallback);
384
385 // Init GLFW when first window is created.
386 if (sWindowCount.fetch_add(1) == 0)
387 {
388 if (glfwInit() == GLFW_FALSE)
389 FALCOR_THROW("Failed to initialize GLFW.");
390 }
391
392 // Create the window
393 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
394 uint32_t w = desc.width;
395 uint32_t h = desc.height;
396
397 if (desc.mode == WindowMode::Fullscreen)
398 {
399 glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
400 auto mon = glfwGetPrimaryMonitor();
401 auto mod = glfwGetVideoMode(mon);
402 w = mod->width;
403 h = mod->height;
404 }
405 else if (desc.mode == WindowMode::Minimized)
406 {
407 // Start with window being invisible
408 glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
409 glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
410 glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
411 }
412
413 if (desc.resizableWindow == false)
414 {
415 glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
416 }
417
418 mpGLFWWindow = glfwCreateWindow(w, h, desc.title.c_str(), nullptr, nullptr);
419 if (!mpGLFWWindow)
420 {
421 FALCOR_THROW("Failed to create GLFW window.");
422 }
423
424 // Init handles
425#if FALCOR_WINDOWS
426 mApiHandle = glfwGetWin32Window(mpGLFWWindow);
427 FALCOR_ASSERT(mApiHandle);
428#elif FALCOR_LINUX
429 mApiHandle.pDisplay = glfwGetX11Display();
430 mApiHandle.window = glfwGetX11Window(mpGLFWWindow);
431 FALCOR_ASSERT(mApiHandle.pDisplay != nullptr);
432#endif
433 updateWindowSize();
434
435 glfwSetWindowUserPointer(mpGLFWWindow, this);
436

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected