From 96a8943cb79e7b2245c898eedeead7b959dc1d35 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sun, 12 Apr 2015 21:56:04 +0200 Subject: [PATCH] Protected some functions of graphics with the init_mutex. --- game/graphics.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game/graphics.cc b/game/graphics.cc index a4b6636..9ea247f 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -259,6 +259,7 @@ Graphics& Graphics::operator= (Graphics &&other) { void Graphics::init(Level* level) { + std::lock_guard lock(init_mutex); // save Level this->level = level; @@ -473,6 +474,7 @@ void Graphics::bindTextureUnits(){ } void Graphics::renderLoadingScreen() { + std::lock_guard lock(init_mutex); loadingScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenPath)); loadingScreen->generateMipmaps(); loadingScreen->setMinFilter(GL_NEAREST_MIPMAP_LINEAR); @@ -538,6 +540,7 @@ glm::uvec2 Graphics::getWindowSize() { void Graphics::render(double time) { if (!gameStart) { + std::lock_guard lock(init_mutex); glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); loadingShader->use(); @@ -851,6 +854,7 @@ void Graphics::updateLights() { } void Graphics::resize(glm::uvec2 windowSize) { + std::lock_guard lock(init_mutex); this->windowSize = windowSize; if (gameStart) { for (unsigned int i = 0; i