Moved global resource creation to startup instead of context creation. Fixes #645.

This commit is contained in:
Leonardo Zide
2021-03-10 21:22:41 -08:00
parent 44d0e92b50
commit 233affe3fc
9 changed files with 79 additions and 86 deletions
+7 -17
View File
@@ -52,6 +52,7 @@ lcPiecesLibrary::~lcPiecesLibrary()
mCancelLoading = true;
WaitForLoadQueue();
Unload();
ReleaseBuffers();
}
void lcPiecesLibrary::Unload()
@@ -1427,10 +1428,14 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
}
}
void lcPiecesLibrary::ReleaseBuffers(lcContext* Context)
void lcPiecesLibrary::ReleaseBuffers()
{
lcContext* Context = lcContext::GetGlobalOffscreenContext();
Context->MakeCurrent();
Context->DestroyVertexBuffer(mVertexBuffer);
Context->DestroyIndexBuffer(mIndexBuffer);
mBuffersDirty = true;
}
@@ -1506,6 +1511,7 @@ void lcPiecesLibrary::UnloadUnusedParts()
bool lcPiecesLibrary::LoadTexture(lcTexture* Texture)
{
QMutexLocker Lock(&mTextureMutex);
char FileName[2*LC_MAXPATH];
if (mZipFiles[static_cast<int>(lcZipFileType::Official)])
@@ -1541,22 +1547,6 @@ void lcPiecesLibrary::ReleaseTexture(lcTexture* Texture)
}
}
void lcPiecesLibrary::QueueTextureUpload(lcTexture* Texture)
{
QMutexLocker Lock(&mTextureMutex);
mTextureUploads.push_back(Texture);
}
void lcPiecesLibrary::UploadTextures(lcContext* Context)
{
QMutexLocker Lock(&mTextureMutex);
for (lcTexture* Texture : mTextureUploads)
Texture->Upload(Context);
mTextureUploads.clear();
}
bool lcPiecesLibrary::SupportsStudStyle() const
{
return true;