Compare commits

..

43 Commits

Author SHA1 Message Date
c107ce732c start ChessServer and remove basic redundant examples 2025-05-20 17:25:50 -05:00
ad658d914c improve ChatVoice 2025-05-20 16:06:11 -05:00
f6ad110880 add ^ 2025-05-19 14:13:55 -05:00
cb5762a3fe Calculator works 2025-05-18 16:17:14 -05:00
45f1d0f69d Calculator 2025-05-13 15:35:41 -05:00
dffca865dc spellcheck 2025-05-13 08:35:22 -05:00
32223cfa05 Calculator 2025-05-13 01:58:46 -05:00
3196f7b81a buttons 2025-05-12 16:39:34 -05:00
08bccb1e70 lock 2025-05-12 16:36:51 -05:00
2e0341a12e build 2025-05-12 16:35:42 -05:00
b4309ab4e9 reintegration complete 2025-05-12 16:28:27 -05:00
2350592424 ... 2025-05-12 16:26:11 -05:00
9d63e16032 reintegrate modules 2025-05-12 16:24:02 -05:00
501649d236 build 2025-05-12 16:06:25 -05:00
e139696d6a ... 2025-05-12 16:04:21 -05:00
79f4a5288f return of endModule 2025-05-12 15:28:08 -05:00
80e0709278 build 2025-05-12 15:23:44 -05:00
9f1e77cb9e help 2025-05-12 14:59:44 -05:00
d3fe8598cd remove endModule 2025-05-12 14:53:50 -05:00
38e398e367 define 2025-05-12 14:46:19 -05:00
3a82e9b4ec use typedef 2025-05-12 14:32:13 -05:00
5319e2309b build 2025-05-12 14:15:23 -05:00
f86eb4ab90 spellcheck 2025-05-12 14:08:42 -05:00
bab30c6124 include 2025-05-12 14:06:49 -05:00
700e422270 no src 2025-05-12 00:14:11 -05:00
ec4b85587b add extra modules as git submodule 2025-05-11 19:17:33 -05:00
cb56bd302d fix headers? 2025-05-11 14:11:24 -05:00
0e1bae3123 build 2025-05-10 15:08:14 -05:00
7e4fad568b undo 2025-05-10 15:05:31 -05:00
37383c3ed7 try again 2025-05-10 14:58:52 -05:00
045f97e9b0 try something 2025-05-10 14:48:30 -05:00
eac9abc839 move example modules elsewhere 2025-05-10 13:50:58 -05:00
cc5efa8424 work on Audio 2025-05-10 13:40:27 -05:00
53695cbc60 clear on pause 2025-05-08 23:50:01 -05:00
101fcf4781 ChatServerVoice 2025-05-08 22:21:18 -05:00
421bf37b75 build 2025-05-08 20:21:42 -05:00
2182abc714 add voice chat 2025-05-08 20:19:51 -05:00
b8fba92ea7 add Audio 2025-05-05 23:08:48 -05:00
21d07cab07 sdl use event callback 2025-05-05 18:14:30 -05:00
3198b91ebc RendererSDL3 functional 2025-05-05 16:43:50 -05:00
62b7618ff4 unsegfault 2025-05-05 16:30:35 -05:00
03213c2c15 spellcheck 2025-05-05 16:18:21 -05:00
0fb63352a2 add RendererSDL3 2025-05-05 16:16:56 -05:00
57 changed files with 1502 additions and 439 deletions

View File

