Protected some functions of graphics with the init_mutex.
This commit is contained in:
parent
b52bef795a
commit
96a8943cb7
@ -259,6 +259,7 @@ Graphics& Graphics::operator= (Graphics &&other) {
|
|||||||
|
|
||||||
|
|
||||||
void Graphics::init(Level* level) {
|
void Graphics::init(Level* level) {
|
||||||
|
std::lock_guard<std::mutex> lock(init_mutex);
|
||||||
// save Level
|
// save Level
|
||||||
this->level = level;
|
this->level = level;
|
||||||
|
|
||||||
@ -473,6 +474,7 @@ void Graphics::bindTextureUnits(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::renderLoadingScreen() {
|
void Graphics::renderLoadingScreen() {
|
||||||
|
std::lock_guard<std::mutex> lock(init_mutex);
|
||||||
loadingScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenPath));
|
loadingScreen = Texture2DFileManager::the()->get(Texture2DCreator(loadingScreenPath));
|
||||||
loadingScreen->generateMipmaps();
|
loadingScreen->generateMipmaps();
|
||||||
loadingScreen->setMinFilter(GL_NEAREST_MIPMAP_LINEAR);
|
loadingScreen->setMinFilter(GL_NEAREST_MIPMAP_LINEAR);
|
||||||
@ -538,6 +540,7 @@ glm::uvec2 Graphics::getWindowSize() {
|
|||||||
void Graphics::render(double time)
|
void Graphics::render(double time)
|
||||||
{
|
{
|
||||||
if (!gameStart) {
|
if (!gameStart) {
|
||||||
|
std::lock_guard<std::mutex> lock(init_mutex);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
loadingShader->use();
|
loadingShader->use();
|
||||||
@ -851,6 +854,7 @@ void Graphics::updateLights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::resize(glm::uvec2 windowSize) {
|
void Graphics::resize(glm::uvec2 windowSize) {
|
||||||
|
std::lock_guard<std::mutex> lock(init_mutex);
|
||||||
this->windowSize = windowSize;
|
this->windowSize = windowSize;
|
||||||
if (gameStart) {
|
if (gameStart) {
|
||||||
for (unsigned int i = 0; i<depth_directionalMaps.size(); i++) {
|
for (unsigned int i = 0; i<depth_directionalMaps.size(); i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user