MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / run

Method run

src/engine/PlatformGLFW.cpp:88–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88int32_t PlatformGLFW::run(int argc, char** argv)
89{
90 int width = 1280;
91 int height = 720;
92
93 std::cout << "Initializing GLFW" << std::endl;
94
95 /* Initialize the library */
96 if (!glfwInit())
97 return -1;
98
99 bx::CommandLine cmd(argc, (const char**)argv);
100
101 bool fullscreen = false;
102 if (cmd.hasArg('f'))
103 {
104 fullscreen = true;
105
106 // Get native resolution
107 const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
108 width = mode->width;
109 height = mode->height;
110 }
111
112 GLFWwindow* window;
113
114 /* Create a windowed mode window and its OpenGL context */
115 window = glfwCreateWindow(width, height, "REGoth", fullscreen ? glfwGetPrimaryMonitor() : NULL, NULL);
116 if (!window)
117 {
118 std::cout << "GLFW: Failed to create window!";
119 glfwTerminate();
120 return -1;
121 }
122
123 /* Make the window's context current */
124#if BX_PLATFORM_OSX
125 glfwMakeContextCurrent(window);
126#endif
127
128 // Initialize bgfx
129 glfwSetWindow(window);
130
131 glfwSetCharCallback(window, GLFWCharEvent);
132 glfwSetKeyCallback(window, GLFWkeyEvent);
133 glfwSetMouseButtonCallback(window, GLFWmouseButtonEvent);
134 glfwSetCursorPosCallback(window, GLFWmouseMoveEvent);
135 glfwSetScrollCallback(window, GLFWscrollEvent);
136
137 // window size is in screen units, while framebuffer size is in pixels
138 // we want pixels
139 glfwSetFramebufferSizeCallback(window, GLFWwindowSizeEvent);
140 glfwGetFramebufferSize(window, &width, &height);
141 GLFWwindowSizeEvent(window, width, height);
142
143 setMouseLockCallback([&window](bool lock) {
144 if (lock)
145 glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

Callers

nothing calls this directly

Calls 2

glfwSetWindowFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected