reintegration complete
This commit is contained in:
56
modules/Archimedes-Modules/TestImgui/TestImgui.cpp
Normal file
56
modules/Archimedes-Modules/TestImgui/TestImgui.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "TestImgui.h"
|
||||
#include "modules/ImguiModule/ImguiModule.h"
|
||||
|
||||
TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
||||
|
||||
name = "TestImgui";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
deps[*im] = im;
|
||||
}
|
||||
|
||||
TestImgui::~TestImgui() {
|
||||
|
||||
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
||||
im->releaseContext(ImGui::GetCurrentContext());
|
||||
}
|
||||
|
||||
void TestImgui::onLoad() {
|
||||
|
||||
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
||||
|
||||
if(!im) {
|
||||
std::cout << "No ImguiModule for TestImgui!\n";
|
||||
std::abort();
|
||||
}
|
||||
|
||||
ImGui::SetCurrentContext(im->aquireContext());
|
||||
|
||||
}
|
||||
|
||||
void TestImgui::run() {
|
||||
if(demo)
|
||||
ImGui::ShowDemoWindow(&this->demo);
|
||||
else
|
||||
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
ImGui::Begin("TestImgui Module"); // Create a window called "Hello, world!" and append into it.
|
||||
|
||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
|
||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
counter++;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", counter);
|
||||
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
24
modules/Archimedes-Modules/TestImgui/TestImgui.h
Normal file
24
modules/Archimedes-Modules/TestImgui/TestImgui.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
class TestImgui : public Archimedes::Module {
|
||||
|
||||
public:
|
||||
TestImgui(Archimedes::App*, void*);
|
||||
|
||||
TestImgui() { name = "TestImgui"; }
|
||||
|
||||
~TestImgui();
|
||||
|
||||
void onLoad();
|
||||
|
||||
void run();
|
||||
|
||||
|
||||
private:
|
||||
bool demo = true;
|
||||
};
|
||||
|
||||
#ifdef TESTIMGUI_DYNAMIC
|
||||
typedef TestImgui mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
Reference in New Issue
Block a user