Compare commits

...

48 Commits

Author SHA1 Message Date
0ab0f4af47 fix 2026-02-14 17:44:30 -06:00
d6f8036175 flake parts 2026-02-14 17:08:36 -06:00
f01bd49fb1 flake parts 2026-02-14 16:24:35 -06:00
874de65dba flake parts 2026-02-14 13:12:52 -06:00
f9f311c82b sandbox 2026-02-13 08:24:03 -06:00
ec8a9c9f4f triangle and imgui 2026-02-11 08:15:55 -06:00
6c33eada03 triangle 2026-02-11 00:03:05 -06:00
badb3c4ec8 triangle 2026-02-10 23:53:52 -06:00
0244f463c4 triangle? 2026-02-10 23:51:27 -06:00
1f22a661cd the great typo of 2026 2026-02-10 18:21:18 -06:00
80d64f5114 test triangle 2026-02-10 15:40:25 -06:00
3c593edeca test triangle 2026-02-10 14:43:43 -06:00
263f0201ca test triangle 2026-02-10 14:39:45 -06:00
65e15ecfa4 test triangle 2026-02-10 14:35:54 -06:00
7d777c9578 work on renderer 2026-02-10 13:52:56 -06:00
874a8a1115 work on renderer 2026-02-10 13:50:44 -06:00
e4d84686c4 work on renderer 2026-02-10 13:41:49 -06:00
914de55f85 work on renderer 2026-02-10 13:40:44 -06:00
6dba251457 work on renderer 2026-02-10 13:39:42 -06:00
dd1befc2a0 work on renderer 2026-02-10 13:37:49 -06:00
086e5f5126 work on renderer 2026-02-08 17:29:56 -06:00
f277dee1f7 polymorphic windows 2026-02-08 11:57:18 -06:00
bad4bd70bc folders 2026-02-08 00:32:46 -06:00
b97957ec53 use extratools 2026-02-07 12:49:47 -06:00
bedd7a5dfd prepare for audio implimentations 2026-02-07 12:45:55 -06:00
89ea39ee60 add extratools.h 2026-02-07 12:44:07 -06:00
e7544e1cc1 add extratools.h 2026-02-07 12:43:10 -06:00
98f990cb57 add concepts 2026-02-07 11:54:47 -06:00
9b0be39b91 start template refactor 2026-02-07 11:47:06 -06:00
9a89ab3bbc start template refactor 2026-02-07 11:45:43 -06:00
8b0192c9b8 Sketchy Multi Viewports 2026-02-05 23:59:11 -06:00
8581589bfe TestTriangle works 2026-02-04 17:31:17 -06:00
9dfabc6dae TestTriangle works 2026-02-04 15:42:30 -06:00
3f102638b0 work on TestTriangle 2026-02-04 14:37:06 -06:00
5ab345460c TestTriangle 2026-02-04 09:29:15 -06:00
e67df40233 TestTriangle 2026-02-04 09:04:44 -06:00
07b4518cb4 TestTriangle 2026-02-04 08:41:09 -06:00
43d950b035 add triangle test 2026-02-04 08:35:16 -06:00
78a8c9bf95 return to something that works 2026-02-04 00:30:52 -06:00
7a45547ad9 attempt multi-viewports 2026-02-03 21:21:27 -06:00
21080c5c63 debating submodules 2026-02-03 21:17:12 -06:00
68524696df spellcheck 2026-02-03 20:15:15 -06:00
8c0cba9397 ccls 2026-02-03 20:13:10 -06:00
afe6254317 ccls? 2026-02-03 20:04:07 -06:00
e38a83e521 ccls? 2026-02-03 20:01:32 -06:00
7517ee8593 scope 2026-02-03 18:16:37 -06:00
148ed1253c try dev shell 2026-02-03 18:15:37 -06:00
cd19db0b88 flakes shouldn't be executable 2026-02-03 14:35:38 -06:00
105 changed files with 2693 additions and 1201 deletions

10
.ccls Normal file
View File

@@ -0,0 +1,10 @@
clang++
-Isrc/include
-Isrc
-Ivendor/imgui
-Ivendor/notcurses/include
-Ivendor/GameNetworkingSockets/include
-DWINDOW_GLFW
-DWINDOW_SDL3
-DRENDERER_OPENGL
-DRENDERER_SDL3

5
.gitignore vendored
View File