@@ -6,6 +6,8 @@
src = ./.; src = ./.;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
clang clang
]; ];
@@ -24,6 +26,10 @@
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cp $name $out/bin cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
''; '';
}; };
@@ -48,16 +54,16 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
src/example_apps/ImguiEmbed/*.cpp \ src/example_apps/ImguiEmbed/*.cpp \
modules/examples/TestImgui/src/*.cpp \ modules/Archimedes-Modules/TestImgui/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -90,16 +96,16 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
src/example_apps/TerminalEmbed/*.cpp \ src/example_apps/TerminalEmbed/*.cpp \
modules/Terminal/src/*.cpp \ modules/Archimedes-Modules/Terminal/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name

View File

@@ -12,9 +12,8 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestMenu/src/*.cpp \ modules/Archimedes-Modules/TestMenu/*.cpp \
-fpic -shared \ -fpic -shared \
-I src \
-Wall \ -Wall \
-DTESTMENU_DYNAMIC \ -DTESTMENU_DYNAMIC \
-o $name -o $name
@@ -43,9 +42,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestNotCurses/src/*.cpp \ modules/Archimedes-Modules/TestNotCurses/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-Wall \ -Wall \
-lnotcurses \ -lnotcurses \
-DTESTNOTCURSES_DYNAMIC \ -DTESTNOTCURSES_DYNAMIC \
@@ -71,9 +70,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/Print/src/*.cpp \ modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-Wall \ -Wall \
-DPRINT_DYNAMIC \ -DPRINT_DYNAMIC \
-o $name -o $name
@@ -98,9 +97,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/DependsOnPrint/src/*.cpp \ modules/Archimedes-Modules/DependsOnPrint/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-Wall \ -Wall \
-DDEPENDSONPRINT_DYNAMIC \ -DDEPENDSONPRINT_DYNAMIC \
-o $name -o $name
@@ -125,10 +124,10 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/DependsOnPrintStatic/src/*.cpp \ modules/Archimedes-Modules/DependsOnPrintStatic/*.cpp \
modules/examples/Print/src/*.cpp \ modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include -I . \ -I include -I . \
-DDEPENDSONPRINTSTATIC_DYNAMIC \ -DDEPENDSONPRINTSTATIC_DYNAMIC \
-Wall \ -Wall \
-o $name -o $name
@@ -160,18 +159,61 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestImgui/src/*.cpp \ modules/Archimedes-Modules/TestImgui/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-DTESTIMGUI_DYNAMIC \ -DTESTIMGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
Calculator = pkgs.stdenvNoCC.mkDerivation {
name = "Calculator";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Calculator/*.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=1 \
-DWINDOW=1 \
-DCALCULATOR_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -198,11 +240,11 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestClay/src/*.cpp \ modules/Archimedes-Modules/TestClay/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-DTESTCLAY_DYNAMIC \ -DTESTCLAY_DYNAMIC \
-Wall \ -Wall \
-o $name -o $name
@@ -231,11 +273,11 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/ChatServer/src/*.cpp \ modules/Archimedes-Modules/Chat/ChatServer/*.cpp \
modules/ServerModule/src/*.cpp \ modules/ServerModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I src -I include -I . \ -I include -I . \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCHATSERVER_DYNAMIC \ -DCHATSERVER_DYNAMIC \
-Wall \ -Wall \
@@ -249,6 +291,40 @@
}; };
ChatServerVoice = pkgs.stdenvNoCC.mkDerivation {
name = "ChatServerVoice";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/ChatVoice/ChatServerVoice/*.cpp \
modules/ServerModule/*.cpp \
-fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I include -I . \
-lGameNetworkingSockets \
-DCHATSERVERVOICE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ChatClient = pkgs.stdenvNoCC.mkDerivation { ChatClient = pkgs.stdenvNoCC.mkDerivation {
name = "ChatClient"; name = "ChatClient";
@@ -269,21 +345,21 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/ChatClient/src/*.cpp \ modules/Archimedes-Modules/Chat/ChatClient/*.cpp \
modules/ClientModule/src/*.cpp \ modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCHATCLIENT_DYNAMIC \ -DCHATCLIENT_DYNAMIC \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -295,4 +371,143 @@
''; '';
}; };
ChatClientVoice = pkgs.stdenvNoCC.mkDerivation {
name = "ChatClientVoice";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
sdl3
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/ChatVoice/ChatClientVoice/*.cpp \
modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCHATCLIENTVOICE_DYNAMIC \
modules/WindowModule/*.cpp \
modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_sdl3.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=2 \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lSDL3 -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
Terminal = pkgs.stdenvNoCC.mkDerivation {
name = "Terminal";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Terminal/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DTERMINAL_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
Ollama = pkgs.stdenvNoCC.mkDerivation {
name = "Ollama";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
curl
nlohmann_json
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Ollama/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DOLLAMA_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
} }

18
flake.lock generated
View File

@@ -3,11 +3,11 @@
"clay": { "clay": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1742509368, "lastModified": 1746753934,
"narHash": "sha256-XSaMuWCADZgZnRaGcBgf+u40O6jS5kkpq3Xruy6z+I0=", "narHash": "sha256-7Kx536YsmPTXUjs/jBknGAmqYsqqDh6T11AlarTeGLM=",
"owner": "nicbarker", "owner": "nicbarker",
"repo": "clay", "repo": "clay",
"rev": "ad49977f1b37ccd7664333181f30f575d08d3838", "rev": "76265e4c3c97ebe5a4aab081d5c5a05e5a979d5d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -19,11 +19,11 @@
"imgui": { "imgui": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1741968903, "lastModified": 1747034542,
"narHash": "sha256-4L37NRR+dlkhdxuDjhLR45kgjyZK2uelKBlGZ1nQzgY=", "narHash": "sha256-kVbyG7LXXHIOiI6dlZVID9DLErR+XNoAGp/R82TEpgo=",
"owner": "ocornut", "owner": "ocornut",
"repo": "imgui", "repo": "imgui",
"rev": "126d004f9e1eef062bf4b044b3b2faaf58d48c51", "rev": "e33069ce56d07751ca875eb239f41febef0ebcd3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -35,11 +35,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1742136038, "lastModified": 1746957726,
"narHash": "sha256-DDe16FJk18sadknQKKG/9FbwEro7A57tg9vB5kxZ8kY=", "narHash": "sha256-k9ut1LSfHCr0AW82ttEQzXVCqmyWVA5+SHJkS5ID/Jo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a1185f4064c18a5db37c5c84e5638c78b46e3341", "rev": "a39ed32a651fdee6842ec930761e31d1f242cb94",
"type": "github" "type": "github"
}, },
"original": { "original": {

138
flake.nix
View File

@@ -13,7 +13,7 @@
}; };
}; };
outputs = { self, nixpkgs, imgui, clay }@inputs: let outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
in { in {
@@ -41,9 +41,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/ServerModule/src/*.cpp \ modules/ServerModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DSERVERMODULE_DYNAMIC \ -DSERVERMODULE_DYNAMIC \
@@ -74,9 +74,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/ClientModule/src/*.cpp \ modules/ClientModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCLIENTMODULE_DYNAMIC \ -DCLIENTMODULE_DYNAMIC \
@@ -108,9 +108,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-DRENDERER=1 \ -DRENDERER=1 \
-DWINDOW=1 \ -DWINDOW=1 \
-DWINDOWMODULE_DYNAMIC \ -DWINDOWMODULE_DYNAMIC \
@@ -145,8 +145,8 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
@@ -156,7 +156,7 @@
-DIMGUIMODULE_DYNAMIC \ -DIMGUIMODULE_DYNAMIC \
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \ -DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -168,6 +168,7 @@
''; '';
}; };
MainGUIsdl = pkgs.stdenvNoCC.mkDerivation { MainGUIsdl = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI"; name = "MainGUI";
@@ -182,24 +183,23 @@
buildInputs = with pkgs; [ buildInputs = with pkgs; [
sdl3 sdl3
glew
]; ];
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/MainGUI/src/*.cpp \ modules/MainGUI/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_sdl3.cpp \ $imgui/backends/imgui_impl_sdl3.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_sdlrenderer3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER=1 \ -DRENDERER=2 \
-DWINDOW=2 \ -DWINDOW=2 \
-DMAINGUI_DYNAMIC \ -DMAINGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lSDL3 -lGLEW \ -lSDL3 \
-Wall \ -Wall \
-o $name -o $name
''; '';
@@ -231,9 +231,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/MainGUI/src/*.cpp \ modules/MainGUI/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
@@ -242,7 +242,7 @@
-DWINDOW=1 \ -DWINDOW=1 \
-DMAINGUI_DYNAMIC \ -DMAINGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -255,101 +255,9 @@
}; };
Terminal = pkgs.stdenvNoCC.mkDerivation {
name = "Terminal";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Terminal/src/*.cpp \
modules/ImguiModule/src/*.cpp \
modules/WindowModule/src/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DTERMINAL_DYNAMIC \
-fpic -shared \
-I src -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
}; };
Ollama = pkgs.stdenvNoCC.mkDerivation { packages.${system}.default = self.Archimedes.examples.MinimalApp;
name = "Ollama";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
curl
nlohmann_json
];
buildPhase = ''
clang++ \
modules/Ollama/src/*.cpp \
modules/ImguiModule/src/*.cpp \
modules/WindowModule/src/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DOLLAMA_DYNAMIC \
-fpic -shared \
-I src -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
packages.${system}.default = self.Archimedes;
apps.${system}.default = { apps.${system}.default = {
type = "app"; type = "app";

View File

@@ -1,12 +1,5 @@
#include "Archimedes.h"
#ifdef MODULE_TYPE
extern "C" { extern "C" {
Archimedes::Module* create(Archimedes::App* app, void* handle) { Archimedes::Module* create(Archimedes::App* app, void* handle) {
return new MODULE_TYPE(app, handle); return new mtype(app, handle);
} }
} }
#undef MODULE_TYPE
#endif

View File

@@ -0,0 +1,51 @@
#ifndef AUDIO_H
#define AUDIO_H
#include "pch.hpp"
#include <SDL3/SDL.h>
#include <SDL3/SDL_audio.h>
namespace Archimedes {
class Audio {
public:
Audio() {
if(!SDL_Init(SDL_INIT_AUDIO)) {
std::abort();
}
pDevices = SDL_GetAudioPlaybackDevices(&pDeviceCount);
rDevices = SDL_GetAudioPlaybackDevices(&rDeviceCount);
}
~Audio() {
for(SDL_AudioStream* s : streams) {
DestroyAudioStream(s);
}
SDL_QuitSubsystem(SDL_INIT_AUDIO);
}
private:
SDL_AudioDeviceID* pDevices;
int pDeviceCount = 0;
SDL_AudioDeviceID* rDevices;
int rDeviceCount = 0;
std::vector<SDL_AudioStream*> streams;
std::vector<SDL_AudioSpec> specs;
};
}
#endif

View File

@@ -3,6 +3,7 @@
#include "pch.hpp" #include "pch.hpp"
#include "RendererOpenGL/RendererOpenGL.h" #include "RendererOpenGL/RendererOpenGL.h"
#include "RendererSDL3/RendererSDL3.h"
namespace Archimedes { namespace Archimedes {
class Renderer { class Renderer {
@@ -12,7 +13,7 @@ namespace Archimedes {
~Renderer() {} ~Renderer() {}
bool init() { return r.init(); } bool init(void* ptr) { return r.init(ptr); }
void render() { void render() {
r.render(rc, w, h); r.render(rc, w, h);
@@ -22,6 +23,8 @@ namespace Archimedes {
return rc; return rc;
} }
RendererImpl& getRendererImpl() { return r; }
private: private:
std::list<std::function<void()>> rc; std::list<std::function<void()>> rc;
RendererImpl r; RendererImpl r;

View File

@@ -19,7 +19,7 @@ namespace Archimedes {
RendererOpenGL() {}; RendererOpenGL() {};
~RendererOpenGL() {}; ~RendererOpenGL() {};
bool init() { bool init(void* p) {
return glewInit() == GLEW_OK; return glewInit() == GLEW_OK;
}; };

View File

@@ -0,0 +1,49 @@
#if RENDERER == 2
#ifndef RENDERER_SDL3
#define RENDERER_SDL3
#include "pch.hpp"
#include <SDL3/SDL.h>
namespace Archimedes {
class RendererSDL3 {
public:
typedef void renderCmd();
RendererSDL3() {};
~RendererSDL3() { SDL_DestroyRenderer(renderer); };
bool init(void* window) {
renderer = SDL_CreateRenderer((SDL_Window*) window, nullptr);
SDL_SetRenderVSync(renderer, 1);
return renderer != nullptr;
};
void render(std::list<std::function<void()>> cmdList, int& w, int& h) {
//SDL_SetRenderScale(renderer, w, h);
SDL_RenderClear(renderer);
for(auto f : cmdList)
f();
SDL_RenderPresent(renderer);
}
SDL_Renderer* renderer = nullptr;
};
typedef RendererSDL3 RendererImpl;
}
#endif
#endif

View File

@@ -25,11 +25,11 @@ namespace Archimedes {
void doFrame() { void doFrame() {
window.pollEvents();
renderer->render(); renderer->render();
window.doFrame(); window.doFrame();
window.pollEvents();
} }
Renderer* getRenderer() { return renderer; } Renderer* getRenderer() { return renderer; }

View File

@@ -9,12 +9,63 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#if RENDERER == 2
#include <SDL3/SDL_opengl.h> #include <SDL3/SDL_opengl.h>
#endif
namespace Archimedes { namespace Archimedes {
class Window; class Window;
static bool EventCallback(void* ptr, SDL_Event* e) {
WindowData& data = *(WindowData*) ptr;
switch(e->type) {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_QUIT:
data.sendEvent(new CloseWindowEvent(data.window, e));
break;
case SDL_EVENT_WINDOW_RESIZED:
data.sendEvent(new ResizeWindowEvent(e->window.data1, e->window.data2, e));
break;
case SDL_EVENT_WINDOW_MOUSE_ENTER:
case SDL_EVENT_WINDOW_FOCUS_GAINED:
data.sendEvent(new FocusedWindowEvent(data.window, e));
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
case SDL_EVENT_WINDOW_FOCUS_LOST:
data.sendEvent(new FocusLostWindowEvent(data.window, e));
break;
case SDL_EVENT_KEY_DOWN:
data.sendEvent(new KeyPressedWindowEvent(e->key.key, e->key.repeat ? 1 : 0, e));
break;
case SDL_EVENT_KEY_UP:
data.sendEvent(new KeyReleasedWindowEvent(e->key.key, e));
break;
case SDL_EVENT_MOUSE_MOTION:
data.sendEvent(new MouseMovedWindowEvent(e->motion.x, e->motion.y, e));
break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
data.sendEvent(new MouseButtonPressedWindowEvent(e->button.button, e));
break;
case SDL_EVENT_MOUSE_BUTTON_UP:
data.sendEvent(new MouseButtonReleasedWindowEvent(e->button.button, e));
break;
case SDL_EVENT_MOUSE_WHEEL:
data.sendEvent(new ScrollWindowEvent(e->wheel.x, e->wheel.y, e));
break;
default:
data.sendEvent(new AnonymousEvent(e));
break;
}
return true;
}
class WindowSDL3 { class WindowSDL3 {
public: public:
@@ -24,158 +75,93 @@ namespace Archimedes {
data.window = p; data.window = p;
data.sendEvent = sendEvent; data.sendEvent = sendEvent;
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
std::cerr << "Error: SDL_Init(): " << SDL_GetError() << std::flush;
std::abort();
}
#if RENDERER == 1
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
#elif RENDERER == 2
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
#endif
w = SDL_CreateWindow("Archimedes", 1280, 720, window_flags); w = SDL_CreateWindow("Archimedes", 1280, 720, window_flags);
if (w == nullptr) if (w == nullptr)
{ {
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError()); std::cerr << "Error: SDL_CreateWindow(): " << SDL_GetError() << std::endl;
std::abort(); std::abort();
} }
SDL_SetWindowPosition(w, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); SDL_SetWindowPosition(w, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
#if RENDERER == 1
gl_context = SDL_GL_CreateContext(w); gl_context = SDL_GL_CreateContext(w);
if (gl_context == nullptr) if (gl_context == nullptr)
{ {
printf("Error: SDL_GL_CreateContext(): %s\n", SDL_GetError()); std::cerr << "Error: SDL_GL_CreateContext(): " << SDL_GetError() << std::endl;
std::abort(); std::abort();
} }
/*SDL_AddEventWatch([](void* ptr, SDL_Event* e) -> bool {
WindowData& data = (WindowData&) *ptr;
switch(e.type) {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_QUIT:
data.sendEvent(new CloseWindowEvent(data.window, (void*) &e));
break;
case SDL_EVENT_WINDOW_RESIZED:
width = e.window.data1;
height = e.window.data2;
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2, (void*) &e));
break;
case SDL_EVENT_WINDOW_MOUSE_ENTER:
case SDL_EVENT_WINDOW_FOCUS_GAINED:
data.sendEvent(new FocusedWindowEvent(data.window, (void*) &e));
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
case SDL_EVENT_WINDOW_FOCUS_LOST:
data.sendEvent(new FocusLostWindowEvent(data.window, (void*) &e));
break;
case SDL_EVENT_KEY_DOWN:
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0, (void*) &e));
break;
case SDL_EVENT_KEY_UP:
data.sendEvent(new KeyReleasedWindowEvent(e.key.key, (void*) &e));
break;
case SDL_EVENT_TEXT_EDITING:
break;
case SDL_EVENT_TEXT_INPUT:
break;
case SDL_EVENT_MOUSE_MOTION:
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y, (void*) &e));
break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button, (void*) &e));
break;
case SDL_EVENT_MOUSE_BUTTON_UP:
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button, (void*) &e));
break;
case SDL_EVENT_MOUSE_WHEEL:
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y, (void*) &e));
break;
default:
break;
}
return true;
}, &data);*/
SDL_GL_MakeCurrent(w, gl_context); SDL_GL_MakeCurrent(w, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync SDL_GL_SetSwapInterval(1); // Enable vsync
#endif
SDL_AddEventWatch(EventCallback, &data);
SDL_ShowWindow(w); SDL_ShowWindow(w);
} }
~WindowSDL3() { ~WindowSDL3() {
#if RENDERER == 1
SDL_GL_DestroyContext(gl_context); SDL_GL_DestroyContext(gl_context);
#endif
SDL_RemoveEventWatch(EventCallback, &data);
SDL_DestroyWindow(w); SDL_DestroyWindow(w);
SDL_Quit(); SDL_Quit();
} }
bool shouldClose() { return false; } bool shouldClose() { return false; }
void doFrame() { restoreContext(); SDL_GL_SwapWindow(w); } void doFrame() {
#if RENDERER == 1
restoreContext();
SDL_GL_SwapWindow(w);
#endif
}
void pollEvents() { void pollEvents() {
while(SDL_PollEvent(&e)) { static SDL_Event e;
switch(e.type) { while(SDL_PollEvent(&e)) {}
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_QUIT:
data.sendEvent(new CloseWindowEvent(data.window, &e));
break;
case SDL_EVENT_WINDOW_RESIZED:
width = e.window.data1;
height = e.window.data2;
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2, &e));
break;
case SDL_EVENT_WINDOW_MOUSE_ENTER:
case SDL_EVENT_WINDOW_FOCUS_GAINED:
data.sendEvent(new FocusedWindowEvent(data.window, &e));
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
case SDL_EVENT_WINDOW_FOCUS_LOST:
data.sendEvent(new FocusLostWindowEvent(data.window, &e));
break;
case SDL_EVENT_KEY_DOWN:
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0, &e));
break;
case SDL_EVENT_KEY_UP:
data.sendEvent(new KeyReleasedWindowEvent(e.key.key, &e));
break;
case SDL_EVENT_MOUSE_MOTION:
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y, &e));
break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button, &e));
break;
case SDL_EVENT_MOUSE_BUTTON_UP:
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button, &e));
break;
case SDL_EVENT_MOUSE_WHEEL:
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y, &e));
break;
default:
data.sendEvent(new AnonymousEvent(&e));
break;
} }
} #if RENDERER == 1
}
void restoreContext() { SDL_GL_MakeCurrent(w, gl_context); } void restoreContext() { SDL_GL_MakeCurrent(w, gl_context); }
#endif
void getSize(int& w, int& h) { void getSize(int& w, int& h) {
w = this->width; w = this->width;
h = this->height; h = this->height;
} }
void setSize(int& w, int& h) {
this->width = w;
this->height = h;
}
SDL_Window* getWindow() { return w; } SDL_Window* getWindow() { return w; }
#if RENDERER == 1
SDL_GLContext getContext() { return gl_context; } SDL_GLContext getContext() { return gl_context; }
#endif
WindowData data; WindowData data;
private: private:
SDL_Window* w; SDL_Window* w;
int width = 0, height = 0; int width = 0, height = 0;
#if RENDERER == 1
SDL_GLContext gl_context; SDL_GLContext gl_context;
SDL_Event e; #endif
}; };

