add SandboxEmbed
This commit is contained in:
71
src/example_apps/SandboxEmbed/SandboxEmbed.cpp
Normal file
71
src/example_apps/SandboxEmbed/SandboxEmbed.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/example_apps/SandboxEmbed/SandboxEmbed.h
Normal file
29
src/example_apps/SandboxEmbed/SandboxEmbed.h
Normal 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"
|
||||||
54
src/example_apps/SandboxEmbed/default.nix
Normal file
54
src/example_apps/SandboxEmbed/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
}; };
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
clang++ \
|
clang++ \
|
||||||
src/example_apps/TriangleEmbed/*.cpp \
|
example_apps/TriangleEmbed/*.cpp \
|
||||||
modules/Archimedes-Modules/TestTriangle/*.cpp \
|
modules/Archimedes-Modules/TestTriangle/*.cpp \
|
||||||
modules/WindowModule/*.cpp \
|
modules/WindowModule/*.cpp \
|
||||||
-DRENDERER_OPENGL=1 \
|
-DRENDERER_OPENGL=1 \
|
||||||
|
|||||||
Reference in New Issue
Block a user