Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Hardware/Video/OpenGL/GLFWWrapper.cpp

Diff revisions: vs.
  @@ -62,8 +62,12 @@
62 62 glfwWindowHint(GLFW_DEPTH_BITS, 24);
63 63
64 64 // Open an OpenGL window; resolution and windowed mode is specified in the external XML files
65 - GLUtil::_mainWindow = glfwCreateWindow(resolution.width, resolution.height, par.getParam<stringImpl>("appTitle", "Divide").c_str(),
66 - par.getParam<bool>("runtime.windowedMode", true) ? nullptr : glfwGetPrimaryMonitor(), nullptr);
65 + GLUtil::_mainWindow = glfwCreateWindow(resolution.width,
66 + resolution.height,
67 + par.getParam<stringImpl>("appTitle", "Divide").c_str(),
68 + par.getParam<bool>("runtime.windowedMode", true) ? nullptr :
69 + glfwGetPrimaryMonitor(),
70 + nullptr);
67 71 // Check if we have a valid window
68 72 if (!GLUtil::_mainWindow) {
69 73 glfwTerminate();
  @@ -78,13 +82,16 @@
78 82 glfwSetWindowCloseCallback(GLUtil::_mainWindow, GLUtil::glfw_close_callback);
79 83 // Bind our focus change callback to GLFW's internal wiring
80 84 glfwSetWindowFocusCallback(GLUtil::_mainWindow, GLUtil::glfw_focus_callback);
81 - // Geometry shaders became core in version 3.3, shader storage buffers in 4.3, buffer storage in 4.4 so fail if we are missing the required version
82 - if ((Config::Profile::DISABLE_PERSISTENT_BUFFER && !GLEW_VERSION_4_3) || (!Config::Profile::DISABLE_PERSISTENT_BUFFER && !GLEW_VERSION_4_4)) {
85 + // Geometry shaders became core in version 3.3, shader storage buffers in 4.3,
86 + // buffer storage in 4.4 so fail if we are missing the required version
87 + if ((Config::Profile::DISABLE_PERSISTENT_BUFFER && !GLEW_VERSION_4_3) ||
88 + (!Config::Profile::DISABLE_PERSISTENT_BUFFER && !GLEW_VERSION_4_4)) {
83 89 ERROR_FN(Locale::get("ERROR_GFX_DEVICE"), Locale::get("ERROR_GL_OLD_VERSION"));
84 90 return GLEW_OLD_HARDWARE;
85 91 }
86 92
87 - // We also create a loader thread in the background with its own GL context. To do this with GLFW, we'll create a second, invisible, window
93 + // We also create a loader thread in the background with its own GL context.
94 + // To do this with GLFW, we'll create a second, invisible, window
88 95 glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
89 96 // The loader window will share context lists with the main window
90 97 GLUtil::_loaderWindow = glfwCreateWindow(1, 1, "divide-res-loader", nullptr, GLUtil::_mainWindow);
  @@ -97,7 +104,9 @@
97 104 // Get the current display mode used by the focused monitor
98 105 const GLFWvidmode* return_struct = glfwGetVideoMode(glfwGetPrimaryMonitor());
99 106 // Attempt to position the window in the center of the screen. Useful for the splash screen
100 - glfwSetWindowPos(GLUtil::_mainWindow, (return_struct->width - resolution.width) * 0.5f, (return_struct->height - resolution.height) * 0.5f);
107 + glfwSetWindowPos(GLUtil::_mainWindow,
108 + (return_struct->width - resolution.width) * 0.5f,
109 + (return_struct->height - resolution.height) * 0.5f);
101 110
102 111 // OpenGL has a nifty error callback system, available in every build configuration if required
103 112 #if defined(_DEBUG) || defined(_PROFILE) || defined(_GLDEBUG_IN_RELEASE)
  @@ -144,7 +153,14 @@
144 153 ERROR_FN(Locale::get("ERROR_GFX_DEVICE"), Locale::get("ERROR_GL_OLD_VERSION"));
145 154 return GLEW_OLD_HARDWARE;
146 155 } else {
147 - PRINT_FN( Locale::get( "GL_MAX_VERSION" ), 4, /*GLEW_VERSION_4_5 ? 5 : */GLEW_VERSION_4_4 ? 4 : GLEW_VERSION_4_3 ? 3 : GLEW_VERSION_4_2 ? 2 : GLEW_VERSION_4_1 ? 1 : 0 );
156 + PRINT_FN(Locale::get( "GL_MAX_VERSION" ),
157 + 4,
158 + /*GLEW_VERSION_4_5 ? 5 :*/
159 + GLEW_VERSION_4_4 ? 4 :
160 + GLEW_VERSION_4_3 ? 3 :
161 + GLEW_VERSION_4_2 ? 2 :
162 + GLEW_VERSION_4_1 ? 1 :
163 + 0 );
148 164 }
149 165
150 166 // Number of sample buffers associated with the framebuffer & MSAA sample count
  @@ -167,7 +183,8 @@
167 183 // How many attributes can we send to a vertex shader
168 184 PRINT_FN(Locale::get("GL_MAX_VERT_ATTRIB"),GLUtil::getIntegerv(GL_MAX_VERTEX_ATTRIBS));
169 185 // Maximum number of texture units we can address in shaders
170 - PRINT_FN(Locale::get("GL_MAX_TEX_UNITS"), GLUtil::getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS), par.getParam<I32>("rendering.maxTextureSlots", 16));
186 + PRINT_FN(Locale::get("GL_MAX_TEX_UNITS"), GLUtil::getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS),
187 + par.getParam<I32>("rendering.maxTextureSlots", 16));
171 188 // Query shading language version support
172 189 PRINT_FN(Locale::get("GL_GLSL_SUPPORT"), glGetString(GL_SHADING_LANGUAGE_VERSION));
173 190 // GPU info, including vendor, gpu and driver
  @@ -179,7 +196,8 @@
