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')
|
public_dir = env.Dir('public')
|
||||||
env.Append(CPPPATH = [public_dir])
|
env.Append(CPPPATH = [public_dir])
|
||||||
|
if env['BUILD_TYPE'] == 'release':
|
||||||
|
cppdefines += ['RAID_RELEASE=1']
|
||||||
env = env.Module('private/raid/SModule')
|
env = env.Module('private/raid/SModule')
|
||||||
|
|
||||||
LIB_CONFIG = {
|
LIB_CONFIG = {
|
||||||
|
@ -136,8 +136,9 @@ int Application::run(int argc, char** argv)
|
|||||||
ImGui_ImplSDL3_NewFrame();
|
ImGui_ImplSDL3_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
ImGui::SetNextWindowPos({0, 0});
|
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Pos);
|
||||||
ImGui::SetNextWindowSize(imguiIO.DisplaySize);
|
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size);
|
||||||
|
ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
|
||||||
|
|
||||||
ImGui::Begin("##main", nullptr, mMainWindowFlags);
|
ImGui::Begin("##main", nullptr, mMainWindowFlags);
|
||||||
render();
|
render();
|
||||||
@ -149,6 +150,13 @@ int Application::run(int argc, char** argv)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
if (imguiIO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
SDL_GL_MakeCurrent(mWindow, mGLContext);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(mWindow);
|
SDL_GL_SwapWindow(mWindow);
|
||||||
|
|
||||||
if (imguiIO.WantSaveIniSettings)
|
if (imguiIO.WantSaveIniSettings)
|
||||||
@ -190,6 +198,15 @@ bool Application::loadFont(const fs::path& path)
|
|||||||
return true;
|
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)
|
void Application::handleMessage(const Message& message)
|
||||||
{
|
{
|
||||||
switch (message.severity)
|
switch (message.severity)
|
||||||
@ -242,7 +259,7 @@ bool Application::initSDL()
|
|||||||
| SDL_WINDOW_RESIZABLE
|
| SDL_WINDOW_RESIZABLE
|
||||||
| SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
| SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
mWindow = SDL_CreateWindow(
|
mWindow = SDL_CreateWindow(
|
||||||
/* title = */ "RAID",
|
/* title = */ getWindowTitle().c_str(),
|
||||||
/* w = */ 1280,
|
/* w = */ 1280,
|
||||||
/* h = */ 720,
|
/* h = */ 720,
|
||||||
/* flags = */ WINDOW_FLAGS
|
/* flags = */ WINDOW_FLAGS
|
||||||
@ -279,9 +296,9 @@ bool Application::initImGui()
|
|||||||
|
|
||||||
loadImGuiConfig();
|
loadImGuiConfig();
|
||||||
|
|
||||||
|
configureImgui();
|
||||||
|
|
||||||
ImGuiIO& imguiIO = ImGui::GetIO();
|
ImGuiIO& imguiIO = ImGui::GetIO();
|
||||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
|
||||||
imguiIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
|
||||||
imguiIO.IniFilename = nullptr; // disable automatic saving of settings
|
imguiIO.IniFilename = nullptr; // disable automatic saving of settings
|
||||||
|
|
||||||
// default style
|
// default style
|
||||||
@ -389,6 +406,7 @@ void QuickApp::init(QuickAppOptions options)
|
|||||||
MIJIN_ASSERT_FATAL(options.callbacks.render, "Missing render callback.");
|
MIJIN_ASSERT_FATAL(options.callbacks.render, "Missing render callback.");
|
||||||
mRenderCallback = std::move(options.callbacks.render);
|
mRenderCallback = std::move(options.callbacks.render);
|
||||||
mFolderName = std::move(options.folderName);
|
mFolderName = std::move(options.folderName);
|
||||||
|
mWindowTitle = std::move(options.windowTitle);
|
||||||
setMainWindowFlags(options.mainWindowFlags);
|
setMainWindowFlags(options.mainWindowFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,6 +426,11 @@ std::string QuickApp::getFolderName()
|
|||||||
return mFolderName;
|
return mFolderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string QuickApp::getWindowTitle()
|
||||||
|
{
|
||||||
|
return mWindowTitle;
|
||||||
|
}
|
||||||
|
|
||||||
int runQuick(int argc, char* argv[], QuickAppOptions options)
|
int runQuick(int argc, char* argv[], QuickAppOptions options)
|
||||||
{
|
{
|
||||||
QuickApp app;
|
QuickApp app;
|
||||||
|
@ -34,6 +34,7 @@ int main(int argc, char* argv[])
|
|||||||
.render = &render
|
.render = &render
|
||||||
},
|
},
|
||||||
.folderName = "raid_test_app",
|
.folderName = "raid_test_app",
|
||||||
|
.windowTitle = "RAID Test App",
|
||||||
.mainWindowFlags = raid::DEFAULT_MAIN_WINDOW_FLAGS | ImGuiWindowFlags_MenuBar
|
.mainWindowFlags = raid::DEFAULT_MAIN_WINDOW_FLAGS | ImGuiWindowFlags_MenuBar
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
virtual std::string getFolderName() = 0;
|
virtual std::string getFolderName() = 0;
|
||||||
|
virtual std::string getWindowTitle() = 0;
|
||||||
|
virtual void configureImgui();
|
||||||
virtual void handleMessage(const Message& message);
|
virtual void handleMessage(const Message& message);
|
||||||
virtual void handleSDLEvent(const SDL_Event& event);
|
virtual void handleSDLEvent(const SDL_Event& event);
|
||||||
|
|
||||||
@ -139,6 +141,7 @@ struct QuickAppOptions
|
|||||||
render_cb_t render;
|
render_cb_t render;
|
||||||
} callbacks;
|
} callbacks;
|
||||||
std::string folderName = "raid";
|
std::string folderName = "raid";
|
||||||
|
std::string windowTitle = "RAID";
|
||||||
ImGuiWindowFlags mainWindowFlags = DEFAULT_MAIN_WINDOW_FLAGS;
|
ImGuiWindowFlags mainWindowFlags = DEFAULT_MAIN_WINDOW_FLAGS;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,10 +150,12 @@ class QuickApp : public Application
|
|||||||
private:
|
private:
|
||||||
render_cb_t mRenderCallback;
|
render_cb_t mRenderCallback;
|
||||||
std::string mFolderName;
|
std::string mFolderName;
|
||||||
|
std::string mWindowTitle;
|
||||||
public:
|
public:
|
||||||
void init(QuickAppOptions options);
|
void init(QuickAppOptions options);
|
||||||
void render() override;
|
void render() override;
|
||||||
std::string getFolderName() override;
|
std::string getFolderName() override;
|
||||||
|
std::string getWindowTitle() override;
|
||||||
|
|
||||||
static QuickApp& get();
|
static QuickApp& get();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user