View File

@@ -0,0 +1,353 @@
#include "Calculator.h"
#include "modules/ImguiModule/ImguiModule.h"
#include <sstream>
#include <cmath>
Calculator::Calculator(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
name = "Calculator";
ImguiModule* im = new ImguiModule(a, h);
deps[*im] = im;
}
Calculator::~Calculator() {
if(app) {
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
im->releaseContext(ImGui::GetCurrentContext());
}
}
void Calculator::onLoad() {
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
if(!im) {
std::cout << "No ImguiModule for Calculator!\n";
std::abort();
}
ImGui::SetCurrentContext(im->aquireContext());
}
void Calculator::run() {
if(open) {
basicCalculator();
} else {
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
}
}
void Calculator::index(std::string equation, std::unordered_map<unsigned int, std::string>& nodes) {
unsigned int idx = 0;
nodes.clear();
const static std::string operators[] = {
"(",
")",
"^",
"*",
"/",
"+",
"-"
};
for(const std::string& s : operators) {
while(equation.find(s, idx) != std::string::npos) {
int next = equation.find(s, idx);
nodes[next] = equation.substr(next, s.length());
idx = next + s.length();
}
idx = 0;
}
// -3+8*6-(8+4)^9/5
for(unsigned int i = 0; i < equation.length(); i++) {
static unsigned int begin = 0, end = 0;
if(nodes.find(i) == nodes.end()) {
if(nodes.find(i - 1) != nodes.end() || i == 0) {
//first digit of expression
begin = i;
}
if(nodes.find(i + 1) != nodes.end() || i == equation.length() - 1) {
//character after last digit of expression
end = i + 1;
nodes[begin] = equation.substr(begin, end - begin);
nodes[end - 1] = equation.substr(begin, end - begin);
}
}
}
}
double Calculator::evaluate(std::string equation, std::unordered_map<char, std::string>& evalStr) {
char op = '^';
while(equation.find(op) == std::string::npos) {
switch(op) {
case '^':
op = '*';
break;
case '*':
op = '/';
break;
case '/':
op = '+';
break;
case '+':
op = '-';
break;
case '-':
//no operator
if(evalStr.find(equation.front()) != evalStr.end()) {
return evaluate(evalStr[equation.front()], evalStr);
} else {
return std::stod(equation);
}
break;
default:
break;
}
}
//op is now the appropriate operator
//if either term is a placeholder, evaluate and substitute.
double a, b;
if(evalStr.find(equation.front()) != evalStr.end()) {
a = evaluate(evalStr[equation.front()], evalStr);
} else {
if(equation.find(op) == 0 && op == '-') {
a = 0;
} else {
a = std::stod(equation.substr(0, equation.find(op)));
}
}
if(evalStr.find(equation.back()) != evalStr.end()) {
b = evaluate(evalStr[equation.back()], evalStr);
} else {
b = std::stod(equation.substr(equation.find(op) + 1));
}
switch(op) {
case '^':
return pow(a, b);
case '*':
return a * b;
case '/':
return a / b;
case '+':
return a + b;
case '-':
return a - b;
default:
break;
}
}
std::string Calculator::calculate(std::string equation) {
//PEMDAS
while(equation.find(' ') != std::string::npos) {
equation.erase(equation.find(' '), 1);
}
while(equation.find('\t') != std::string::npos) {
equation.erase(equation.find('\t'), 1);
}
while(equation.find('\n') != std::string::npos) {
equation.erase(equation.find('\n'), 1);
}
std::unordered_map<unsigned int, std::string> nodes;
std::unordered_map<char, std::string> evalStr;
std::string eval = "a";
unsigned int idx = 0;
index(equation, nodes);
idx = 0;
// ()
while(equation.find(')', idx) != std::string::npos) {
int end = equation.find(')');
int begin = equation.rfind('(', end);
evalStr[eval.front()] = calculate(equation.substr(begin + 1, (end - begin) - 1));
equation.replace(begin, (end - begin) + 1, eval);
eval.front()++;
idx = end + 1;
}
idx = 0;
index(equation, nodes);
// ^
while(equation.find('^', idx) != std::string::npos) {
int mid = equation.find('^');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
}
idx = 0;
index(equation, nodes);
// * or /
while(equation.find('*', idx) != std::string::npos || equation.find('/', idx) != std::string::npos) {
if(equation.find('*', idx) < equation.find('/', idx) && equation.find('*', idx) != std::string::npos) {
int mid = equation.find('*');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
} else if(equation.find('/', idx) != std::string::npos) {
int mid = equation.find('/');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
}
}
idx = 0;
index(equation, nodes);
// + or -
while(equation.find('+', idx) != std::string::npos || equation.find('-', idx) != std::string::npos) {
if(equation.find('+', idx) < equation.find('-', idx) && equation.find('+', idx) != std::string::npos) {
int mid = equation.find('+');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
} else if(equation.find('-', idx) != std::string::npos) {
int mid = equation.find('-');
int begin = mid;
if(nodes.find(mid - 1) != nodes.end()) {
begin = equation.find(nodes[mid - 1] + nodes[mid]);
}
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
}
}
return std::to_string(evaluate(equation, evalStr));
}
void Calculator::basicCalculator() {
static bool b = true;
static std::string s;
if(b) {
ImGui::Begin("Basic Calculator", &open);
ImGui::Text("%s", s.c_str());
ImGui::BeginGroup();
{
if(ImGui::Button("AC")) {
s.clear();
}
ImGui::SameLine();
if(ImGui::Button("(")) {
s += " ( ";
}
ImGui::SameLine();
if(ImGui::Button(")")) {
s += " ) ";
}
ImGui::SameLine();
if(ImGui::Button("^")) {
s += " ^ ";
}
ImGui::SameLine();
if(ImGui::Button("=")) {
s = calculate(s);
}
}
ImGui::EndGroup();
ImGui::BeginGroup();
{
for(int i = 1; i < 4; i++) {
ImGui::BeginGroup();
for(int j = 6; j >= 0; j -= 3) {
if(ImGui::Button(std::to_string(i + j).c_str())) {
s += std::to_string(i + j);
}
}
ImGui::EndGroup();
if(i < 3) {
ImGui::SameLine();
}
}
if(ImGui::Button("0")) {
s += "0";
}
ImGui::SameLine();
if(ImGui::Button(".")) {
s += ".";
}
ImGui::SameLine();
if(ImGui::Button("del")) {
if(!s.empty()) {
if(s.back() == ' ') {
s.pop_back();
if(s.back() == '(' || s.back() == ')') {
parenthesis = !parenthesis;
}
s.pop_back();
s.pop_back();
} else {
s.pop_back();
}
}
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
if(ImGui::Button("+")) {
s += " + ";
}
if(ImGui::Button("-")) {
s += " - ";
}
if(ImGui::Button("*")) {
s += " * ";
}
if(ImGui::Button("/")) {
s += " / ";
}
ImGui::EndGroup();
ImGui::End();
}
}
void Calculator::graphingCalculator() {
}

View File

@@ -0,0 +1,35 @@
#include "Archimedes.h"
class Calculator : public Archimedes::Module {
public:
Calculator(Archimedes::App*, void*);
Calculator() { name = "Calculator"; }
~Calculator();
void onLoad();
void run();
private:
bool open = true;
bool parenthesis = true;
bool graphing = false;
void basicCalculator();
std::string calculate(std::string);
double evaluate(std::string, std::unordered_map<char, std::string>&);
void index(std::string, std::unordered_map<unsigned int, std::string>&);
void graphingCalculator();
};
#ifdef CALCULATOR_DYNAMIC
typedef Calculator mtype;
#include "endModule.h"
#endif

View File

@@ -1,7 +1,7 @@
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
#include "modules/ClientModule/src/ClientModule.h" #include "modules/ClientModule/ClientModule.h"
#include "ChatClient.h" #include "ChatClient.h"

View File

@@ -23,6 +23,6 @@ class ChatClient : public Archimedes::Module {
}; };
#ifdef CHATCLIENT_DYNAMIC #ifdef CHATCLIENT_DYNAMIC
#define MODULE_TYPE ChatClient typedef ChatClient mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,6 +1,6 @@
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/ServerModule/src/ServerModule.h" #include "modules/ServerModule/ServerModule.h"
class ChatServer : public Archimedes::Module { class ChatServer : public Archimedes::Module {
@@ -29,6 +29,6 @@ class ChatServer : public Archimedes::Module {
}; };
#ifdef CHATSERVER_DYNAMIC #ifdef CHATSERVER_DYNAMIC
#define MODULE_TYPE ChatServer typedef ChatServer mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -0,0 +1,276 @@
#include "modules/ImguiModule/ImguiModule.h"
#include "modules/ClientModule/ClientModule.h"
#include "ChatClientVoice.h"
ChatClientVoice::ChatClientVoice(Archimedes::App* a, void* h) : Module(a, h) {
name = "ChatClientVoice";
ClientModule* cm = new ClientModule(a, h);
deps[*cm] = cm;
cm->shouldHandleEvents(ClientModule::CMEventEnum::ConnectionStatusChanged | ClientModule::CMEventEnum::DataSent);
ImguiModule* im = new ImguiModule(a, h);
deps[*im] = im;
}
ChatClientVoice::~ChatClientVoice() {
if(app) {
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
im->releaseContext(ImGui::GetCurrentContext());
//if(buf)
// delete [] buf;
}
}
void ChatClientVoice::onLoad() {
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
if(!im) {
std::cout << "No ImguiModule for ChatClientVoice!\n";
std::abort();
}
ImGui::SetCurrentContext(im->aquireContext());
ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
if(!cm) {
std::cout << "No ClientModule for ChatClientVoice!\n";
std::abort();
}
if(!SDL_Init(SDL_INIT_AUDIO)) {
std::cout << "Audio init failed!\n";
std::abort();
}
mic = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_RECORDING, NULL, NULL, NULL);
SDL_GetAudioStreamFormat(mic, &spec, NULL);
speaker = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, NULL, NULL);
//buf = new unsigned char[len];
}
void ChatClientVoice::run() {
static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
static unsigned char buf[10 * 1024];
if(!cm) {
std::cout << "No ClientModule for ChatClientVoice!\n";
std::abort();
}
if(open) {
static std::string s, addr = "127.0.0.1:9932";
ImGui::Begin("ChatClientVoice Module", &open);
ImGui::InputText("Server Address: ", &addr);
if(cm->isRunning() && cm->isConnected()) {
if(ImGui::Button("Disconnect") && cm->isRunning()) {
cm->sendReliable("srvcmd1", strlen("srvcmd1"));
//cm->stopClient();
}
} else {
if(ImGui::Button("Connect") && !cm->isRunning()) {
static SteamNetworkingIPAddr serverAddr;
serverAddr.ParseString(addr.c_str());
cm->startClient(serverAddr);
}
}
ImGui::Text("%s", messages.c_str());
ImGui::InputText("Message: ", &s);
if(cm->isConnected()) {
ImGui::SameLine();
if(ImGui::Button("send")) {
if(s == "/quit") {
cm->sendReliable("srvcmd1", strlen("srvcmd1"));
cm->stopClient();
} else if(s == "/shutdown") {
cm->sendReliable("srvcmd2", strlen("srvcmd2"));
//cm->stopClient();
} else {
s.insert(0, "client");
cm->sendReliable(s.c_str(), (uint32) s.length());
}
s.clear();
}
}
static float micVol = 1.0f;
static float speakerVol = 1.0f;
static bool micTest = false;
ImGui::SliderFloat("Mic Volume", &micVol, 0.0f, 1.0f);
ImGui::SliderFloat("Speaker Volume", &speakerVol, 0.0f, 1.0f);
ImGui::Checkbox("Mic test", &micTest);
if(!SDL_AudioStreamDevicePaused(mic)) {
SDL_SetAudioStreamGain(mic, micVol);
} else if(micTest) {
SDL_ClearAudioStream(mic);
SDL_ResumeAudioStreamDevice(mic);
SDL_SetAudioStreamGain(mic, micVol);
}
if(!SDL_AudioStreamDevicePaused(speaker)) {
SDL_SetAudioStreamGain(speaker, speakerVol);
} else if(micTest) {
SDL_ClearAudioStream(speaker);
SDL_ResumeAudioStreamDevice(speaker);
SDL_SetAudioStreamGain(speaker, speakerVol);
}
static int avail = 0;
if(micTest) {
avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic));
if(avail > 10) {
avail = SDL_GetAudioStreamData(mic, buf, avail);
SDL_PutAudioStreamData(speaker, buf, avail);
}
} else if(cm->isConnected()){
// if not testing, send to server.
avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic));
if(avail > 10) {
avail = SDL_GetAudioStreamData(mic, buf, avail);
cm->sendReliable(buf, avail);
}
}
ImGui::End();
} else {
app->emitEvent(new Archimedes::DoUnloadModuleEvent(*cm));
}
}
bool ChatClientVoice::onEvent(const Archimedes::Event& event) {
unsigned int type = app->getEventType(event);
static ClientModule* cm;
/*if(type == app->getEventType("DataSentEvent")) {
//we did this?
return true;
} else */
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
{ cm = (ClientModule*) moduleInstances[ClientModule()]; }
static std::string s;
if(std::string((const char*)e.msg->m_pData, 6) == "client") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
messages += "\n\n" + s;
} else if(std::string((const char*)e.msg->m_pData, 6) == "server") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
int serverCode = stoi(s);
switch(serverCode) {
case 0:
//start voice
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
SDL_ResumeAudioStreamDevice(mic);
SDL_ResumeAudioStreamDevice(speaker);
break;
case 1:
//stop voice and clear
SDL_PauseAudioStreamDevice(mic);
SDL_PauseAudioStreamDevice(speaker);
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
break;
case 2:
//disconnect
cm->stopClient();
break;
default:
break;
}
} else /*if(std::string((const char*)e.msg->m_pData, 6) == "audio:")*/ {
s = "audio data";
SDL_PutAudioStreamData(speaker, e.msg->m_pData, e.msg->m_cbSize);
}
//std::cerr << "Client Recieved: " << s << std::endl;
return true;
} else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
switch(e.info->m_info.m_eState) {
case k_ESteamNetworkingConnectionState_None:
// NOTE: We will get callbacks here when we destroy connections. You can ignore these.
break;
case k_ESteamNetworkingConnectionState_ClosedByPeer:
case k_ESteamNetworkingConnectionState_ProblemDetectedLocally:
{
SDL_PauseAudioStreamDevice(mic);
SDL_PauseAudioStreamDevice(speaker);
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
break;
}
case k_ESteamNetworkingConnectionState_Connecting:
{
break;
}
case k_ESteamNetworkingConnectionState_Connected:
//OnConnect
break;
default:
// Silences -Wswitch
break;
}
return false;
}
return false;
}