179 196 GLUtil::getIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE) / 1024,
180 197 GLUtil::getIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT));
181 198
182 - // In order: Maximum number of shader storage buffer binding points, maximum size in basic machine units of a shader storage block,
199 + // In order: Maximum number of shader storage buffer binding points,
200 + // maximum size in basic machine units of a shader storage block,
183 201 // maximum total number of active shader storage blocks that may be accessed by all active shaders and
184 202 // minimum required alignment for shader storage buffer sizes and offset.
185 203 PRINT_FN(Locale::get("GL_SSBO_INFO"), GLUtil::getIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS),
  @@ -188,7 +206,9 @@
188 206 GLUtil::getIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT));
189 207
190 208 // Maximum number of subroutines and maximum number of subroutine uniform locations usable in a shader
191 - PRINT_FN(Locale::get("GL_SUBROUTINE_INFO"), GLUtil::getIntegerv(GL_MAX_SUBROUTINES), GLUtil::getIntegerv(GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS));
209 + PRINT_FN(Locale::get("GL_SUBROUTINE_INFO"),
210 + GLUtil::getIntegerv(GL_MAX_SUBROUTINES),
211 + GLUtil::getIntegerv(GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS));
192 212
193 213 // Set the clear color to the blue color used since the initial OBJ loader days
194 214 GL_API::clearColor(DefaultColors::DIVIDE_BLUE());
  @@ -209,7 +229,8 @@
209 229
210 230 // Culling is enabled by default, but RenderStateBlocks can toggle it on a per-draw call basis
211 231 glEnable(GL_CULL_FACE);
212 - // Primitive restart indexes can either be a predefined short value (_S) or a predefined int value (_L), depending on the index buffer
232 + // Primitive restart indexes can either be a predefined short value (_S) or a predefined int value (_L),
233 + // depending on the index buffer
213 234 glPrimitiveRestartIndex(Config::PRIMITIVE_RESTART_INDEX_S);
214 235 // Vsync is toggled on or off via the external config file
215 236 glfwSwapInterval(par.getParam<bool>("runtime.enableVSync",false) ? 1 : 0);
  @@ -228,7 +249,13 @@
228 249 tempDisplayMode._refreshRate = temp.refreshRate;
229 250 GFX_DEVICE.registerDisplayMode(tempDisplayMode);
230 251 // Optionally, output to console/file each display mode
231 - D_PRINT_FN(Locale::get("CURRENT_DISPLAY_MODE"), temp.width, temp.height, temp.redBits, temp.greenBits, temp.blueBits, temp.refreshRate);
252 + D_PRINT_FN(Locale::get("CURRENT_DISPLAY_MODE"),
253 + temp.width,
254 + temp.height,
255 + temp.redBits,
256 + temp.greenBits,
257 + temp.blueBits,
258 + temp.refreshRate);
232 259 }
233 260
234 261 // Prepare font rendering subsystem
  @@ -247,7 +274,8 @@
247 274 glGenBuffers(1, &_indirectDrawBuffer);
248 275 // In debug, we also have various performance counters to profile GPU rendering operations
249 276 # ifdef _DEBUG
250 - // We have multiple counter buffers, and each can be multi-buffered (currently, only double-buffered, front and back) to avoid pipeline stalls
277 + // We have multiple counter buffers, and each can be multi-buffered (currently, only double-buffered, front and back)
278 + // to avoid pipeline stalls
251 279 for (U8 i = 0; i < PERFORMANCE_COUNTER_BUFFERS; ++i) {
252 280 glGenQueries(PERFORMANCE_COUNTERS, _queryID[i]);
253 281 DIVIDE_ASSERT(_queryID[i][0] != 0, "GLFWWrapper error: Invalid performance counter query ID!");
  @@ -288,10 +316,7 @@
288 316 }
289 317
290 318 // Destroy sampler objects
291 - for (samplerObjectMap::value_type& it : _samplerMap ) {
292 - MemoryManager::SAFE_DELETE( it.second );
293 - }
294 - _samplerMap.clear();
319 + MemoryManager::DELETE_HASHMAP(_samplerMap);
295 320
296 321 // Destroy the text rendering system
297 322 deleteFonsContext();