Re-enable multiviewport
Also fixes a bunch of stuff to make multiviewport way more stable
This commit is contained in:
parent
f3f6a219f6
commit
77c9561868
5 changed files with 28 additions and 18 deletions
|
@ -77,6 +77,8 @@ public:
|
|||
*/
|
||||
void render(const int index);
|
||||
|
||||
void end_frame();
|
||||
|
||||
/// Pause updating.
|
||||
void pause();
|
||||
|
||||
|
@ -344,12 +346,12 @@ private:
|
|||
RenderTarget* render_target;
|
||||
};
|
||||
|
||||
std::vector<Window> _windows;
|
||||
std::vector<std::unique_ptr<Window>> _windows;
|
||||
|
||||
Window* get_window(const int identifier) {
|
||||
for(auto& window : _windows) {
|
||||
if(window.identifier == identifier)
|
||||
return &window;
|
||||
if(window->identifier == identifier)
|
||||
return window.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
@ -84,11 +84,11 @@ bool Engine::is_paused() const {
|
|||
}
|
||||
|
||||
void Engine::quit() {
|
||||
_windows[0].quitRequested = true;
|
||||
_windows[0]->quitRequested = true;
|
||||
}
|
||||
|
||||
bool Engine::is_quitting() const {
|
||||
return _windows[0].quitRequested;
|
||||
return _windows[0]->quitRequested;
|
||||
}
|
||||
|
||||
void Engine::prepare_quit() {
|
||||
|
@ -193,7 +193,7 @@ ui::Screen* Engine::load_screen(const file::Path path) {
|
|||
void Engine::set_screen(ui::Screen* screen) {
|
||||
_current_screen = screen;
|
||||
|
||||
screen->extent = _windows[0].extent;
|
||||
screen->extent = _windows[0]->extent;
|
||||
screen->calculate_sizes();
|
||||
|
||||
get_renderer()->set_screen(screen);
|
||||
|
@ -414,10 +414,12 @@ void Engine::add_window(void* native_handle, const int identifier, const prism::
|
|||
|
||||
_gfx->initialize_view(native_handle, identifier, drawable_extent.width, drawable_extent.height);
|
||||
|
||||
Window& window = _windows.emplace_back();
|
||||
window.identifier = identifier;
|
||||
window.extent = extent;
|
||||
window.render_target = _renderer->allocate_render_target(drawable_extent);
|
||||
_windows.push_back(std::move(std::make_unique<Window>()));
|
||||
|
||||
Window* window = _windows.back().get();
|
||||
window->identifier = identifier;
|
||||
window->extent = extent;
|
||||
window->render_target = _renderer->allocate_render_target(drawable_extent);
|
||||
|
||||
render_ready = true;
|
||||
}
|
||||
|
@ -425,8 +427,8 @@ void Engine::add_window(void* native_handle, const int identifier, const prism::
|
|||
void Engine::remove_window(const int identifier) {
|
||||
Expects(identifier >= 0);
|
||||
|
||||
utility::erase_if(_windows, [identifier](Window& w) {
|
||||
return w.identifier == identifier;
|
||||
utility::erase_if(_windows, [identifier](std::unique_ptr<Window>& w) {
|
||||
return w->identifier == identifier;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -658,6 +660,10 @@ void Engine::begin_frame(const float delta_time) {
|
|||
_app->begin_frame();
|
||||
}
|
||||
|
||||
void Engine::end_frame() {
|
||||
ImGui::UpdatePlatformWindows();
|
||||
}
|
||||
|
||||
int frame_delay = 0;
|
||||
const int frame_delay_between_resolution_change = 60;
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ ImGuiLayer::ImGuiLayer() {
|
|||
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports;
|
||||
io.BackendPlatformName = "Prism";
|
||||
|
||||
//if(platform::supports_feature(PlatformFeature::Windowing))
|
||||
// io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
if(platform::supports_feature(PlatformFeature::Windowing))
|
||||
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
|
||||
for (auto& [im, pl] : imToPl)
|
||||
io.KeyMap[im] = platform::get_keycode(pl);
|
||||
|
@ -196,8 +196,6 @@ void ImGuiLayer::render(int index) {
|
|||
if(index == 0) {
|
||||
ImGui::EndFrame();
|
||||
ImGui::Render();
|
||||
|
||||
ImGui::UpdatePlatformWindows();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,11 @@ void ImGuiPass::render_post(GFXCommandBuffer* command_buffer, const int index) {
|
|||
} else {
|
||||
auto& io = ImGui::GetPlatformIO();
|
||||
for(int i = 1; i < io.Viewports.size(); i++) {
|
||||
if((io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0)
|
||||
if(*(int*)io.Viewports[i]->PlatformHandle == index)
|
||||
if((io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0) {
|
||||
auto platform_handle = (int*)io.Viewports[i]->PlatformHandle;
|
||||
if(platform_handle != nullptr && *platform_handle == index)
|
||||
draw_data = io.Viewports[i]->DrawData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -616,6 +616,8 @@ int main(int argc, char* argv[]) {
|
|||
[window->delegate render];
|
||||
}
|
||||
|
||||
engine->end_frame();
|
||||
|
||||
scrollX = 0.0f;
|
||||
scrollY = 0.0f;
|
||||
|
||||
|
|
Reference in a new issue