View File

@@ -0,0 +1,36 @@
#include "Archimedes.h"
#include <SDL3/SDL.h>
#include <SDL3/SDL_audio.h>
class ChatClientVoice : public Archimedes::Module {
public:
ChatClientVoice(Archimedes::App* a, void* h);
ChatClientVoice() { name = "ChatClientVoice"; }
~ChatClientVoice();
void onLoad() override;
void run() override;
bool onEvent(const Archimedes::Event&) override;
private:
std::string messages = "";
bool open = true;
SDL_AudioSpec spec;
SDL_AudioStream *mic, *speaker;
const int len = 10 * 1024;
};
#ifdef CHATCLIENTVOICE_DYNAMIC
typedef ChatClientVoice mtype;
#include "endModule.h"
#endif

View File

@@ -0,0 +1,131 @@
#include "ChatServerVoice.h"
void ChatServerVoice::onLoad() {
ServerModule* sm = (ServerModule*) moduleInstances[ServerModule()];
sm->startServer(9932);
}
//void ChatServerVoice::run() {}
bool ChatServerVoice::onEvent(const Archimedes::Event& event) {
unsigned int type = app->getEventType(event);
static ServerModule* sm;
/*if(type == app->getEventType("DataSentEvent")) {
//we did this?
return true;
} else */
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
{ sm = (ServerModule*) moduleInstances[ServerModule()]; }
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
static std::string s;
if(std::string((const char*)e.msg->m_pData, 6) == "client") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
for(auto& it : sm->getClients()) {
if(it.first != e.msg->m_conn)
sm->sendReliable(it.first, e.msg->m_pData, e.msg->m_cbSize);
else
sm->sendReliable(e.msg->m_conn, "client\nMessage sent\n", strlen("client\nMessage sent\n"));
}
} else if(std::string((const char*)e.msg->m_pData, 6) == "srvcmd") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
int cmdCode = stoi(s);
switch(cmdCode) {
case 0:
break;
case 1:
//disconnect
sm->disconnectClient(e.msg->m_conn);
break;
case 2:
for(auto& it : sm->getClients()) {
sm->sendReliable(it.first, "server2", strlen("server2"));
}
sm->stopServer();
app->end();
break;
default:
break;
}
} else /*if(std::string((const char*)e.msg->m_pData, 6) == "audio:")*/ {
s = "audio data";
for(auto& it : sm->getClients()) {
if(it.first != e.msg->m_conn)
sm->sendReliable(it.first, e.msg->m_pData, e.msg->m_cbSize);
}
}
//std::cerr << "Server Recieved: " << s << std::endl;
return true;
} else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
{ sm = (ServerModule*) moduleInstances[ServerModule()]; }
unsigned int numClients;
(void)sm->getClients(&numClients);
switch(e.info->m_info.m_eState) {
case k_ESteamNetworkingConnectionState_None:
// NOTE: We will get callbacks here when we destroy connections. You can ignore these.
break;
case k_ESteamNetworkingConnectionState_ClosedByPeer:
case k_ESteamNetworkingConnectionState_ProblemDetectedLocally:
{
if(numClients < 2) {
for(auto& it : sm->getClients()) {
sm->sendReliable(it.first, "server1", strlen("server1"));
}
}
break;
}
case k_ESteamNetworkingConnectionState_Connecting:
{
break;
}
case k_ESteamNetworkingConnectionState_Connected:
//OnConnect
if(numClients == 2) {
for(auto& it : sm->getClients()) {
sm->sendReliable(it.first, "server0", strlen("server0"));
}
} else if(numClients > 2) {
sm->sendReliable(e.info->m_hConn, "server0", strlen("server0"));
}
break;
default:
// Silences -Wswitch
break;
}
return false;
}
return false;
}