@@ -1 +1,4 @@
vendor/*
vendor/
.ccls-cache/
imgui.ini
result*

View File

@@ -1,121 +0,0 @@
{ inputs, pkgs, ... }: {
MinimalApp = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = ./.;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
clang
];
/*buildInputs = with pkgs; [
];*/
buildPhase = ''
clang++ \
src/example_apps/MinimalApp/MinimalApp.cpp \
-I src -I include \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
'';
};
ImguiEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
src/example_apps/ImguiEmbed/*.cpp \
modules/Archimedes-Modules/TestImgui/*.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 \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
TerminalEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
src/example_apps/TerminalEmbed/*.cpp \
modules/Archimedes-Modules/Terminal/*.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 \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
}

View File

@@ -1,513 +0,0 @@
{ inputs, pkgs, ... }: {
TestMenu = pkgs.stdenvNoCC.mkDerivation {
name = "TestMenu";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestMenu/*.cpp \
-fpic -shared \
-Wall \
-DTESTMENU_DYNAMIC \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
TestNotCurses = pkgs.stdenvNoCC.mkDerivation {
name = "TestNotCurses";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
notcurses
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestNotCurses/*.cpp \
-fpic -shared \
-I include \
-Wall \
-lnotcurses \
-DTESTNOTCURSES_DYNAMIC \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
Print = pkgs.stdenvNoCC.mkDerivation {
name = "Print";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \
-I include \
-Wall \
-DPRINT_DYNAMIC \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
DependsOnPrint = pkgs.stdenvNoCC.mkDerivation {
name = "DependsOnPrint";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/DependsOnPrint/*.cpp \
-fpic -shared \
-I include \
-Wall \
-DDEPENDSONPRINT_DYNAMIC \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
DependsOnPrintStatic = pkgs.stdenvNoCC.mkDerivation {
name = "DependsOnPrintStatic";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/DependsOnPrintStatic/*.cpp \
modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \
-I include -I . \
-DDEPENDSONPRINTSTATIC_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
TestImgui = pkgs.stdenvNoCC.mkDerivation {
name = "TestImgui";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestImgui/*.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 \
-DTESTIMGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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 . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
TestClay = pkgs.stdenvNoCC.mkDerivation {
name = "TestClay";
src = ./.;
clay = inputs.clay;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestClay/*.cpp \
-fpic -shared \
-I include \
-DRENDERER=1 \
-DWINDOW=1 \
-DTESTCLAY_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ChatServer = pkgs.stdenvNoCC.mkDerivation {
name = "ChatServer";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Chat/ChatServer/*.cpp \
modules/ServerModule/*.cpp \
-fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I include -I . \
-lGameNetworkingSockets \
-DCHATSERVER_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
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 {
name = "ChatClient";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Chat/ChatClient/*.cpp \
modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCHATCLIENT_DYNAMIC \
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 \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
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 . \
-lEGL -lSDL3 -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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 . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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 . \
-lEGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
}

17
dev/overlays.nix Normal file
View File

@@ -0,0 +1,17 @@
{ self, inputs, ... }: {
flake.overlays.glfw-old = (final: prev: let
pkgs-old = import inputs.nixpkgs-old { system = prev.stdenv.hostPlatform.system; };
in { glfw = pkgs-old.glfw; });
perSystem = { lib, system, pkgs, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
self.overlays.glfw-old
];
config = {};
};
};
}

29
dev/shells.nix Normal file
View File

@@ -0,0 +1,29 @@
{ ... }: {
perSystem = { config, system, pkgs, self', inputs', ... }: {
devShells.default = pkgs.mkShellNoCC {
packages = with pkgs; [
clang
glfw
glew
sdl3
curl
glm
nlohmann_json
stb
gamenetworkingsockets
];
shellHook = ''
'';
};
};
}

6
dev/systems.nix Normal file
View File

@@ -0,0 +1,6 @@
{ ... }: {
systems = [
"x86_64-linux"
];
}

81
flake.lock generated Executable file → Normal file
View File

@@ -16,14 +16,32 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1769996383,
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"imgui": {
"flake": false,
"locked": {
"lastModified": 1769795052,
"narHash": "sha256-JRA4E/aFcEEoB9FYHcLcEs4tgcX41ix2VjMV61PVQeA=",
"lastModified": 1770923283,
"narHash": "sha256-EOhlmnhoJRNjU7o7aCXnRrOw7JM0nq0VWDVnUJ6A6Xo=",
"owner": "ocornut",
"repo": "imgui",
"rev": "913a3c60561bb07e8fd410ec7d4a8f6f485defd6",
"rev": "3fb22b836ba968c62d280d9de079ec5ed7fcd1b5",
"type": "github"
},
"original": {
@@ -33,13 +51,28 @@
"type": "github"
}
},
"import-tree": {
"locked": {
"lastModified": 1771045967,
"narHash": "sha256-oYO4poyw0Sb/db2PigqugMlDwsvwLg6CSpFrMUWxA3Q=",
"owner": "vic",
"repo": "import-tree",
"rev": "c968d3b54d12cf5d9c13f16f7c545a06c9d1fde6",
"type": "github"
},
"original": {
"owner": "vic",
"repo": "import-tree",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1769900590,
"narHash": "sha256-I7Lmgj3owOTBGuauy9FL6qdpeK2umDoe07lM4V+PnyA=",
"lastModified": 1770770419,
"narHash": "sha256-iKZMkr6Cm9JzWlRYW/VPoL0A9jVKtZYiU4zSrVeetIs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "41e216c0ca66c83b12ab7a98cc326b5db01db646",
"rev": "6c5e707c6b5339359a9a9e215c5e66d6d802fd7a",
"type": "github"
},
"original": {
@@ -49,11 +82,45 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1769909678,
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "72716169fe93074c333e8d0173151350670b824c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-old": {
"locked": {
"lastModified": 1720535198,
"narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"clay": "clay",
"flake-parts": "flake-parts",
"imgui": "imgui",
"nixpkgs": "nixpkgs"
"import-tree": "import-tree",
"nixpkgs": "nixpkgs",
"nixpkgs-old": "nixpkgs-old"
}
}
},

262
flake.nix Executable file → Normal file
View File

@@ -3,6 +3,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
nixpkgs-old.url = "github:nixos/nixpkgs/nixos-23.11"; # Until Dear ImGUI has multi viewports on wayland
imgui = {
url = "github:ocornut/imgui?ref=docking";
flake = false;
@@ -11,258 +12,17 @@
url = "github:nicbarker/clay";
flake = false;
};
flake-parts.url = "github:hercules-ci/flake-parts";
import-tree.url = "github:vic/import-tree";
};
outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
outputs = { self, flake-parts, import-tree, ... } @ inputs:
flake-parts.lib.mkFlake {
inputs = inputs // {
src = ./src;
};
} (import-tree [ ./src ./dev ]);
Archimedes = {
examples = import ./ExampleApps.nix { inherit inputs; inherit pkgs; };
};
Modules = {
examples = import ./ExampleModules.nix { inherit inputs; inherit pkgs; };
ServerModule = pkgs.stdenvNoCC.mkDerivation {
name = "ServerModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/ServerModule/*.cpp \
-fpic -shared \
-I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DSERVERMODULE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ClientModule = pkgs.stdenvNoCC.mkDerivation {
name = "ClientModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/ClientModule/*.cpp \
-fpic -shared \
-I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCLIENTMODULE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
WindowModule = pkgs.stdenvNoCC.mkDerivation {
name = "WindowModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/WindowModule/*.cpp \
-fpic -shared \
-I include \
-DRENDERER=1 \
-DWINDOW=1 \
-DWINDOWMODULE_DYNAMIC \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ImguiModule = pkgs.stdenvNoCC.mkDerivation {
name = "ImguiModule";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
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 \
-DIMGUIMODULE_DYNAMIC \
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
MainGUIsdl = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
sdl3
];
buildPhase = ''
clang++ \
modules/MainGUI/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_sdl3.cpp \
$imgui/backends/imgui_impl_sdlrenderer3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=2 \
-DWINDOW=2 \
-DMAINGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lSDL3 \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
MainGUI = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/MainGUI/*.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 \
-DMAINGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
packages.${system}.default = self.Archimedes.examples.MinimalApp;
apps.${system}.default = {
type = "app";
program = "${self.Archimedes.examples.MinimalApp}/bin/Archimedes";
};
};
}

View File

@@ -1,34 +0,0 @@
#ifndef RENDERER_H
#define RENDERER_H
#include "pch.hpp"
#include "RendererOpenGL/RendererOpenGL.h"
#include "RendererSDL3/RendererSDL3.h"
namespace Archimedes {
class Renderer {
public:
int w, h;
~Renderer() {}
bool init(void* ptr) { return r.init(ptr); }
void render() {
r.render(rc, w, h);
}
std::list<std::function<void()>>& getCmdList() {
return rc;
}
RendererImpl& getRendererImpl() { return r; }
private:
std::list<std::function<void()>> rc;
RendererImpl r;
};
}
#endif

View File

@@ -1,44 +0,0 @@
#if RENDERER == 1
#ifndef RENDERER_OPENGL
#define RENDERER_OPENGL
#include "pch.hpp"
#define GLEW_STATIC
#include <GL/glew.h>
namespace Archimedes {
class RendererOpenGL {
public:
typedef void renderCmd();
RendererOpenGL() {};
~RendererOpenGL() {};
bool init(void* p) {
return glewInit() == GLEW_OK;
};
void render(std::list<std::function<void()>> cmdList, int& w, int& h) {
glViewport(0, 0, w, h);
glClear(GL_COLOR_BUFFER_BIT);
for(auto f : cmdList)
f();
}
};
typedef RendererOpenGL RendererImpl;
}
#endif
#endif

View File

@@ -1,47 +0,0 @@
#ifndef WINDOW_H
#define WINDOW_H
#include "WindowEvents.h"
#include "utils/Renderer/Renderer.h"
#include "WindowGLFW/WindowGLFW.h"
#include "WindowSDL3/WindowSDL3.h"
namespace Archimedes {
class Window {
public:
Window(const std::function<void(Event*)>& sendEventFn) : window(this, sendEventFn) {}
~Window() {}
bool shouldClose() { return window.shouldClose(); }
void getSize(int& w, int& h) {
window.getSize(w, h);
}
void doFrame() {
renderer->render();
window.doFrame();
window.pollEvents();
}
Renderer* getRenderer() { return renderer; }
void setRenderer(Renderer* r) { renderer = r; }
WindowImpl& getWindowImpl() { return window; }
private:
Renderer* renderer;
WindowImpl window;
};
}
#endif

View File

@@ -1,31 +1,71 @@
#include "ImguiEmbed.h"
bool ImguiEmbed::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 ImguiEmbed::run() {
for(auto m : runOrder)
for(std::string m : runOrder) {
modules[m]->onLoad();
}
// Main loop
while (!done && !runOrder.empty()) {
for(auto m : runOrder) {
for(std::string m : runOrder) {
modules[m]->run();
}
for(auto m : toClose) {
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)) {
load(std::get<std::string>(m))->onLoad();
n = load(std::get<std::string>(m));
} else {
load(std::get<Archimedes::Module*>(m))->onLoad();
n = load(std::get<Archimedes::Module*>(m));
}
if(n) {
n->onLoad();
n = nullptr;
}
}
toOpen.clear();
}
}

View File

@@ -1,7 +1,7 @@
#define ENTRYPOINT
#include "Archimedes.h"
#include "modules/Archimedes-Modules/TestImgui/TestImgui.h"
#include "modules/MainGUI/MainGUI.h"
class ImguiEmbed : public Archimedes::App {
@@ -13,7 +13,7 @@ class ImguiEmbed : public Archimedes::App {
public:
ImguiEmbed() {
Archimedes::Module* m = (Archimedes::Module*) new TestImgui(Get(), nullptr);
Archimedes::Module* m = (Archimedes::Module*) new MainGUI(Get(), nullptr);
load(m);
};

View File

@@ -0,0 +1,55 @@
{ inputs, ... }: {
perSystem = { lib, system, pkgs, ... }: {
packages.exampleApps_ImguiEmbed = 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++ \
$src/example_apps/ImguiEmbed/*.cpp \
$src/modules/MainGUI/*.cpp \
$src/modules/WindowModule/*.cpp \
$src/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 $src/include -I $imgui -I $src \
-lEGL -lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,38 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_MinimalApp = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
$src/example_apps/MinimalApp/MinimalApp.cpp \
-I $src/include \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
'';
};
};
}

View File

@@ -0,0 +1,48 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_TerminalEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
example_apps/TerminalEmbed/*.cpp \
modules/Archimedes-Modules/Terminal/*.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 \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,71 @@
#include "TriangleEmbed.h"
bool TriangleEmbed::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 TriangleEmbed::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/TestTriangle/TestTriangle.h"
class TriangleEmbed : public Archimedes::App {
private:
void printHelp() override {};
bool onEvent(const Archimedes::Event&) override;
public:
TriangleEmbed() {
Archimedes::Module* m = (Archimedes::Module*) new TestTriangle(Get(), nullptr);
load(m);
};
~TriangleEmbed() {};
void handleArgs(const int& argc, char* argv[]) override {};
void run() override;
};
#define APP_TYPE TriangleEmbed
#include "endApp.h"

View File

@@ -0,0 +1,49 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_TriangleEmbed = 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++ \
src/example_apps/TriangleEmbed/*.cpp \
modules/Archimedes-Modules/TestTriangle/*.cpp \
modules/WindowModule/*.cpp \
-DRENDERER_OPENGL=1 \
-DWINDOW_GLFW=1 \
-I include -I . \
-lEGL -lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
}; };
}

12
src/include/extratools.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef EXTRATOOLS_H
#define EXTRATOOLS_H
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <nlohmann/json.hpp>
#include <curl/curl.h>
#endif

View File

@@ -2,6 +2,7 @@
#define PCH_HPP
#include <iostream>
#include <fstream>
#include <cstring>
#include <cassert>
#include <list>
@@ -17,6 +18,7 @@
#include <optional>
#include <chrono>
//#include <thread>
#include <concepts>
#include <dlfcn.h>

View File

@@ -0,0 +1,23 @@
#ifndef OBJECT_H
#define OBJECT_H
#include "pch.hpp"
#include "extratools.h"
namespace Archimedes {
class Object {
public:
Object() {};
~Object() {};
private:
glm::mat4 worldTransform = glm::mat4(1.0f);
};
}
#endif

View File

@@ -0,0 +1,195 @@
#ifndef RENDERTARGET_H
#define RENDERTARGET_H
#include "pch.hpp"
#include "extratools.h"
namespace Archimedes {
class LayoutElement {
public:
LayoutElement(unsigned int type, size_t count) : type(type), count(count) {}
~LayoutElement() {}
unsigned int getType() const { return type; }
size_t getSize() const { return size; }
size_t getCount() const { return count; }
private:
unsigned int type;
size_t size;
size_t count;
};
class VertexLayout {
public:
VertexLayout() {}
~VertexLayout() {}
const std::vector<LayoutElement>& getElements() const { return elements; }
private:
std::vector<LayoutElement> elements;
};
class VertexBuffer {
public:
VertexBuffer(const void* data, size_t size) : data(data), size(size) {
}
VertexBuffer() {}
~VertexBuffer() {}
const void* getData() const { return data; }
size_t getSize() const { return size; }
unsigned int id;
private:
const void* data;
size_t size;
};
class VertexArray {
public:
VertexArray() {
}
~VertexArray() {}
unsigned int id;
private:
};
class IndexArray {
public:
IndexArray(const unsigned int* indices, size_t count) : indices(indices), count(count) {
}
IndexArray() {}
~IndexArray() {}
const void* getIndicies() const { return indices; }
size_t getCount() const { return count; }
unsigned int id;
private:
const unsigned int* indices;
size_t count;
};
class Shader {
public:
enum class LoadType {
FromSource,
FromBin,
FromFileSource,
FromFileBin
};
Shader() {}
Shader(const std::string& vs, const std::string& fs, LoadType loadType) {
init(vs, fs, loadType);
}
~Shader() {}
void init(const std::string& vs, const std::string& fs, LoadType loadType) {
switch(loadType) {
case LoadType::FromSource:
this->vs = vs;
this->fs = fs;
break;
case LoadType::FromBin:
break;
case LoadType::FromFileSource:
this->vs = readSourceFile(vs);
this->fs = readSourceFile(fs);
break;
case LoadType::FromFileBin:
break;
default:
break;
}
}
std::string getVSource() const { return vs; }
std::string getFSource() const { return fs; }
unsigned int id;
private:
std::string vs;
std::string fs;
std::string readSourceFile(const std::string& path) {
std::ifstream file(path);
if(!file.is_open()) {
return "";
}
std::string s;
while(!file.eof()) {
file >> s;
}
return s;
}
};
class RenderTarget {
public:
RenderTarget(const void* data, size_t size, unsigned int* indices, size_t count, VertexLayout layout, const std::string& vs, const std::string& fs)
: vertexBuffer(data, size),
indexArray(indices, count),
layout(layout),
shader(vs, fs, Shader::LoadType::FromFileSource) {
}
RenderTarget(VertexBuffer vb, IndexArray ia, VertexLayout vl, Shader s)
: vertexBuffer(vb),
indexArray(ia),
layout(vl),
shader(s) {
}
RenderTarget() {}
~RenderTarget() {}
//private:
VertexBuffer vertexBuffer;
VertexArray vertexArray;
IndexArray indexArray;
VertexLayout layout;
Shader shader;
glm::mat4 transform = glm::mat4(1.0f);
};
}
#endif

View File

@@ -0,0 +1,47 @@
#ifndef RENDERER_H
#define RENDERER_H
#include "pch.hpp"
#include "extratools.h"
#include "RenderTarget.h"
namespace Archimedes {
class Renderer {
public:
int w, h;
glm::vec4 clearColor = { 0.0f, 0.0f, 0.0f, 1.0f };
Renderer() : w(0), h(0) {}
virtual ~Renderer() {}
virtual bool init() = 0;
virtual void render() = 0;
virtual Shader createShader(const std::string& vs, const std::string& fs, const Shader::LoadType& lt) = 0;
virtual void useShader(Shader& shader) = 0;
virtual RenderTarget createRenderTarget(
VertexBuffer vb,
IndexArray ia,
VertexLayout layout,
Shader& s
) = 0;
virtual void useRenderTarget(RenderTarget& rt) = 0;
virtual void draw(const RenderTarget&) = 0;
virtual Renderer* getRendererImpl() = 0;
};
}
#endif

View File

@@ -0,0 +1,231 @@
#ifdef RENDERER_OPENGL
#ifndef RENDERER_OPENGL_H
#define RENDERER_OPENGL_H
#include "pch.hpp"
#include "utils/Renderer/Renderer.h"
#define GLEW_STATIC
#include <GL/glew.h>
namespace Archimedes {
class RendererOpenGL : public Renderer {
public:
typedef void renderCmd();
RendererOpenGL() {};
~RendererOpenGL() {};
bool init() override {
bool ok = glewInit() == GLEW_OK;
if(ok) {
glEnable(GL_DEPTH_TEST);
}
return ok;
};
void render() override {
glViewport(0, 0, w, h);
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
Shader createShader(const std::string& vs, const std::string& fs, const Shader::LoadType& lt) override {
Shader shader(vs, fs, lt);
std::string vss = shader.getVSource();
std::string fss = shader.getFSource();
const char* vsc = vss.c_str();
const char* fsc = fss.c_str();
unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vsc, NULL);
glCompileShader(vertexShader);
// check for shader compile errors
int success;
char infoLog[512];
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// fragment shader
unsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fsc, NULL);
glCompileShader(fragmentShader);
// check for shader compile errors
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// link shaders
unsigned int shaderProgram = glCreateProgram();
glAttachShader(shaderProgram, vertexShader);
glAttachShader(shaderProgram, fragmentShader);
glLinkProgram(shaderProgram);
// check for linking errors
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
shader.id = shaderProgram;
return shader;
}
void useShader(Shader& shader) override {
std::string vss = shader.getVSource();
std::string fss = shader.getFSource();
const char* vsc = vss.c_str();
const char* fsc = fss.c_str();
unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vsc, NULL);
glCompileShader(vertexShader);
// check for shader compile errors
int success;
char infoLog[512];
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// fragment shader
unsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fsc, NULL);
glCompileShader(fragmentShader);
// check for shader compile errors
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// link shaders
unsigned int shaderProgram = glCreateProgram();
glAttachShader(shaderProgram, vertexShader);
glAttachShader(shaderProgram, fragmentShader);
glLinkProgram(shaderProgram);
// check for linking errors
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
shader.id = shaderProgram;
}
RenderTarget createRenderTarget(VertexBuffer vb, IndexArray ia, VertexLayout layout, Shader& s) override {
auto rt = RenderTarget(vb, ia, layout, s);
glGenVertexArrays(1, &rt.vertexArray.id);
glGenBuffers(1, &rt.vertexBuffer.id);
glBindVertexArray(rt.vertexArray.id);
glBindBuffer(GL_ARRAY_BUFFER, rt.vertexBuffer.id);
glBufferData(GL_ARRAY_BUFFER, vb.getSize(), vb.getData(), GL_STATIC_DRAW);
glGenBuffers(1, &rt.indexArray.id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, rt.indexArray.id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, rt.indexArray.getCount() * sizeof(unsigned int), rt.indexArray.getIndicies(), GL_STATIC_DRAW);
glUseProgram(s.id);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return rt;
};
void useRenderTarget(RenderTarget& rt) override {
glGenVertexArrays(1, &rt.vertexArray.id);
glGenBuffers(1, &rt.vertexBuffer.id);
glBindVertexArray(rt.vertexArray.id);
glBindBuffer(GL_ARRAY_BUFFER, rt.vertexBuffer.id);
glBufferData(GL_ARRAY_BUFFER, rt.vertexBuffer.getSize(), rt.vertexBuffer.getData(), GL_STATIC_DRAW);
glGenBuffers(1, &rt.indexArray.id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, rt.indexArray.id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, rt.indexArray.getCount() * sizeof(unsigned int), rt.indexArray.getIndicies(), GL_STATIC_DRAW);
glUseProgram(rt.shader.id);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
};
void draw(const RenderTarget& rt) override {
glUseProgram(rt.shader.id);
unsigned int transformLoc = glGetUniformLocation(rt.shader.id, "model");
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(rt.transform));
unsigned int resLoc = glGetUniformLocation(rt.shader.id, "res");
glUniform2ui(resLoc, w, h);
unsigned int ccLoc = glGetUniformLocation(rt.shader.id, "clearColor");
glUniform4f(ccLoc, clearColor.r, clearColor.g, clearColor.b, clearColor.a);
glBindVertexArray(rt.vertexArray.id);
glDrawElements(GL_TRIANGLES, rt.indexArray.getCount(), GL_UNSIGNED_INT, nullptr);
glBindVertexArray(0);
}
RendererOpenGL* getRendererImpl() override { return this; }
};
}
#endif
#endif

View File

@@ -1,7 +1,6 @@
#if RENDERER == 2
#ifndef RENDERER_SDL3
#define RENDERER_SDL3
#ifdef RENDERER_SDL3
#ifndef RENDERER_SDL3_H
#define RENDERER_SDL3_H
#include "pch.hpp"
@@ -38,12 +37,7 @@ namespace Archimedes {
SDL_Renderer* renderer = nullptr;
};
typedef RendererSDL3 RendererImpl;
}
#endif
#endif

View File

@@ -0,0 +1,21 @@
#ifndef RENDERER_CONCEPTS
#define RENDERER_CONCEPTS
#include "pch.hpp"
namespace Archimedes {
class RendererOpenGL;
class RendererSDL3;
template <class RendererImpl>
concept allowed_renderers = requires (RendererImpl r) {
#ifndef CUSTOM_RENDERER
requires std::same_as<RendererImpl, RendererOpenGL>
|| std::same_as<RendererImpl, RendererSDL3>;
#endif
};
}
#endif

View File

@@ -0,0 +1,66 @@
#ifndef WINDOW_H
#define WINDOW_H
#include "WindowEvents.h"
#include "utils/Renderer/Renderer.h"
namespace Archimedes {
class Window {
public:
Window(const std::function<void(Event*)>& sendEventFn) : eventFn(sendEventFn) {}
virtual ~Window() {};
void doFrame() {
swapBuffers();
renderer->render();
pollEvents();
}
virtual bool shouldClose() = 0;
virtual void swapBuffers() = 0;
virtual void pollEvents() = 0;
virtual void restoreContext() = 0;
virtual void getSize(int& w, int& h) {
w = this->w;
h = this->h;
}
virtual void setSize(const int& w, const int& h) {
this->w = w;
this->h = h;
}
Renderer* getRenderer() { return renderer; }
void setRenderer(Renderer* r) {
renderer = r;
renderer->w = w;
renderer->h = h;
}
virtual Window* getWindowImpl() = 0;
protected:
int w, h;
Renderer* renderer;
std::function<void(Event*)> eventFn;
};
}
#endif

View File

@@ -1,11 +1,10 @@
#if WINDOW == 1
#ifndef WINDOW_GLFW
#define WINDOW_GLFW
#ifdef WINDOW_GLFW
#ifndef WINDOW_GLFW_H
#define WINDOW_GLFW_H
#include "pch.hpp"
#include "utils/Window/WindowEvents.h"
#include "utils/Window/Window.h"
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
@@ -13,20 +12,13 @@
namespace Archimedes {
class Window;
class WindowGLFW {
class WindowGLFW : public Window {
public:
WindowGLFW(Window* p, const std::function<void(Event*)>& sendEvent) {
WindowGLFW(const std::function<void(Event*)>& sendEvent) : Window(sendEvent) {
/*if(glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) {
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
}*/
data.window = p;
data.window = this;
data.sendEvent = sendEvent;
glfwSetErrorCallback([](int e, const char* m){
@@ -37,31 +29,39 @@ namespace Archimedes {
std::cout << "glfwInit failed!\n";
std::abort();
}
w = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL);
#ifdef RENDERER_OPENGL
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
#endif
if(!w) {
window = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL);
if(!window) {
std::cout << "glfwCreateWindow failed!\n";
glfwTerminate();
std::abort();
}
glfwMakeContextCurrent(w);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetWindowUserPointer(w, &data);
glfwSetWindowUserPointer(window, &data);
glfwSetWindowSizeCallback(w, [](GLFWwindow* window, int w, int h){
glfwSetWindowSizeCallback(window, [](GLFWwindow* window, int w, int h){
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new ResizeWindowEvent(w, h));
});
glfwSetWindowCloseCallback(w, [](GLFWwindow* window){
glfwSetWindowCloseCallback(window, [](GLFWwindow* window){
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new CloseWindowEvent(d.window));
});
glfwSetKeyCallback(w, [](GLFWwindow* window, int key, int scancode, int action, int mods){
glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods){
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
switch(action) {
@@ -77,7 +77,7 @@ namespace Archimedes {
}
});
glfwSetMouseButtonCallback(w, [](GLFWwindow* window, int button, int action, int mods){
glfwSetMouseButtonCallback(window, [](GLFWwindow* window, int button, int action, int mods){
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
switch(action) {
@@ -90,13 +90,13 @@ namespace Archimedes {
}
});
glfwSetScrollCallback(w, [](GLFWwindow* window, double dx, double dy){
glfwSetScrollCallback(window, [](GLFWwindow* window, double dx, double dy){
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new ScrollWindowEvent(dx, dy));
});
glfwSetCursorPosCallback(w, [](GLFWwindow* window, double dx, double dy){
glfwSetCursorPosCallback(window, [](GLFWwindow* window, double dx, double dy){
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new MouseMovedWindowEvent(dx, dy));
@@ -108,33 +108,39 @@ namespace Archimedes {
}
bool shouldClose() {
return glfwWindowShouldClose(w);
void swapBuffers() override { restoreContext(); glfwSwapBuffers(window); };
void pollEvents() override { glfwPollEvents(); }
bool shouldClose() override {
return glfwWindowShouldClose(window);
}
void doFrame() { restoreContext(); glfwSwapBuffers(w); }
void setSize(const int& w, const int& h) override {
this->w = w;
this->h = h;
void pollEvents() { glfwPollEvents(); }
void restoreContext() { glfwMakeContextCurrent(w); }
void getSize(int& w, int& h) {
glfwGetFramebufferSize(this->w, &w, &h);
glfwSetWindowSize(window, w, h);
}
GLFWwindow* getWindow() { return w; }
void restoreContext() override { glfwMakeContextCurrent(window); }
void getSize(int& w, int& h) override {
glfwGetFramebufferSize(window, &w, &h);
}
GLFWwindow* getWindow() { return window; }
WindowData data;
virtual WindowGLFW* getWindowImpl() override { return this; }
private:
GLFWwindow* w;
GLFWwindow* window;
};
typedef WindowGLFW WindowImpl;
}
#endif
#endif

View File

@@ -1,15 +1,14 @@
#if WINDOW == 2
#ifndef WINDOW_SDL3
#define WINDOW_SDL3
#ifdef WINDOW_SDL3
#ifndef WINDOW_SDL3_H
#define WINDOW_SDL3_H
#include "pch.hpp"
#include "utils/Window/WindowEvents.h"
#include "utils/Window/Window.h"
#include <SDL3/SDL.h>
#if RENDERER == 2
#ifdef RENDERER_OPENGL
#include <SDL3/SDL_opengl.h>
@@ -17,8 +16,6 @@
namespace Archimedes {
class Window;
static bool EventCallback(void* ptr, SDL_Event* e) {
WindowData& data = *(WindowData*) ptr;
@@ -66,13 +63,13 @@ namespace Archimedes {
return true;
}
class WindowSDL3 {
class WindowSDL3 : public Window {
public:
WindowSDL3(Window* p, const std::function<void(Event*)>& sendEvent) {
WindowSDL3(const std::function<void(Event*)>& sendEvent) : Window(sendEvent) {
data.window = p;
data.window = this;
data.sendEvent = sendEvent;
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
@@ -80,26 +77,27 @@ namespace Archimedes {
std::abort();
}
#if RENDERER == 1
#ifdef RENDERER_OPENGL
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
#elif RENDERER == 2
#endif
#ifdef RENDERER_SDL3
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
#endif
w = SDL_CreateWindow("Archimedes", 1280, 720, window_flags);
if (w == nullptr)
window = SDL_CreateWindow("Archimedes", 1280, 720, window_flags);
if (window == nullptr)
{
std::cerr << "Error: SDL_CreateWindow(): " << SDL_GetError() << std::endl;
std::abort();
}
SDL_SetWindowPosition(w, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
#if RENDERER == 1
gl_context = SDL_GL_CreateContext(w);
#ifdef RENDERER_OPENGL
gl_context = SDL_GL_CreateContext(window);
if (gl_context == nullptr)
{
@@ -107,67 +105,57 @@ namespace Archimedes {
std::abort();
}
SDL_GL_MakeCurrent(w, gl_context);
SDL_GL_MakeCurrent(window, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync
#endif
SDL_AddEventWatch(EventCallback, &data);
SDL_ShowWindow(w);
SDL_ShowWindow(window);
}
~WindowSDL3() {
#if RENDERER == 1
#ifdef RENDERER_OPENGL
SDL_GL_DestroyContext(gl_context);
#endif
SDL_RemoveEventWatch(EventCallback, &data);
SDL_DestroyWindow(w);
SDL_DestroyWindow(window);
SDL_Quit();
}
bool shouldClose() { return false; }
bool shouldClose() override { return false; }
void doFrame() {
#if RENDERER == 1
void swapBuffers() override {
#ifdef RENDERER_OPENGL
restoreContext();
SDL_GL_SwapWindow(w);
SDL_GL_SwapWindow(window);
#endif
}
void pollEvents() {
void pollEvents() override {
static SDL_Event e;
while(SDL_PollEvent(&e)) {}
while(SDL_PollEvent(&e));
}
#if RENDERER == 1
void restoreContext() { SDL_GL_MakeCurrent(w, gl_context); }
WindowSDL3* getWindowImpl() override { return this; };
#ifdef RENDERER_OPENGL
void restoreContext() override { SDL_GL_MakeCurrent(window, gl_context); }
#endif
void getSize(int& w, int& h) {
w = this->width;
h = this->height;
}
void setSize(int& w, int& h) {
this->width = w;
this->height = h;
}
SDL_Window* getWindow() { return w; }
#if RENDERER == 1
SDL_Window* getWindow() { return window; }
#ifdef RENDERER_OPENGL
SDL_GLContext getContext() { return gl_context; }
#endif
WindowData data;
private:
SDL_Window* w;
int width = 0, height = 0;
#if RENDERER == 1
SDL_Window* window;
#ifdef RENDERER_OPENGL
SDL_GLContext gl_context;
#endif
};
typedef WindowSDL3 WindowImpl;
}
#endif
#endif

View File

@@ -0,0 +1,25 @@
#ifndef WINDOW_CONCEPTS
#define WINDOW_CONCEPTS
#include "pch.hpp"
#include "utils/Renderer/concepts.h"
namespace Archimedes {
template <class R>
class WindowGLFW;
template <class R>
class WindowSDL3;
template <class WindowImpl, class R>
concept allowed_windows = requires (WindowImpl a, R b) {
#ifndef CUSTOM_WINDOW
requires std::same_as<WindowImpl, WindowGLFW<R>>
|| std::same_as<WindowImpl, WindowSDL3<R>>;
#endif
};
}
#endif

View File

@@ -151,6 +151,8 @@ double Calculator::evaluate(std::string equation, std::unordered_map<char, std::
default:
break;
}
return 0;
}
std::string Calculator::calculate(std::string equation) {

View File

@@ -17,7 +17,7 @@ class Calculator : public Archimedes::Module {
bool parenthesis = true;
bool graphing = false;
//bool graphing = false;
void basicCalculator();

View File

@@ -0,0 +1,56 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.Calculator = pkgs.stdenvNoCC.mkDerivation {
name = "Calculator";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
glm
nlohmann_json
curl
];
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_OPENGL=1 \
-DWINDOW_GLFW=1 \
-DCALCULATOR_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,54 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ChatClient = pkgs.stdenvNoCC.mkDerivation {
name = "ChatClient";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Chat/ChatClient/*.cpp \
modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCHATCLIENT_DYNAMIC \
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 \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,41 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ChatServer = pkgs.stdenvNoCC.mkDerivation {
name = "ChatServer";
src = inputs.src;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Chat/ChatServer/*.cpp \
modules/ServerModule/*.cpp \
-fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I include -I . \
-lGameNetworkingSockets \
-DCHATSERVER_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,54 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.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 . \
-lEGL -lSDL3 -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,41 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ChatServerVoice = pkgs.stdenvNoCC.mkDerivation {
name = "ChatServerVoice";
src = inputs.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
'';
};
};
}

View File

@@ -0,0 +1,54 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ChessClient = pkgs.stdenvNoCC.mkDerivation {
name = "ChatClient";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Chat/ChatClient/*.cpp \
modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCHATCLIENT_DYNAMIC \
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 \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,41 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ChessServer = pkgs.stdenvNoCC.mkDerivation {
name = "ChatServer";
src = inputs.src;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Chat/ChatServer/*.cpp \
modules/ServerModule/*.cpp \
-fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I include -I . \
-lGameNetworkingSockets \
-DCHATSERVER_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -1,7 +1,6 @@
#include "Archimedes.h"
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include "extratools.h"
class Ollama : public Archimedes::Module {

View File

@@ -0,0 +1,55 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.Ollama = pkgs.stdenvNoCC.mkDerivation {
name = "Ollama";
src = inputs.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 . \
-lEGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,34 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.Print = pkgs.stdenvNoCC.mkDerivation {
name = "Print";
src = inputs.src;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \
-I include \
-Wall \
-DPRINT_DYNAMIC \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,191 @@
// This only works with opengl!!!!
#include "Sandbox.h"
Sandbox::Sandbox(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
name = "Sandbox";
WindowModule* wm = new WindowModule(a, h);
deps[*wm] = wm;
ImguiModule* im = new ImguiModule(a, h);
deps[*im] = im;
}
Sandbox::~Sandbox() {
if(app) {
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
im->releaseContext(ImGui::GetCurrentContext());
wm->releaseWindow(window);
}
}
void Sandbox::onLoad() {
// get window
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
if(!wm) {
std::cout << "No WindowModule for Sandbox!\n";
std::abort();
}
if(!im) {
std::cout << "No ImguiModule for Sandbox!\n";
std::abort();
}
window = wm->aquireWindow();
ImGui::SetCurrentContext(im->aquireContext());
window->getRenderer()->clearColor = { 0.2, 0.2, 0.4, 0.7 };
gridShader = Archimedes::Shader(cubeVS, gridFS, Archimedes::Shader::LoadType::FromSource);
window->getRenderer()->useShader(gridShader);
grid = Archimedes::RenderTarget(
Archimedes::VertexBuffer(gridVertices, 12 * sizeof(float)),
Archimedes::IndexArray(gridIndices, 6),
Archimedes::VertexLayout(),
gridShader
);
window->getRenderer()->useRenderTarget(grid);
cubeShader = Archimedes::Shader(cubeVS, cubeFS, Archimedes::Shader::LoadType::FromSource);
window->getRenderer()->useShader(cubeShader);
cube = Archimedes::RenderTarget(
Archimedes::VertexBuffer(vertices, 24 * sizeof(float)),
Archimedes::IndexArray(indices, 36),
Archimedes::VertexLayout(),
cubeShader
);
window->getRenderer()->useRenderTarget(cube);
int w, h;
window->getSize(w, h);
app->emitEvent(new Archimedes::ResizeWindowEvent(w, h));
}
void Sandbox::run() {
static float scale = 100.0f;
static glm::vec3 pos(0), rot(0);
static glm::vec3 camPos(0.0f, 0.0f, 3.0f), camRot(0.0f, 0.0f, 0.0f);
static glm::mat4 orthoCamera, perspCamera, cameraTransform;
cameraTransform = glm::mat4(1.0f);
cameraTransform = glm::translate(cameraTransform, camPos);
cameraTransform = glm::rotate(cameraTransform, camRot.x, glm::vec3(1.0f, 0.0f, 0.0f));
cameraTransform = glm::rotate(cameraTransform, camRot.y, glm::vec3(0.0f, 1.0f, 0.0f));
cameraTransform = glm::rotate(cameraTransform, camRot.z, glm::vec3(0.0f, 0.0f, 1.0f));
int w, h;
window->getSize(w, h);
orthoCamera = glm::ortho(-(float)w / 2.0f, (float)w / 2.0f, -(float)h / 2.0f, (float)h / 2.0f, 0.1f, 100.0f)
* cameraTransform;
perspCamera = glm::perspective(glm::radians(45.0f), (float)w/(float)h, 0.1f, 100.0f)
* cameraTransform;
glm::mat4& cubeTransform = cube.transform;
//glm::mat4& gridTransform = grid.transform;
cubeTransform = glm::mat4(1.0f);
cubeTransform = glm::translate(cubeTransform, pos);
cubeTransform = glm::rotate(cubeTransform, rot.x, glm::vec3(1.0f, 0.0f, 0.0f));
cubeTransform = glm::rotate(cubeTransform, rot.y, glm::vec3(0.0f, 1.0f, 0.0f));
cubeTransform = glm::rotate(cubeTransform, rot.z, glm::vec3(0.0f, 0.0f, 1.0f));
cubeTransform = glm::scale(cubeTransform, glm::vec3(scale));
//gridTransform = glm::mat4(1.0f);
//gridTransform = glm::scale(gridTransform, glm::vec3(800.0f));
cubeTransform = orthoCamera * cubeTransform;
//gridTransform = orthoCamera * gridTransform;
/*
cubeTransform = glm::perspective(glm::radians(45.0f), (float)w/(float)h, 0.1f, 100.0f)
* glm::lookAt(glm::vec3(0.0f, 0.0f, 3.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f))
* cubeTransform;
*/
//window->getRenderer()->draw(grid);
window->getRenderer()->draw(cube);
{
ImGuiIO& io = ImGui::GetIO();
static glm::vec4& clearColor = window->getRenderer()->clearColor;
ImGui::Begin("Sandbox Module");
ImGui::Text("Pick a clear color!");
ImGui::SliderFloat("r", &clearColor.r, 0.0f, 1.0f);
ImGui::SliderFloat("g", &clearColor.g, 0.0f, 1.0f);
ImGui::SliderFloat("b", &clearColor.b, 0.0f, 1.0f);
ImGui::SliderFloat("a", &clearColor.a, 0.0f, 1.0f);
ImGui::Text("Properties");
ImGui::SliderFloat("pitch", &rot.x, -3.14159265359f, 3.14159265359f);
ImGui::SliderFloat("yaw", &rot.y, -3.14159265359f, 3.14159265359f);
ImGui::SliderFloat("roll", &rot.z, -3.14159265359f, 3.14159265359f);
ImGui::SliderFloat("scale", &scale, 0.1f, 1000.0f);
ImGui::SliderFloat("x", &pos.x, -100.0f, 100.0f);
ImGui::SliderFloat("y", &pos.y, -100.0f, 100.0f);
ImGui::SliderFloat("z", &pos.z, -100.0f, 100.0f);
ImGui::Text("Camera Properties");
ImGui::SliderFloat("c_pitch", &camRot.x, -3.14159265359f, 3.14159265359f);
ImGui::SliderFloat("c_yaw", &camRot.y, -3.14159265359f, 3.14159265359f);
ImGui::SliderFloat("c_roll", &camRot.z, -3.14159265359f, 3.14159265359f);
ImGui::SliderFloat("c_x", &camPos.x, -100.0f, 100.0f);
ImGui::SliderFloat("c_y", &camPos.y, -100.0f, 100.0f);
ImGui::SliderFloat("c_z", &camPos.z, -100.0f, 100.0f);
if(ImGui::Button("Reset Window Size")) {
app->emitEvent(new Archimedes::ResizeWindowEvent(500, 500));
}
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::End();
}
}
bool Sandbox::onEvent(const Archimedes::Event& e) {
return false;
}

View File

@@ -0,0 +1,161 @@
// This only works with opengl!!!!
#include "Archimedes.h"
#include "modules/WindowModule/WindowModule.h"
#include "modules/ImguiModule/ImguiModule.h"
class Sandbox : public Archimedes::Module {
public:
Sandbox(Archimedes::App*, void*);
Sandbox() { name = "Sandbox"; }
~Sandbox();
void onLoad() override;
void run() override;
bool onEvent(const Archimedes::Event& e) override;
private:
Archimedes::Window* window;
std::string cubeVS = "#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"uniform mat4 model;\n"
"uniform uvec2 res;\n"
"uniform vec4 clearColor;\n"
"void main()\n"
"{\n"
" gl_Position = model * vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
"}\0";
std::string cubeFS = "#version 330 core\n"
"out vec4 FragColor;\n"
"uniform mat4 model;\n"
"uniform uvec2 res;\n"
"uniform vec4 clearColor;\n"
"void main()\n"
"{\n"
" FragColor = vec4(0.6f, 0.1f, 0.1f, 1.0f);\n"
"}\n\0";
std::string gridFS = "#version 330 core\n"
"out vec4 FragColor;\n"
"uniform mat4 model;\n"
"uniform uvec2 res;\n"
"uniform vec4 clearColor;\n"
"vec2 pos = gl_FragCoord.xy - res / 2.0f;\n"
"int gridSpacing = 50;"
"void main()\n"
"{\n"
" switch((int(pos.x)) * (int(pos.y))) {\n"
" case 0:\n"
" FragColor = vec4(1.0f);\n"
" break;\n"
" default:\n"
" switch((int(pos.x) % gridSpacing) * (int(pos.y) % gridSpacing)) {\n"
" case 0:\n"
" FragColor = vec4(0.7f, 0.7f, 0.7f, 1.0f);\n"
" break;\n"
" default:\n"
" discard;\n"
" break;\n"
" }\n"
" break;\n"
" }\n"
"}\n\0";
Archimedes::Shader cubeShader, gridShader;
Archimedes::RenderTarget cube, grid;
float gridVertices[24] = {
-1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, -1.0f,
-1.0f, 0.0f, -1.0f,
};
unsigned int gridIndices[6] = {
0,
1,
2,
2,
3,
0
};
float vertices[24] = {
-0.5f, -0.5f, 0.5f,
0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f, -0.5f, -0.5f,
0.5f, -0.5f, -0.5f,
0.5f, 0.5f, -0.5f,
-0.5f, 0.5f, -0.5f,
};
unsigned int indices[36] = {
0,
1,
2,
2,
3,
0,
4,
5,
6,
6,
7,
4,
0,
1,
5,
5,
4,
0,
3,
2,
6,
6,
7,
3,
0,
3,
7,
7,
4,
0,
1,
2,
6,
6,
5,
1,
};
};
#ifdef SANDBOX_DYNAMIC
typedef Sandbox mtype;
#include "endModule.h"
#endif

View File

@@ -0,0 +1,56 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.Sandbox = pkgs.stdenvNoCC.mkDerivation {
name = "Sandbox";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
glm
curl
nlohmann_json
];
buildPhase = ''
clang++ \
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 \
-DSANDBOX_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,50 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.Terminal = pkgs.stdenvNoCC.mkDerivation {
name = "Terminal";
src = inputs.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 . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,38 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.TestClay = pkgs.stdenvNoCC.mkDerivation {
name = "TestClay";
src = inputs.src;
clay = inputs.clay;
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestClay/*.cpp \
-fpic -shared \
-I include \
-DRENDERER=1 \
-DWINDOW=1 \
-DTESTCLAY_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,50 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.TestImgui = pkgs.stdenvNoCC.mkDerivation {
name = "TestImgui";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestImgui/*.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 \
-DTESTIMGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -17,7 +17,7 @@ void TestNotCurses::onLoad() {
ncInstance = notcurses_init(&opts, NULL);
if(!ncInstance) {
app->stopModule(getName());
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
return;
}
}

View File

@@ -0,0 +1,39 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.TestNotCurses = pkgs.stdenvNoCC.mkDerivation {
name = "TestNotCurses";
src = inputs.src;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
notcurses
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestNotCurses/*.cpp \
-fpic -shared \
-I include \
-Wall \
-lnotcurses \
-DTESTNOTCURSES_DYNAMIC \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,67 @@
// This only works with opengl!!!!
#include "TestTriangle.h"
TestTriangle::TestTriangle(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
name = "TestTriangle";
WindowModule* wm = new WindowModule(a, h);
deps[*wm] = wm;
}
TestTriangle::~TestTriangle() {
if(app) {
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
/*
#if WINDOW == 2
wm->removeEventFn(ecmd_it);
#endif
*/
wm->releaseWindow(window);
}
}
void TestTriangle::onLoad() {
// get window
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
if(!wm) {
std::cout << "No WindowModule TestTriangle!\n";
std::abort();
}
window = wm->aquireWindow();
window->getRenderer()->clearColor = { 0.2, 0.2, 0.4, 0.7 };
shader = Archimedes::Shader(vertexShaderSource, fragmentShaderSource, Archimedes::Shader::LoadType::FromSource);
window->getRenderer()->useShader(shader);
rt = Archimedes::RenderTarget(
Archimedes::VertexBuffer(vertices, 9 * sizeof(float)),
Archimedes::IndexArray(indices, 3),
Archimedes::VertexLayout(),
shader
);
window->getRenderer()->useRenderTarget(rt);
}
void TestTriangle::run() {
window->getRenderer()->draw(rt);
}
bool TestTriangle::onEvent(const Archimedes::Event& e) {
return false;
}

View File

@@ -0,0 +1,64 @@
// This only works with opengl!!!!
#include "Archimedes.h"
#include "modules/WindowModule/WindowModule.h"
#define GLEW_STATIC
#include <GL/glew.h>
class TestTriangle : public Archimedes::Module {
public:
TestTriangle(Archimedes::App*, void*);
TestTriangle() { name = "TestTriangle"; }
~TestTriangle();
void onLoad() override;
void run() override;
bool onEvent(const Archimedes::Event& e) override;
private:
Archimedes::Window* window;
const char *vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
"}\0";
const char *fragmentShaderSource = "#version 330 core\n"
"out vec4 FragColor;\n"
"void main()\n"
"{\n"
" FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
"}\n\0";
Archimedes::RenderTarget rt;
Archimedes::Shader shader;
float vertices[9] = {
-0.5f, -0.5f, 0.0f, // left
0.5f, -0.5f, 0.0f, // right
0.0f, 0.5f, 0.0f // top
};
unsigned int indices[3] = {
0, // left
1, // right
2 // top
};
};
#ifdef TESTTRIANGLE_DYNAMIC
typedef TestTriangle mtype;
#include "endModule.h"
#endif

View File

@@ -0,0 +1,48 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.TestTriangle = pkgs.stdenvNoCC.mkDerivation {
name = "TestTriangle";
src = inputs.src;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
glm
nlohmann_json
curl
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/TestTriangle/*.cpp \
modules/WindowModule/*.cpp \
-DRENDERER_OPENGL=1 \
-DWINDOW_GLFW=1 \
-DTESTTRIANGLE_DYNAMIC \
-fpic -shared \
-I include -I . \
-lEGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,40 @@
{ ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ClientModule = pkgs.stdenvNoCC.mkDerivation {
name = "ClientModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/ClientModule/*.cpp \
-fpic -shared \
-I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCLIENTMODULE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -15,9 +15,7 @@ ImguiModule::~ImguiModule() {
if(app) {
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
wm->getRenderer()->getCmdList().erase(rcmd_it);
#if WINDOW == 2
#ifdef WINDOW_SDL3
wm->removeEventFn(ecmd_it);
#endif
@@ -38,10 +36,10 @@ void ImguiModule::onLoad() {
std::abort();
}
window = wm->aquireWindow();
window = (Archimedes::WindowGLFW*) wm->aquireWindow();
#if RENDERER == 2
renderer = window->getRenderer()->getRendererImpl().renderer;
#ifdef RENDERER_SDL3
renderer = window->getRenderer()->getRendererImpl()->renderer;
#endif
IMGUI_CHECKVERSION();
@@ -51,8 +49,8 @@ void ImguiModule::onLoad() {
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
#ifdef CUSTOMFONT
io.Fonts->AddFontFromFileTTF(STRINGIZE_VALUE_OF(CUSTOMFONT), 13.0f);
#endif
@@ -60,6 +58,18 @@ void ImguiModule::onLoad() {
ImGui::StyleColorsDark();
//ImGui::StyleColorsLight();
// Setup scaling
ImGuiStyle& style = ImGui::GetStyle();
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends
if(!windowInit())
std::cout << "windowInit failed\n";
@@ -68,19 +78,7 @@ void ImguiModule::onLoad() {
std::cout << "rendererInit failed!\n" << std::endl;
}
wm->getRenderer()->getCmdList().push_back([this](){
ImGui::Render();
rendererRenderDrawData();
rendererNewFrame();
windowNewFrame();
ImGui::NewFrame();
});
rcmd_it = --wm->getRenderer()->getCmdList().end()++;
#if WINDOW == 2
#ifdef WINDOW_SDL3
ecmd_it = wm->addEventFn([](Archimedes::Event* e){
if(e->userData.type() == typeid(SDL_Event*)) {
ImGui_ImplSDL3_ProcessEvent(std::any_cast<SDL_Event*>(e->userData));
@@ -92,30 +90,27 @@ void ImguiModule::onLoad() {
rendererNewFrame();
windowNewFrame();
ImGui::NewFrame();
}
void ImguiModule::run() {
ImGui::Render();
rendererRenderDrawData();
if(ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
window->getWindowImpl()->restoreContext();
}
rendererNewFrame();
windowNewFrame();
ImGui::NewFrame();
};
bool ImguiModule::onEvent(const Archimedes::Event &e) {
/*
#if WINDOW == 2
if(e.userData != nullptr) {
unsigned int type = app->getEventType(e);
if(type == app->getEventType(Archimedes::ResizeWindowEvent())
|| type == app->getEventType(Archimedes::CloseWindowEvent())
|| type == app->getEventType(Archimedes::KeyPressedWindowEvent())
|| type == app->getEventType(Archimedes::KeyReleasedWindowEvent())
|| type == app->getEventType(Archimedes::MouseButtonPressedWindowEvent())
|| type == app->getEventType(Archimedes::MouseButtonReleasedWindowEvent())
|| type == app->getEventType(Archimedes::ScrollWindowEvent())
|| type == app->getEventType(Archimedes::MouseMovedWindowEvent())
|| type == app->getEventType(Archimedes::FocusedWindowEvent())
|| type == app->getEventType(Archimedes::FocusLostWindowEvent())
|| type == app->getEventType(Archimedes::MovedWindowEvent())) {
ImGui_ImplSDL3_ProcessEvent((SDL_Event*) e.userData);
}
}
#endif
*/
return false;
}

View File

@@ -6,22 +6,24 @@
#include "modules/WindowModule/WindowModule.h"
#if RENDERER == 1
#ifdef RENDERER_OPENGL
#include "backends/imgui_impl_opengl3.h"
#elif RENDERER == 2
#endif
#ifdef RENDERER_SDL3
#include "backends/imgui_impl_sdlrenderer3.h"
#endif
#if WINDOW == 1
#ifdef WINDOW_GLFW
#include "backends/imgui_impl_glfw.h"
#include <GLFW/glfw3.h>
#elif WINDOW == 2
#endif
#ifdef WINDOW_SDL3
#include "backends/imgui_impl_sdl3.h"
#include <SDL3/SDL.h>
@@ -38,6 +40,8 @@ class ImguiModule : public Archimedes::Module {
~ImguiModule();
void onLoad() override;
void run() override;
bool onEvent(const Archimedes::Event&) override;
@@ -60,20 +64,20 @@ class ImguiModule : public Archimedes::Module {
ImGuiContext* context;
Archimedes::Window* window;
Archimedes::WindowGLFW* window;
std::list<std::function<void()>>::iterator rcmd_it;
std::list<std::function<void(Archimedes::Event*)>>::iterator ecmd_it;
#if RENDERER == 1
#ifdef RENDERER_OPENGL
auto rendererInit() { return ImGui_ImplOpenGL3_Init("#version 330"); }
void rendererShutdown() { ImGui_ImplOpenGL3_Shutdown(); }
void rendererNewFrame() { ImGui_ImplOpenGL3_NewFrame(); }
void rendererRenderDrawData() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); }
#elif RENDERER == 2
#endif
#ifdef RENDERER_SDL3
SDL_Renderer* renderer;
auto rendererInit() { return ImGui_ImplSDLRenderer3_Init(renderer); }
void rendererShutdown() { ImGui_ImplSDLRenderer3_Shutdown(); }
@@ -82,20 +86,23 @@ class ImguiModule : public Archimedes::Module {
void rendererRenderDrawData() { ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer); }
#endif
#if WINDOW == 1
#if RENDERER == 1
auto windowInit() { return ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true); }
#ifdef WINDOW_GLFW
#ifdef RENDERER_OPENGL
auto windowInit() { return ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl()->getWindow(), true); }
#endif
void windowShutdown() { ImGui_ImplGlfw_Shutdown(); }
void windowNewFrame() { ImGui_ImplGlfw_NewFrame(); }
#elif WINDOW == 2
#if RENDERER == 1
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
#ifdef WINDOW_SDL3
#ifdef RENDERER_OPENGL
auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl()->getWindow(), window->getWindowImpl()->getContext()); }
#endif
#ifdef RENDERER_SDL3
auto windowInit() { return ImGui_ImplSDL3_InitForSDLRenderer(window->getWindowImpl()->getWindow(), renderer); }
#endif
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }

View File

@@ -0,0 +1,50 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.ImguiModule = pkgs.stdenvNoCC.mkDerivation {
name = "ImguiModule";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
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 \
-DIMGUIMODULE_DYNAMIC \
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -56,6 +56,8 @@ void MainGUI::run() {
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::End();
ImGui::ShowDemoWindow();
} else {
app->end();
}

View File

@@ -0,0 +1,50 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.MainGUI = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/MainGUI/*.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 \
-DMAINGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

Some files were not shown because too many files have changed in this diff Show More