mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-29 04:37:30 +01:00
feat(vulkan): vulkan 1.4 core with the user interface and the launcher, shaders split into ogl46/vk14 with SPIR-V binaries loaded first
This commit is contained in:
@@ -145,16 +145,13 @@ void eu07_application::queue_screenshot()
|
||||
int eu07_application::run_crashgui()
|
||||
{
|
||||
bool autoup = false;
|
||||
bool y{false}, n{false};
|
||||
|
||||
while (!glfwWindowShouldClose(m_windows.front()))
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
// the questions are the ui of the frames the renderer draws (render_ui()), whichever api it is: the window has no opengl
|
||||
// context with vulkan
|
||||
m_crashui = [&]() {
|
||||
ui_layer::begin_ui_frame_internal();
|
||||
|
||||
bool y, n;
|
||||
|
||||
if (Global.asLang == "pl")
|
||||
{
|
||||
ImGui::Begin("Raportowanie błędów", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize);
|
||||
@@ -201,22 +198,35 @@ int eu07_application::run_crashgui()
|
||||
}
|
||||
|
||||
ui_layer::render_internal();
|
||||
glfwSwapBuffers(m_windows.front());
|
||||
};
|
||||
|
||||
while (!glfwWindowShouldClose(m_windows.front()))
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
y = false;
|
||||
n = false;
|
||||
if (!GfxRenderer->Render())
|
||||
break;
|
||||
GfxRenderer->SwapBuffers();
|
||||
|
||||
if (y)
|
||||
{
|
||||
crashreport_upload_accept();
|
||||
if (autoup)
|
||||
crashreport_set_autoupload();
|
||||
m_crashui = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (n)
|
||||
{
|
||||
crashreport_upload_reject();
|
||||
m_crashui = nullptr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
m_crashui = nullptr;
|
||||
return -1;
|
||||
}
|
||||
#if WITH_DISCORD_RPC
|
||||
@@ -382,15 +392,6 @@ int eu07_application::init(int Argc, char *Argv[])
|
||||
return result;
|
||||
}
|
||||
|
||||
if (crashreport_is_pending())
|
||||
{ // run crashgui as early as possible
|
||||
if ((result = run_crashgui()) != 0)
|
||||
{
|
||||
ErrorLog("Failed to run crash gui!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if ((result = init_locale()) != 0)
|
||||
{
|
||||
ErrorLog("Failed to initialize locales! Maybe you're missing lang directory?");
|
||||
@@ -408,6 +409,14 @@ int eu07_application::init(int Argc, char *Argv[])
|
||||
ErrorLog("Failed to init UI!");
|
||||
return result;
|
||||
}
|
||||
if (crashreport_is_pending())
|
||||
{ // run crashgui as early as possible: it's drawn by the renderer
|
||||
if ((result = run_crashgui()) != 0)
|
||||
{
|
||||
ErrorLog("Failed to run crash gui!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if ((result = init_audio()) != 0)
|
||||
{
|
||||
ErrorLog("Failed to initialize OpenAL");
|
||||
@@ -632,7 +641,6 @@ int eu07_application::run()
|
||||
Timer::subsystem.loop_tasks.start();
|
||||
m_taskqueue.update();
|
||||
Timer::subsystem.loop_tasks.stop();
|
||||
opengl_texture::reset_unit_cache();
|
||||
|
||||
if (!GfxRenderer->Render())
|
||||
break;
|
||||
@@ -747,6 +755,11 @@ void eu07_application::exit()
|
||||
|
||||
void eu07_application::render_ui()
|
||||
{
|
||||
if (m_crashui)
|
||||
{
|
||||
m_crashui();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_modestack.empty())
|
||||
{
|
||||
|
||||
@@ -123,6 +123,8 @@ private:
|
||||
// members
|
||||
|
||||
bool m_screenshot_queued = false;
|
||||
// the ui of the crash gui, drawn in the frames of the renderer instead of the ui of the modes while it's there
|
||||
std::function<void()> m_crashui;
|
||||
|
||||
modeptr_array m_modes { nullptr }; // collection of available application behaviour modes
|
||||
mode_stack m_modestack; // current behaviour mode
|
||||
|
||||
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "application/scenarioloaderuilayer.h"
|
||||
|
||||
#include "utilities/Globals.h"
|
||||
#include "rendering/renderer.h"
|
||||
#include "utilities/translation.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "utilities/Logs.h"
|
||||
@@ -309,18 +310,13 @@ void scenarioloader_ui::generate_gradient_tex()
|
||||
image_data[(y * image_width + x) * 4 + 3] = std::clamp(static_cast<int>(pow(y / 1023.f, 0.7) * 255), 0, 255);
|
||||
}
|
||||
|
||||
// Create a OpenGL texture identifier
|
||||
GLuint image_texture;
|
||||
glGenTextures(1, &image_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, image_texture);
|
||||
|
||||
// Setup filtering parameters for display
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
// Upload pixels into texture
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
|
||||
// an image of the user interface: the values as they are (not srgb), the nearest texel
|
||||
imgui_renderer::image_options options;
|
||||
options.srgb = false;
|
||||
options.nearest = true;
|
||||
std::uint64_t image_texture{0};
|
||||
if (auto *renderer{GfxRenderer->GetImguiRenderer()})
|
||||
image_texture = renderer->Create_Image(reinterpret_cast<std::uint8_t const *>(image_data), image_width, image_height, options);
|
||||
|
||||
delete[] image_data;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
class scenarioloader_ui : public ui_layer {
|
||||
int m_gradient_overlay_width;
|
||||
int m_gradient_overlay_height;
|
||||
GLuint m_gradient_overlay_tex;
|
||||
std::uint64_t m_gradient_overlay_tex; // imgui_renderer image
|
||||
deferred_image m_loading_wheel_frames[60];
|
||||
std::vector<std::string> m_trivia;
|
||||
public:
|
||||
|
||||
@@ -421,7 +421,11 @@ void ui_layer::shutdown()
|
||||
{
|
||||
ImGui::EndFrame();
|
||||
|
||||
GfxRenderer->GetImguiRenderer()->Shutdown();
|
||||
// the vulkan renderer is gone by now (its backend of imgui went with it)
|
||||
if (auto *renderer{GfxRenderer->GetImguiRenderer()})
|
||||
{
|
||||
renderer->Shutdown();
|
||||
}
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user