View File

@@ -0,0 +1,34 @@
#include "Archimedes.h"
#include "modules/ServerModule/ServerModule.h"
class ChatServerVoice : public Archimedes::Module {
public:
ChatServerVoice(Archimedes::App* a, void* h) : Module(a, h) {
name = "ChatServerVoice";
ServerModule* sm = new ServerModule(a, h);
deps[*sm] = sm;
sm->shouldHandleEvents(ServerModule::SMEventEnum::ConnectionStatusChanged | ServerModule::SMEventEnum::DataSent);
}
ChatServerVoice() { name = "ChatServerVoice"; }
~ChatServerVoice() {
if(app) {}
}
void onLoad();
//void run();
bool onEvent(const Archimedes::Event&);
};
#ifdef CHATSERVERVOICE_DYNAMIC
typedef ChatServerVoice mtype;
#include "endModule.h"
#endif

View File

@@ -0,0 +1,46 @@
#include "ChessServer.h"
void ChessServer::onLoad() {
ServerModule* sm = (ServerModule*) moduleInstances[ServerModule()];
sm->startServer(9932);
}
//void ChessServer::run() {}
bool ChessServer::onEvent(const Archimedes::Event& event) {
unsigned int type = app->getEventType(event);
/*if(type == app->getEventType("DataSentEvent")) {
//we did this?
return true;
} else */
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
static ServerModule* sm; { sm = (ServerModule*) moduleInstances[ServerModule()]; }
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize);
for(auto& it : sm->getClients()) {
if(it.first != e.msg->m_conn)
sm->sendReliable(it.first, s.c_str(), s.length());
}
return true;
} /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
//Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
return false;
}*/
return false;
}

