add SandboxEmbed

This commit is contained in:
2026-02-15 23:56:24 -06:00
parent 2899932f7f
commit c25ed1949d
4 changed files with 155 additions and 1 deletions

View File

@@ -0,0 +1,71 @@
#include "SandboxEmbed.h"
bool SandboxEmbed::onEvent(const Archimedes::Event& event) {
unsigned int type = getEventType(event);
if(type == getEventType(Archimedes::DoLoadModuleEvent())) {
Archimedes::DoLoadModuleEvent& e = (Archimedes::DoLoadModuleEvent&) event;
startModule(e.module);
return true;
} else if(type == getEventType(Archimedes::DoUnloadModuleEvent())) {
Archimedes::DoUnloadModuleEvent& e = (Archimedes::DoUnloadModuleEvent&) event;
stopModule(e.module);
return true;
} else if(type == getEventType(Archimedes::LoadModuleEvent())) {
return true;
} else if(type == getEventType(Archimedes::UnloadModuleEvent())) {
return true;
} else if(type == getEventType(Archimedes::AnonymousEvent())) {
return true;
}
return false;
}
void SandboxEmbed::run() {
for(std::string m : runOrder) {
modules[m]->onLoad();
}
// Main loop
while (!done && !runOrder.empty()) {
for(std::string m : runOrder) {
modules[m]->run();
}
handleEvents();
for(std::string m : toClose) {
unload(m);
}
toClose.clear();
for(auto m : toOpen) {
static Archimedes::Module* n;
if(std::holds_alternative<std::string>(m)) {
n = load(std::get<std::string>(m));
} else {
n = load(std::get<Archimedes::Module*>(m));
}
if(n) {
n->onLoad();
n = nullptr;
}
}
toOpen.clear();
}
}

View File

@@ -0,0 +1,29 @@
#define ENTRYPOINT
#include "Archimedes.h"
#include "modules/Archimedes-Modules/Sandbox/Sandbox.h"
class SandboxEmbed : public Archimedes::App {
private:
void printHelp() override {};
bool onEvent(const Archimedes::Event&) override;
public:
SandboxEmbed() {
Archimedes::Module* m = (Archimedes::Module*) new Sandbox(Get(), nullptr);
load(m);
};
~SandboxEmbed() {};
void handleArgs(const int& argc, char* argv[]) override {};
void run() override;
};
#define APP_TYPE SandboxEmbed
#include "endApp.h"

View File

@@ -0,0 +1,54 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_Sandbox = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
glm
nlohmann_json
curl
];
buildPhase = ''
clang++ \
example_apps/SandboxEmbed/*.cpp \
modules/Archimedes-Modules/Sandbox/*.cpp \
modules/WindowModule/*.cpp \
modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER_OPENGL=1 \
-DWINDOW_GLFW=1 \
-I include -I $imgui -I . \
-lEGL -lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
}; };
}

View File

@@ -25,7 +25,7 @@
buildPhase = ''
clang++ \
src/example_apps/TriangleEmbed/*.cpp \
example_apps/TriangleEmbed/*.cpp \
modules/Archimedes-Modules/TestTriangle/*.cpp \
modules/WindowModule/*.cpp \
-DRENDERER_OPENGL=1 \