From 8dbd991652d5d881c9bc6e5c4b70ac68cc6f9735 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 22 Jul 2015 10:54:40 -0700 Subject: [PATCH] USing a modern singleton guard --- libraries/gpu/src/gpu/GLBackend.cpp | 9 ++++----- libraries/gpu/src/gpu/GLBackend.h | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 0a6f3a423d..721be0f402 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -8,14 +8,13 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include "GPULogging.h" #include "GLBackendShared.h" #include using namespace gpu; -bool GLBackend::_initialized = false; - GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = { (&::gpu::GLBackend::do_draw), @@ -91,7 +90,8 @@ GLBackend::GLBackend() : _pipeline(), _output() { - if (!_initialized) { + static std::once_flag once; + std::call_once(once, [] { qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); @@ -118,8 +118,7 @@ GLBackend::GLBackend() : qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); }*/ #endif - _initialized = true; - } + }); initInput(); initTransform(); diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index b4906b4ac7..b3e905bf21 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -447,8 +447,6 @@ protected: typedef void (GLBackend::*CommandCall)(Batch&, uint32); static CommandCall _commandCalls[Batch::NUM_COMMANDS]; - - static bool _initialized; };