View File

@@ -0,0 +1,34 @@
#include "Archimedes.h"
#include "modules/ServerModule/ServerModule.h"
class ChessServer : public Archimedes::Module {
public:
ChessServer(Archimedes::App* a, void* h) : Module(a, h) {
name = "ChessServer";
ServerModule* sm = new ServerModule(a, h);
deps[*sm] = sm;
sm->shouldHandleEvents(ServerModule::SMEventEnum::ConnectionStatusChanged | ServerModule::SMEventEnum::DataSent);
}
ChessServer() { name = "ChessServer"; }
~ChessServer() {
if(app) {}
}
void onLoad();
//void run();
bool onEvent(const Archimedes::Event&);
};
#ifdef CHESSSERVER_DYNAMIC
typedef ChessServer mtype;
#include "endModule.h"
#endif

View File

@@ -1,5 +1,5 @@
#include "Ollama.h" #include "Ollama.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
#include <sstream> #include <sstream>

View File

@@ -21,6 +21,6 @@ class Ollama : public Archimedes::Module {
}; };
#ifdef OLLAMA_DYNAMIC #ifdef OLLAMA_DYNAMIC
#define MODULE_TYPE Ollama typedef Ollama mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -10,6 +10,6 @@ class Print : public Archimedes::Module {
}; };
#ifdef PRINT_DYNAMIC #ifdef PRINT_DYNAMIC
#define MODULE_TYPE Print typedef Print mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -0,0 +1 @@
Example modules for Archimedes

