Finalize the loadingscreen before initializing GL part of the scene

Correctly use screen aspect ratio to render the loading screen box
This commit is contained in:
Alexander Bock
2017-11-09 12:47:28 -05:00
parent 5f391de33c
commit 0015cbb6f6
3 changed files with 54 additions and 27 deletions
@@ -60,6 +60,8 @@ public:
void postMessage(std::string message);
void finalize();
void setItemNumber(int nItems);
void tickItem();
+3 -2
View File
@@ -678,10 +678,11 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
while (!initializeFinished) {
_loadingScreen->render();
}
_windowWrapper->swapBuffer();
_loadingScreen->postMessage("Initializing OpenGL");
_loadingScreen->finalize();
t.join();
// It's okay to delete it since the last rendered image will remain on screen
_loadingScreen = nullptr;
if (errorWhileLoading) {
+49 -25
View File
@@ -357,46 +357,47 @@ void LoadingScreen::render() {
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(_progressbar.vaoBox);
float w = ProgressbarLineWidth;
float w = ProgressbarLineWidth / screenAspectRatio;
float h = ProgressbarLineWidth;
GLfloat dataBox[] = {
// In order to avoid the deprecated glLineWidth, we split the lines into
// separate triangles instead
// Left side
progressbarLl.x - w , progressbarLl.y - w,
progressbarLl.x + w, progressbarUr.y + w,
progressbarLl.x - w, progressbarUr.y + w,
progressbarLl.x - w , progressbarLl.y - h,
progressbarLl.x + w, progressbarUr.y + h,
progressbarLl.x - w, progressbarUr.y + h,
progressbarLl.x - w , progressbarLl.y - w,
progressbarLl.x + w , progressbarLl.y - w,
progressbarLl.x + w, progressbarUr.y + w,
progressbarLl.x - w , progressbarLl.y - h,
progressbarLl.x + w , progressbarLl.y - h,
progressbarLl.x + w, progressbarUr.y + h,
// Top side
progressbarLl.x - w, progressbarUr.y - w,
progressbarUr.x + w, progressbarUr.y + w,
progressbarLl.x - w, progressbarUr.y + w,
progressbarLl.x - w, progressbarUr.y - h,
progressbarUr.x + w, progressbarUr.y + h,
progressbarLl.x - w, progressbarUr.y + h,
progressbarLl.x - w, progressbarUr.y - w,
progressbarUr.x + w, progressbarUr.y - w,
progressbarUr.x + w, progressbarUr.y + w,
progressbarLl.x - w, progressbarUr.y - h,
progressbarUr.x + w, progressbarUr.y - h,
progressbarUr.x + w, progressbarUr.y + h,
// Right side
progressbarUr.x - w, progressbarLl.y - w,
progressbarUr.x + w, progressbarUr.y + w,
progressbarUr.x - w, progressbarUr.y - w,
progressbarUr.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarUr.y + h,
progressbarUr.x - w, progressbarUr.y - h,
progressbarUr.x - w, progressbarLl.y - w,
progressbarUr.x + w, progressbarLl.y - w,
progressbarUr.x + w, progressbarUr.y + w,
progressbarUr.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y - h,
progressbarUr.x + w, progressbarUr.y + h,
// Bottom side
progressbarLl.x - w, progressbarLl.y - w,
progressbarUr.x + w, progressbarLl.y + w,
progressbarLl.x - w, progressbarLl.y + w,
progressbarLl.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y + h,
progressbarLl.x - w, progressbarLl.y + h,
progressbarLl.x - w, progressbarLl.y - w,
progressbarUr.x + w, progressbarLl.y - w,
progressbarUr.x + w, progressbarLl.y + w,
progressbarLl.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y + h,
};
glBindBuffer(GL_ARRAY_BUFFER, _progressbar.vboBox);
@@ -624,6 +625,29 @@ void LoadingScreen::postMessage(std::string message) {
_message = std::move(message);
}
void LoadingScreen::finalize() {
_items.erase(
std::remove_if(
_items.begin(),
_items.end(),
[](const Item& i) {
return i.status != ItemStatus::Failed;
}
),
_items.end()
);
//for (Item& i : _items) {
// if (i.status != ItemStatus::Failed) {
// i.status = ItemStatus::Finished;
// }
// i.finishedTime = std::chrono::system_clock::now() + TTL;
//}
render();
}
void LoadingScreen::setItemNumber(int nItems) {
_nItems = nItems;
}