restructure modules

This commit is contained in:
2025-03-31 10:14:18 -05:00
parent 7841f04a35
commit d6f769d2dd
13 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
#include "DependsOnPrint.h"
DependsOnPrint::DependsOnPrint(void* h, Archimedes::App* a) : Module(h, a) {
name = "DependsOnPrint";
deps["Print"] = "/home/nathan/Projects/Archimedes/result-1/bin/Print";
}
DependsOnPrint::~DependsOnPrint() {
std::cout << "DependsOnPrint Destroyed!\n";
}
void DependsOnPrint::run() {
std::cout << "DependsOnPrint lib loaded and run!\n";
app->stopModule(self);
}

View File

@@ -0,0 +1,16 @@
#include "Archimedes.h"
class DependsOnPrint : public Archimedes::Module {
public:
DependsOnPrint(void*, Archimedes::App*);
~DependsOnPrint();
void run();
void onLoad() {}
};
#ifndef DEPENDSONPRINT_STATIC
#define MODULE_TYPE DependsOnPrint
#include "endModule.h"
#endif

View File

@@ -0,0 +1,17 @@
#include "DependsOnPrintStatic.h"
#include "modules/Print/src/Print.h"
DependsOnPrintStatic::DependsOnPrintStatic(void* h, Archimedes::App* a) : Module(h, a) {
name = "DependsOnPrintStatic";
deps["Print"] = new Print(nullptr, a);
}
DependsOnPrintStatic::~DependsOnPrintStatic() {
std::cout << "DependsOnPrintStatic Destroyed!\n";
}
void DependsOnPrintStatic::run() {
std::cout << "DependsOnPrintStatic lib loaded and run!\n";
app->stopModule(self);
}

View File

@@ -0,0 +1,16 @@
#include "Archimedes.h"
class DependsOnPrintStatic : public Archimedes::Module {
public:
DependsOnPrintStatic(void*, Archimedes::App*);
~DependsOnPrintStatic();
void run();
void onLoad() {}
};
#ifndef DEPENDSONPRINTSTATIC_STATIC
#define MODULE_TYPE DependsOnPrintStatic
#include "endModule.h"
#endif

View File

@@ -0,0 +1,35 @@
#include "TestClay.h"
#define CLAY_IMPLIMENTATION
#include "clay.h"
#include <GLFW/glfw3.h>
TestClay::TestClay(void* h, Archimedes::App& a) : Archimedes::GuiModule(h, a) {
name = "TestClay";
}
TestClay::~TestClay() {
}
void TestClay::onLoad() {
createWindow();
window->getRenderer().init();
}
void TestClay::run() {
window->getRenderer().addRenderCmd([](){
});
if(window->shouldClose())
app.end();
window->doFrame();
}

View File

@@ -0,0 +1,25 @@
#include "Archimedes.h"
class TestClay : public Archimedes::GuiModule {
public:
TestClay(void*, Archimedes::App&);
~TestClay();
void onLoad();
void run();
private:
};
extern "C" {
Archimedes::Module* create(void* handle, Archimedes::App& app) {
return new TestClay(handle, app);
}
}

View File

@@ -0,0 +1,74 @@
#include "TestImgui.h"
#include "imgui.h"
#include "backends/imgui_impl_glfw.h"
#include "backends/imgui_impl_opengl3.h"
#include <GLFW/glfw3.h>
TestImgui::TestImgui(void* h, Archimedes::App* a) : Archimedes::GuiModule(h, a) {
name = "TestImgui";
}
TestImgui::~TestImgui() {
window->getRenderer().removeRenderCmd(rcmd);
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void TestImgui::onLoad() {
createWindow();
window->getRenderer().init();
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
ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true);
ImGui_ImplOpenGL3_Init("#version 130");
rcmd = window->getRenderer().addRenderCmd([](){
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
/*if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}*/
});
//cmdlist.push_back(it);
}
void TestImgui::run() {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
if(demo)
ImGui::ShowDemoWindow(&this->demo);
else
app->end();
ImGui::Render();
if(window->shouldClose())
app->end();
window->doFrame();
}

View File

@@ -0,0 +1,27 @@
#ifndef GUIMODULE
#define GUIMODULE
#endif
#include "Archimedes.h"
class TestImgui : public Archimedes::GuiModule {
public:
TestImgui(void*, Archimedes::App*);
~TestImgui();
void onLoad();
void run();
private:
bool demo = true;
std::list<Archimedes::Renderer::renderCmd*>::iterator rcmd;
};
#ifndef TESTIMGUI_STATIC
#define MODULE_TYPE TestImgui
#include "endModule.h"
#endif

View File

@@ -0,0 +1,15 @@
#include "Print.h"
Print::Print(void* h, Archimedes::App* a) : Archimedes::Module(h, a) {
name = "Print";
}
Print::~Print() {
std::cout << "Print Destroyed!\n";
}
void Print::run() {
std::cout << "Print lib loaded and run!\n";
app->stopModule(self);
}

View File

@@ -0,0 +1,16 @@
#include "Archimedes.h"
class Print : public Archimedes::Module {
public:
Print(void*, Archimedes::App*);
~Print();
void run();
void onLoad() {}
};
#ifndef PRINT_STATIC
#define MODULE_TYPE Print
#include "endModule.h"
#endif

View File

@@ -0,0 +1,37 @@
#include "TestMenu.h"
TestMenu::TestMenu(void* h, App& a) : Module(h, a) {
name = "TestMenu";
}
TestMenu::~TestMenu() {
std::cout << "TestMenu Destroyed!\n";
}
void TestMenu::run() {
std::cout << "Your number is: " << num << "\n"
<< "1. Add 1\n"
<< "2. Subtract 1\n"
<< "3. Unload Module\n\n"
<< "4. Quit\n\n";
std::cin >> choice;
switch(choice) {
case 1:
num++;
break;
case 2:
num--;
break;
case 3:
app.stopModule(self);
break;
case 4:
app.end();
break;
default:
break;
}
}

View File

@@ -0,0 +1,20 @@
#include "Archimedes.h"
class TestMenu : public Module {
public:
TestMenu(void*, App&);
~TestMenu();
void run();
void onLoad() {}
private:
int choice;
int num = 5;
};
extern "C" {
Module* create(void* handle, App& app) {
return new TestMenu(handle, app);
}
}