Enabled viewports.
This commit is contained in:
@@ -136,8 +136,9 @@ int Application::run(int argc, char** argv)
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::SetNextWindowPos({0, 0});
|
||||
ImGui::SetNextWindowSize(imguiIO.DisplaySize);
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Pos);
|
||||
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size);
|
||||
ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
|
||||
|
||||
ImGui::Begin("##main", nullptr, mMainWindowFlags);
|
||||
render();
|
||||
@@ -149,6 +150,13 @@ int Application::run(int argc, char** argv)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
if (imguiIO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
SDL_GL_MakeCurrent(mWindow, mGLContext);
|
||||
}
|
||||
|
||||
SDL_GL_SwapWindow(mWindow);
|
||||
|
||||
if (imguiIO.WantSaveIniSettings)
|
||||
@@ -190,6 +198,15 @@ bool Application::loadFont(const fs::path& path)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Application::configureImgui()
|
||||
{
|
||||
ImGuiIO& imguiIO = ImGui::GetIO();
|
||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
imguiIO.ConfigViewportsNoAutoMerge = true;
|
||||
}
|
||||
|
||||
void Application::handleMessage(const Message& message)
|
||||
{
|
||||
switch (message.severity)
|
||||
@@ -242,7 +259,7 @@ bool Application::initSDL()
|
||||
| SDL_WINDOW_RESIZABLE
|
||||
| SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
mWindow = SDL_CreateWindow(
|
||||
/* title = */ "RAID",
|
||||
/* title = */ getWindowTitle().c_str(),
|
||||
/* w = */ 1280,
|
||||
/* h = */ 720,
|
||||
/* flags = */ WINDOW_FLAGS
|
||||
@@ -279,9 +296,9 @@ bool Application::initImGui()
|
||||
|
||||
loadImGuiConfig();
|
||||
|
||||
configureImgui();
|
||||
|
||||
ImGuiIO& imguiIO = ImGui::GetIO();
|
||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||
imguiIO.IniFilename = nullptr; // disable automatic saving of settings
|
||||
|
||||
// default style
|
||||
@@ -389,6 +406,7 @@ void QuickApp::init(QuickAppOptions options)
|
||||
MIJIN_ASSERT_FATAL(options.callbacks.render, "Missing render callback.");
|
||||
mRenderCallback = std::move(options.callbacks.render);
|
||||
mFolderName = std::move(options.folderName);
|
||||
mWindowTitle = std::move(options.windowTitle);
|
||||
setMainWindowFlags(options.mainWindowFlags);
|
||||
}
|
||||
|
||||
@@ -408,6 +426,11 @@ std::string QuickApp::getFolderName()
|
||||
return mFolderName;
|
||||
}
|
||||
|
||||
std::string QuickApp::getWindowTitle()
|
||||
{
|
||||
return mWindowTitle;
|
||||
}
|
||||
|
||||
int runQuick(int argc, char* argv[], QuickAppOptions options)
|
||||
{
|
||||
QuickApp app;
|
||||
|
||||
@@ -34,6 +34,7 @@ int main(int argc, char* argv[])
|
||||
.render = &render
|
||||
},
|
||||
.folderName = "raid_test_app",
|
||||
.windowTitle = "RAID Test App",
|
||||
.mainWindowFlags = raid::DEFAULT_MAIN_WINDOW_FLAGS | ImGuiWindowFlags_MenuBar
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user