View File

@@ -5,7 +5,7 @@
#include <fcntl.h> #include <fcntl.h>
#include "Terminal.h" #include "Terminal.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
Terminal::Terminal(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { Terminal::Terminal(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {

View File

@@ -16,6 +16,6 @@ class Terminal : public Archimedes::Module {
}; };
#ifdef TERMINAL_DYNAMIC #ifdef TERMINAL_DYNAMIC
#define MODULE_TYPE Terminal typedef Terminal mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,7 +1,7 @@
#include "Archimedes.h" #include "Archimedes.h"
class TestClay : public Archimedes::GuiModule { class TestClay : public Archimedes::Module {
public: public:
TestClay(void*, Archimedes::App&); TestClay(void*, Archimedes::App&);

View File

@@ -1,5 +1,5 @@
#include "TestImgui.h" #include "TestImgui.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {

View File

@@ -19,6 +19,6 @@ class TestImgui : public Archimedes::Module {
}; };
#ifdef TESTIMGUI_DYNAMIC #ifdef TESTIMGUI_DYNAMIC
#define MODULE_TYPE TestImgui typedef TestImgui mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -14,6 +14,6 @@ class TestNotCurses : public Archimedes::Module {
}; };
#ifdef TESTNOTCURSES_DYNAMIC #ifdef TESTNOTCURSES_DYNAMIC
#define MODULE_TYPE TestNotCurses typedef TestNotCurses mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -68,6 +68,6 @@ class ClientModule : public Archimedes::Module {
}; };
#ifdef CLIENTMODULE_DYNAMIC #ifdef CLIENTMODULE_DYNAMIC
#define MODULE_TYPE ClientModule typedef ClientModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -40,6 +40,10 @@ void ImguiModule::onLoad() {
window = wm->aquireWindow(); window = wm->aquireWindow();
#if RENDERER == 2
renderer = window->getRenderer()->getRendererImpl().renderer;
#endif
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
context = ImGui::CreateContext(); context = ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;

View File

