Enabled viewports.
This commit is contained in:
parent
7eabd55167
commit
53efca4729
2
SModule
2
SModule
@ -3,6 +3,8 @@ Import('env')
|
||||
|
||||
public_dir = env.Dir('public')
|
||||
env.Append(CPPPATH = [public_dir])
|
||||
if env['BUILD_TYPE'] == 'release':
|
||||
cppdefines += ['RAID_RELEASE=1']
|
||||
env = env.Module('private/raid/SModule')
|
||||
|
||||
LIB_CONFIG = {
|
||||
|
@ -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
|
||||
});
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
protected:
|
||||
virtual void render() = 0;
|
||||
virtual std::string getFolderName() = 0;
|
||||
virtual std::string getWindowTitle() = 0;
|
||||
virtual void configureImgui();
|
||||
virtual void handleMessage(const Message& message);
|
||||
virtual void handleSDLEvent(const SDL_Event& event);
|
||||
|
||||
@ -139,6 +141,7 @@ struct QuickAppOptions
|
||||
render_cb_t render;
|
||||
} callbacks;
|
||||
std::string folderName = "raid";
|
||||
std::string windowTitle = "RAID";
|
||||
ImGuiWindowFlags mainWindowFlags = DEFAULT_MAIN_WINDOW_FLAGS;
|
||||
};
|
||||
|
||||
@ -147,10 +150,12 @@ class QuickApp : public Application
|
||||
private:
|
||||
render_cb_t mRenderCallback;
|
||||
std::string mFolderName;
|
||||
std::string mWindowTitle;
|
||||
public:
|
||||
void init(QuickAppOptions options);
|
||||
void render() override;
|
||||
std::string getFolderName() override;
|
||||
std::string getWindowTitle() override;
|
||||
|
||||
static QuickApp& get();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user