TestImgui
This commit is contained in:
@@ -6,9 +6,14 @@
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
TestImgui::TestImgui(void* h, Archimedes::App* a) : Archimedes::GuiModule(h, a) {
|
||||
#include "modules/ImguiModule/src/ImguiModule.h"
|
||||
|
||||
TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::GuiModule(a, h) {
|
||||
|
||||
name = "TestImgui";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a);
|
||||
deps[im->getName()] = im;
|
||||
}
|
||||
|
||||
TestImgui::~TestImgui() {
|
||||
@@ -17,21 +22,15 @@ TestImgui::~TestImgui() {
|
||||
|
||||
void TestImgui::onLoad() {
|
||||
|
||||
WindowModule* wm = (WindowModule*) depsInstances["WindowModule"];
|
||||
WindowModule* wm = (WindowModule*) moduleInstances["WindowModule"];
|
||||
|
||||
if(!wm) {
|
||||
std::cout << "No WindowModule for TestImgui!\n";
|
||||
std::abort();
|
||||
}
|
||||
|
||||
wm->getLayerstack()->push(&layer);
|
||||
}
|
||||
|
||||
void TestImgui::run() {
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
if(demo)
|
||||
ImGui::ShowDemoWindow(&this->demo);
|
||||
else
|
||||
@@ -56,56 +55,4 @@ void TestImgui::run() {
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
|
||||
TestImgui::TILayer::~TILayer() {}
|
||||
|
||||
void TestImgui::TILayer::onAttach() {
|
||||
WindowModule* wm = (WindowModule*) ti->depsInstances["WindowModule"];
|
||||
|
||||
if(!wm) {
|
||||
std::cout << "No WindowModule for TestImgui!\n";
|
||||
std::abort();
|
||||
}
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsLight();
|
||||
|
||||
// Setup Platform/Renderer backends
|
||||
if(!ImGui_ImplGlfw_InitForOpenGL(wm->getWindow()->getWindowImpl().getWindow(), true))
|
||||
std::cout << "GLFWImpl failed\n";
|
||||
if(!ImGui_ImplOpenGL3_Init("#version 330")) {
|
||||
std::cout << "ImGui_ImplOpenGL3_Init failed!\n" << std::endl;
|
||||
}
|
||||
|
||||
//Compute first frame ahead of first WindowModule->run()
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
void TestImgui::TILayer::onRender() {
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
void TestImgui::TILayer::onDetach() {
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
bool TestImgui::TILayer::onEvent(const Archimedes::Event&) { return false; }
|
||||
|
||||
Reference in New Issue
Block a user