@@ -4,12 +4,16 @@
#include "imgui.h" #include "imgui.h"
#include "misc/cpp/imgui_stdlib.h" #include "misc/cpp/imgui_stdlib.h"
#include "modules/WindowModule/src/WindowModule.h" #include "modules/WindowModule/WindowModule.h"
#if RENDERER == 1 #if RENDERER == 1
#include "backends/imgui_impl_opengl3.h" #include "backends/imgui_impl_opengl3.h"
#elif RENDERER == 2
#include "backends/imgui_impl_sdlrenderer3.h"
#endif #endif
#if WINDOW == 1 #if WINDOW == 1
@@ -69,6 +73,13 @@ class ImguiModule : public Archimedes::Module {
void rendererNewFrame() { ImGui_ImplOpenGL3_NewFrame(); } void rendererNewFrame() { ImGui_ImplOpenGL3_NewFrame(); }
void rendererRenderDrawData() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); } void rendererRenderDrawData() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); }
#elif RENDERER == 2
SDL_Renderer* renderer;
auto rendererInit() { return ImGui_ImplSDLRenderer3_Init(renderer); }
void rendererShutdown() { ImGui_ImplSDLRenderer3_Shutdown(); }
void rendererNewFrame() { ImGui_ImplSDLRenderer3_NewFrame(); }
void rendererRenderDrawData() { ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer); }
#endif #endif
#if WINDOW == 1 #if WINDOW == 1
@@ -83,6 +94,8 @@ class ImguiModule : public Archimedes::Module {
#elif WINDOW == 2 #elif WINDOW == 2
#if RENDERER == 1 #if RENDERER == 1
auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl().getWindow(), window->getWindowImpl().getContext()); } auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl().getWindow(), window->getWindowImpl().getContext()); }
#elif RENDERER == 2
auto windowInit() { return ImGui_ImplSDL3_InitForSDLRenderer(window->getWindowImpl().getWindow(), renderer); }
#endif #endif
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); } void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }
@@ -93,7 +106,7 @@ class ImguiModule : public Archimedes::Module {
}; };
#ifdef IMGUIMODULE_DYNAMIC #ifdef IMGUIMODULE_DYNAMIC
#define MODULE_TYPE ImguiModule typedef ImguiModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,5 +1,5 @@
#include "MainGUI.h" #include "MainGUI.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
MainGUI::MainGUI(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { MainGUI::MainGUI(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {

View File

@@ -17,6 +17,6 @@ class MainGUI : public Archimedes::Module {
}; };
#ifdef MAINGUI_DYNAMIC #ifdef MAINGUI_DYNAMIC
#define MODULE_TYPE MainGUI typedef MainGUI mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -52,7 +52,12 @@ class ServerModule : public Archimedes::Module {
} }
} }
std::map<HSteamNetConnection, unsigned int> getClients() const { return clients; } std::map<HSteamNetConnection, unsigned int> getClients(unsigned int* num = nullptr) const {
if(num) {
*num = numClients;
}
return clients;
}
void pollIncomingData(); void pollIncomingData();
@@ -88,7 +93,7 @@ class ServerModule : public Archimedes::Module {
}; };
#ifdef SERVERMODULE_DYNAMIC #ifdef SERVERMODULE_DYNAMIC
#define MODULE_TYPE ServerModule typedef ServerModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -57,6 +57,9 @@ bool WindowModule::onEvent(const Archimedes::Event& e) {
Archimedes::ResizeWindowEvent& event = (Archimedes::ResizeWindowEvent&) e; Archimedes::ResizeWindowEvent& event = (Archimedes::ResizeWindowEvent&) e;
renderer->w = event.width; renderer->w = event.width;
renderer->h = event.height; renderer->h = event.height;
#if WINDOW == 2
window->getWindowImpl().setSize(event.width, event.height);
#endif
return true; return true;
} else if(type == app->getEventType(Archimedes::CloseWindowEvent())) { } else if(type == app->getEventType(Archimedes::CloseWindowEvent())) {
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));

View File

@@ -6,6 +6,8 @@
#include "utils/Renderer/Renderer.h" #include "utils/Renderer/Renderer.h"
#include "utils/Window/Window.h" #include "utils/Window/Window.h"
static_assert(!(WINDOW == 1 && RENDERER == 2), "Window and Renderer are incompatible!\n");
class WindowModule : public Archimedes::Module { class WindowModule : public Archimedes::Module {
public: public:
@@ -37,14 +39,16 @@ class WindowModule : public Archimedes::Module {
window->setRenderer(renderer); window->setRenderer(renderer);
if(!renderer->init()) { if(!renderer->init(window->getWindowImpl().getWindow())) {
std::cout << "Renderer init failed!\n"; std::cout << "Renderer init failed!\n";
std::abort(); std::abort();
} }
} }
windowRefs++; windowRefs++;
#if RENDERER == 1
window->getWindowImpl().restoreContext(); window->getWindowImpl().restoreContext();
#endif
return window; return window;
} }
@@ -76,7 +80,7 @@ class WindowModule : public Archimedes::Module {
#ifdef WINDOWMODULE_DYNAMIC #ifdef WINDOWMODULE_DYNAMIC
#define MODULE_TYPE WindowModule typedef WindowModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,16 +0,0 @@
#include "DependsOnPrint.h"
DependsOnPrint::DependsOnPrint(Archimedes::App* a, void* h) : Module(a, h) {
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->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
}

View File

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

View File

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

View File

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

View File

@@ -1,37 +0,0 @@
#include "TestMenu.h"
TestMenu::TestMenu(Archimedes::App* a, void* h) : Module(a, h) {
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->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
break;
case 4:
app->end();
break;
default:
break;
}
}

View File

@@ -1,20 +0,0 @@
#include "Archimedes.h"
class TestMenu : public Archimedes::Module {
public:
TestMenu(Archimedes::App*, void*);
TestMenu() { name = "TestMenu"; }
~TestMenu();
void run();
void onLoad() {}
private:
int choice;
int num = 5;
};
#ifdef TESTMENU_DYNAMIC
#define MODULE_TYPE TestMenu
#include "endModule.h"
#endif

View File

@@ -1,7 +1,7 @@
#define ENTRYPOINT #define ENTRYPOINT
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/examples/TestImgui/src/TestImgui.h" #include "modules/Archimedes-Modules/TestImgui/TestImgui.h"
class ImguiEmbed : public Archimedes::App { class ImguiEmbed : public Archimedes::App {

View File

@@ -6,6 +6,7 @@ void MinimalApp::run() {
modules[m]->onLoad(); modules[m]->onLoad();
} }
// Main loop // Main loop
while (!done && !runOrder.empty()) { while (!done && !runOrder.empty()) {

View File

@@ -1,7 +1,7 @@
#define ENTRYPOINT #define ENTRYPOINT
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/Terminal/src/Terminal.h" #include "modules/Archimedes-Modules/Terminal/Terminal.h"
class TerminalEmbed : public Archimedes::App { class TerminalEmbed : public Archimedes::App {