Compare commits
48 Commits
master
...
0ab0f4af47
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ab0f4af47 | |||
| d6f8036175 | |||
| f01bd49fb1 | |||
| 874de65dba | |||
| f9f311c82b | |||
| ec8a9c9f4f | |||
| 6c33eada03 | |||
| badb3c4ec8 | |||
| 0244f463c4 | |||
| 1f22a661cd | |||
| 80d64f5114 | |||
| 3c593edeca | |||
| 263f0201ca | |||
| 65e15ecfa4 | |||
| 7d777c9578 | |||
| 874a8a1115 | |||
| e4d84686c4 | |||
| 914de55f85 | |||
| 6dba251457 | |||
| dd1befc2a0 | |||
| 086e5f5126 | |||
| f277dee1f7 | |||
| bad4bd70bc | |||
| b97957ec53 | |||
| bedd7a5dfd | |||
| 89ea39ee60 | |||
| e7544e1cc1 | |||
| 98f990cb57 | |||
| 9b0be39b91 | |||
| 9a89ab3bbc | |||
| 8b0192c9b8 | |||
| 8581589bfe | |||
| 9dfabc6dae | |||
| 3f102638b0 | |||
| 5ab345460c | |||
| e67df40233 | |||
| 07b4518cb4 | |||
| 43d950b035 | |||
| 78a8c9bf95 | |||
| 7a45547ad9 | |||
| 21080c5c63 | |||
| 68524696df | |||
| 8c0cba9397 | |||
| afe6254317 | |||
| e38a83e521 | |||
| 7517ee8593 | |||
| 148ed1253c | |||
| cd19db0b88 |
10
.ccls
Normal file
10
.ccls
Normal 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
5
.gitignore
vendored
@@ -1 +1,4 @@
|
|||||||
vendor/*
|
vendor/
|
||||||
|
.ccls-cache/
|
||||||
|
imgui.ini
|
||||||
|
result*
|
||||||
|
|||||||
121
ExampleApps.nix
121
ExampleApps.nix
@@ -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
|
|
||||||
'';
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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
17
dev/overlays.nix
Normal 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
29
dev/shells.nix
Normal 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
6
dev/systems.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ ... }: {
|
||||||
|
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
}
|
||||||
81
flake.lock
generated
Executable file → Normal file
81
flake.lock
generated
Executable file → Normal file
@@ -16,14 +16,32 @@
|
|||||||
"type": "github"
|
"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": {
|
"imgui": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769795052,
|
"lastModified": 1770923283,
|
||||||
"narHash": "sha256-JRA4E/aFcEEoB9FYHcLcEs4tgcX41ix2VjMV61PVQeA=",
|
"narHash": "sha256-EOhlmnhoJRNjU7o7aCXnRrOw7JM0nq0VWDVnUJ6A6Xo=",
|
||||||
"owner": "ocornut",
|
"owner": "ocornut",
|
||||||
"repo": "imgui",
|
"repo": "imgui",
|
||||||
"rev": "913a3c60561bb07e8fd410ec7d4a8f6f485defd6",
|
"rev": "3fb22b836ba968c62d280d9de079ec5ed7fcd1b5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -33,13 +51,28 @@
|
|||||||
"type": "github"
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769900590,
|
"lastModified": 1770770419,
|
||||||
"narHash": "sha256-I7Lmgj3owOTBGuauy9FL6qdpeK2umDoe07lM4V+PnyA=",
|
"narHash": "sha256-iKZMkr6Cm9JzWlRYW/VPoL0A9jVKtZYiU4zSrVeetIs=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "41e216c0ca66c83b12ab7a98cc326b5db01db646",
|
"rev": "6c5e707c6b5339359a9a9e215c5e66d6d802fd7a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -49,11 +82,45 @@
|
|||||||
"type": "github"
|
"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": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"clay": "clay",
|
"clay": "clay",
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
"imgui": "imgui",
|
"imgui": "imgui",
|
||||||
"nixpkgs": "nixpkgs"
|
"import-tree": "import-tree",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"nixpkgs-old": "nixpkgs-old"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
260
flake.nix
Executable file → Normal file
260
flake.nix
Executable file → Normal file
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
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 = {
|
imgui = {
|
||||||
url = "github:ocornut/imgui?ref=docking";
|
url = "github:ocornut/imgui?ref=docking";
|
||||||
flake = false;
|
flake = false;
|
||||||
@@ -11,258 +12,17 @@
|
|||||||
url = "github:nicbarker/clay";
|
url = "github:nicbarker/clay";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
|
||||||
|
import-tree.url = "github:vic/import-tree";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
|
outputs = { self, flake-parts, import-tree, ... } @ inputs:
|
||||||
system = "x86_64-linux";
|
flake-parts.lib.mkFlake {
|
||||||
pkgs = import nixpkgs { inherit system; };
|
inputs = inputs // {
|
||||||
in {
|
src = ./src;
|
||||||
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
} (import-tree [ ./src ./dev ]);
|
||||||
|
|
||||||
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";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -1,31 +1,71 @@
|
|||||||
#include "ImguiEmbed.h"
|
#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() {
|
void ImguiEmbed::run() {
|
||||||
|
|
||||||
for(auto m : runOrder)
|
for(std::string m : runOrder) {
|
||||||
modules[m]->onLoad();
|
modules[m]->onLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (!done && !runOrder.empty()) {
|
while (!done && !runOrder.empty()) {
|
||||||
|
|
||||||
for(auto m : runOrder) {
|
for(std::string m : runOrder) {
|
||||||
modules[m]->run();
|
modules[m]->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto m : toClose) {
|
handleEvents();
|
||||||
|
|
||||||
|
for(std::string m : toClose) {
|
||||||
unload(m);
|
unload(m);
|
||||||
}
|
}
|
||||||
toClose.clear();
|
toClose.clear();
|
||||||
|
|
||||||
for(auto m : toOpen) {
|
for(auto m : toOpen) {
|
||||||
|
static Archimedes::Module* n;
|
||||||
if(std::holds_alternative<std::string>(m)) {
|
if(std::holds_alternative<std::string>(m)) {
|
||||||
load(std::get<std::string>(m))->onLoad();
|
n = load(std::get<std::string>(m));
|
||||||
} else {
|
} else {
|
||||||
load(std::get<Archimedes::Module*>(m))->onLoad();
|
n = load(std::get<Archimedes::Module*>(m));
|
||||||
|
}
|
||||||
|
if(n) {
|
||||||
|
n->onLoad();
|
||||||
|
n = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toOpen.clear();
|
toOpen.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#define ENTRYPOINT
|
#define ENTRYPOINT
|
||||||
#include "Archimedes.h"
|
#include "Archimedes.h"
|
||||||
|
|
||||||
#include "modules/Archimedes-Modules/TestImgui/TestImgui.h"
|
#include "modules/MainGUI/MainGUI.h"
|
||||||
|
|
||||||
class ImguiEmbed : public Archimedes::App {
|
class ImguiEmbed : public Archimedes::App {
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ class ImguiEmbed : public Archimedes::App {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ImguiEmbed() {
|
ImguiEmbed() {
|
||||||
Archimedes::Module* m = (Archimedes::Module*) new TestImgui(Get(), nullptr);
|
Archimedes::Module* m = (Archimedes::Module*) new MainGUI(Get(), nullptr);
|
||||||
|
|
||||||
load(m);
|
load(m);
|
||||||
};
|
};
|
||||||
|
|||||||
55
src/example_apps/ImguiEmbed/default.nix
Normal file
55
src/example_apps/ImguiEmbed/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
38
src/example_apps/MinimalApp/default.nix
Normal file
38
src/example_apps/MinimalApp/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
48
src/example_apps/TerminalEmbed/default.nix
Normal file
48
src/example_apps/TerminalEmbed/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
71
src/example_apps/TriangleEmbed/TriangleEmbed.cpp
Normal file
71
src/example_apps/TriangleEmbed/TriangleEmbed.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/example_apps/TriangleEmbed/TriangleEmbed.h
Normal file
29
src/example_apps/TriangleEmbed/TriangleEmbed.h
Normal 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"
|
||||||
49
src/example_apps/TriangleEmbed/default.nix
Normal file
49
src/example_apps/TriangleEmbed/default.nix
Normal 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
12
src/include/extratools.h
Normal 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
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#define PCH_HPP
|
#define PCH_HPP
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <list>
|
#include <list>
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
//#include <thread>
|
//#include <thread>
|
||||||
|
#include <concepts>
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
23
src/include/utils/Objects/Object.h
Normal file
23
src/include/utils/Objects/Object.h
Normal 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
|
||||||
195
src/include/utils/Renderer/RenderTarget.h
Normal file
195
src/include/utils/Renderer/RenderTarget.h
Normal 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
|
||||||
47
src/include/utils/Renderer/Renderer.h
Normal file
47
src/include/utils/Renderer/Renderer.h
Normal 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
|
||||||
@@ -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
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#if RENDERER == 2
|
#ifdef RENDERER_SDL3
|
||||||
|
#ifndef RENDERER_SDL3_H
|
||||||
#ifndef RENDERER_SDL3
|
#define RENDERER_SDL3_H
|
||||||
#define RENDERER_SDL3
|
|
||||||
|
|
||||||
#include "pch.hpp"
|
#include "pch.hpp"
|
||||||
|
|
||||||
@@ -38,12 +37,7 @@ namespace Archimedes {
|
|||||||
|
|
||||||
SDL_Renderer* renderer = nullptr;
|
SDL_Renderer* renderer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef RendererSDL3 RendererImpl;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
21
src/include/utils/Renderer/concepts.h
Normal file
21
src/include/utils/Renderer/concepts.h
Normal 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
|
||||||
66
src/include/utils/Window/Window.h
Normal file
66
src/include/utils/Window/Window.h
Normal 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
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
#if WINDOW == 1
|
#ifdef WINDOW_GLFW
|
||||||
|
#ifndef WINDOW_GLFW_H
|
||||||
#ifndef WINDOW_GLFW
|
#define WINDOW_GLFW_H
|
||||||
#define WINDOW_GLFW
|
|
||||||
|
|
||||||
#include "pch.hpp"
|
#include "pch.hpp"
|
||||||
|
|
||||||
#include "utils/Window/WindowEvents.h"
|
#include "utils/Window/Window.h"
|
||||||
|
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@@ -13,20 +12,13 @@
|
|||||||
|
|
||||||
namespace Archimedes {
|
namespace Archimedes {
|
||||||
|
|
||||||
class Window;
|
class WindowGLFW : public Window {
|
||||||
|
|
||||||
class WindowGLFW {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowGLFW(Window* p, const std::function<void(Event*)>& sendEvent) {
|
WindowGLFW(const std::function<void(Event*)>& sendEvent) : Window(sendEvent) {
|
||||||
|
|
||||||
/*if(glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) {
|
data.window = this;
|
||||||
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
data.window = p;
|
|
||||||
data.sendEvent = sendEvent;
|
data.sendEvent = sendEvent;
|
||||||
|
|
||||||
glfwSetErrorCallback([](int e, const char* m){
|
glfwSetErrorCallback([](int e, const char* m){
|
||||||
@@ -37,31 +29,39 @@ namespace Archimedes {
|
|||||||
std::cout << "glfwInit failed!\n";
|
std::cout << "glfwInit failed!\n";
|
||||||
std::abort();
|
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);
|
||||||
|
|
||||||
if(!w) {
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
window = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL);
|
||||||
|
|
||||||
|
if(!window) {
|
||||||
std::cout << "glfwCreateWindow failed!\n";
|
std::cout << "glfwCreateWindow failed!\n";
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
glfwMakeContextCurrent(w);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
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);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new ResizeWindowEvent(w, h));
|
d.sendEvent(new ResizeWindowEvent(w, h));
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetWindowCloseCallback(w, [](GLFWwindow* window){
|
glfwSetWindowCloseCallback(window, [](GLFWwindow* window){
|
||||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new CloseWindowEvent(d.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);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
switch(action) {
|
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);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
switch(action) {
|
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);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new ScrollWindowEvent(dx, dy));
|
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);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new MouseMovedWindowEvent(dx, dy));
|
d.sendEvent(new MouseMovedWindowEvent(dx, dy));
|
||||||
@@ -108,33 +108,39 @@ namespace Archimedes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool shouldClose() {
|
void swapBuffers() override { restoreContext(); glfwSwapBuffers(window); };
|
||||||
return glfwWindowShouldClose(w);
|
|
||||||
|
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(); }
|
glfwSetWindowSize(window, w, h);
|
||||||
|
|
||||||
void restoreContext() { glfwMakeContextCurrent(w); }
|
|
||||||
|
|
||||||
void getSize(int& w, int& h) {
|
|
||||||
glfwGetFramebufferSize(this->w, &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;
|
WindowData data;
|
||||||
|
|
||||||
|
virtual WindowGLFW* getWindowImpl() override { return this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFWwindow* w;
|
GLFWwindow* window;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef WindowGLFW WindowImpl;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
#if WINDOW == 2
|
#ifdef WINDOW_SDL3
|
||||||
|
#ifndef WINDOW_SDL3_H
|
||||||
#ifndef WINDOW_SDL3
|
#define WINDOW_SDL3_H
|
||||||
#define WINDOW_SDL3
|
|
||||||
|
|
||||||
#include "pch.hpp"
|
#include "pch.hpp"
|
||||||
|
|
||||||
#include "utils/Window/WindowEvents.h"
|
#include "utils/Window/Window.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#if RENDERER == 2
|
#ifdef RENDERER_OPENGL
|
||||||
|
|
||||||
#include <SDL3/SDL_opengl.h>
|
#include <SDL3/SDL_opengl.h>
|
||||||
|
|
||||||
@@ -17,8 +16,6 @@
|
|||||||
|
|
||||||
namespace Archimedes {
|
namespace Archimedes {
|
||||||
|
|
||||||
class Window;
|
|
||||||
|
|
||||||
static bool EventCallback(void* ptr, SDL_Event* e) {
|
static bool EventCallback(void* ptr, SDL_Event* e) {
|
||||||
|
|
||||||
WindowData& data = *(WindowData*) ptr;
|
WindowData& data = *(WindowData*) ptr;
|
||||||
@@ -66,13 +63,13 @@ namespace Archimedes {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class WindowSDL3 {
|
class WindowSDL3 : public Window {
|
||||||
|
|
||||||
public:
|
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;
|
data.sendEvent = sendEvent;
|
||||||
|
|
||||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
|
||||||
@@ -80,26 +77,27 @@ namespace Archimedes {
|
|||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RENDERER == 1
|
#ifdef RENDERER_OPENGL
|
||||||
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);
|
||||||
|
|
||||||
SDL_WindowFlags 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
|
#endif
|
||||||
|
#ifdef RENDERER_SDL3
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
w = SDL_CreateWindow("Archimedes", 1280, 720, window_flags);
|
window = SDL_CreateWindow("Archimedes", 1280, 720, window_flags);
|
||||||
if (w == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: SDL_CreateWindow(): " << SDL_GetError() << std::endl;
|
std::cerr << "Error: SDL_CreateWindow(): " << SDL_GetError() << std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
SDL_SetWindowPosition(w, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
|
|
||||||
#if RENDERER == 1
|
#ifdef RENDERER_OPENGL
|
||||||
gl_context = SDL_GL_CreateContext(w);
|
gl_context = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
if (gl_context == nullptr)
|
if (gl_context == nullptr)
|
||||||
{
|
{
|
||||||
@@ -107,67 +105,57 @@ namespace Archimedes {
|
|||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(w, gl_context);
|
SDL_GL_MakeCurrent(window, gl_context);
|
||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
#endif
|
#endif
|
||||||
SDL_AddEventWatch(EventCallback, &data);
|
SDL_AddEventWatch(EventCallback, &data);
|
||||||
|
|
||||||
SDL_ShowWindow(w);
|
SDL_ShowWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
~WindowSDL3() {
|
~WindowSDL3() {
|
||||||
#if RENDERER == 1
|
#ifdef RENDERER_OPENGL
|
||||||
SDL_GL_DestroyContext(gl_context);
|
SDL_GL_DestroyContext(gl_context);
|
||||||
#endif
|
#endif
|
||||||
SDL_RemoveEventWatch(EventCallback, &data);
|
SDL_RemoveEventWatch(EventCallback, &data);
|
||||||
SDL_DestroyWindow(w);
|
SDL_DestroyWindow(window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldClose() { return false; }
|
bool shouldClose() override { return false; }
|
||||||
|
|
||||||
void doFrame() {
|
void swapBuffers() override {
|
||||||
#if RENDERER == 1
|
#ifdef RENDERER_OPENGL
|
||||||
restoreContext();
|
restoreContext();
|
||||||
SDL_GL_SwapWindow(w);
|
SDL_GL_SwapWindow(window);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pollEvents() {
|
void pollEvents() override {
|
||||||
static SDL_Event e;
|
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
|
#endif
|
||||||
void getSize(int& w, int& h) {
|
|
||||||
w = this->width;
|
|
||||||
h = this->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSize(int& w, int& h) {
|
SDL_Window* getWindow() { return window; }
|
||||||
this->width = w;
|
#ifdef RENDERER_OPENGL
|
||||||
this->height = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Window* getWindow() { return w; }
|
|
||||||
#if RENDERER == 1
|
|
||||||
SDL_GLContext getContext() { return gl_context; }
|
SDL_GLContext getContext() { return gl_context; }
|
||||||
#endif
|
#endif
|
||||||
WindowData data;
|
WindowData data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Window* w;
|
SDL_Window* window;
|
||||||
int width = 0, height = 0;
|
#ifdef RENDERER_OPENGL
|
||||||
#if RENDERER == 1
|
|
||||||
SDL_GLContext gl_context;
|
SDL_GLContext gl_context;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef WindowSDL3 WindowImpl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
25
src/include/utils/Window/concepts.h
Normal file
25
src/include/utils/Window/concepts.h
Normal 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
|
||||||
@@ -151,6 +151,8 @@ double Calculator::evaluate(std::string equation, std::unordered_map<char, std::
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Calculator::calculate(std::string equation) {
|
std::string Calculator::calculate(std::string equation) {
|
||||||
@@ -17,7 +17,7 @@ class Calculator : public Archimedes::Module {
|
|||||||
|
|
||||||
bool parenthesis = true;
|
bool parenthesis = true;
|
||||||
|
|
||||||
bool graphing = false;
|
//bool graphing = false;
|
||||||
|
|
||||||
void basicCalculator();
|
void basicCalculator();
|
||||||
|
|
||||||
56
src/modules/Archimedes-Modules/Calculator/default.nix
Normal file
56
src/modules/Archimedes-Modules/Calculator/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
54
src/modules/Archimedes-Modules/Chat/ChatClient/default.nix
Normal file
54
src/modules/Archimedes-Modules/Chat/ChatClient/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
41
src/modules/Archimedes-Modules/Chat/ChatServer/default.nix
Normal file
41
src/modules/Archimedes-Modules/Chat/ChatServer/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
54
src/modules/Archimedes-Modules/Chess/ChessClient/default.nix
Normal file
54
src/modules/Archimedes-Modules/Chess/ChessClient/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
41
src/modules/Archimedes-Modules/Chess/ChessServer/default.nix
Normal file
41
src/modules/Archimedes-Modules/Chess/ChessServer/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "Archimedes.h"
|
#include "Archimedes.h"
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include "extratools.h"
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
class Ollama : public Archimedes::Module {
|
class Ollama : public Archimedes::Module {
|
||||||
|
|
||||||
55
src/modules/Archimedes-Modules/Ollama/default.nix
Normal file
55
src/modules/Archimedes-Modules/Ollama/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
34
src/modules/Archimedes-Modules/Print/default.nix
Normal file
34
src/modules/Archimedes-Modules/Print/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
191
src/modules/Archimedes-Modules/Sandbox/Sandbox.cpp
Normal file
191
src/modules/Archimedes-Modules/Sandbox/Sandbox.cpp
Normal 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;
|
||||||
|
}
|
||||||
161
src/modules/Archimedes-Modules/Sandbox/Sandbox.h
Normal file
161
src/modules/Archimedes-Modules/Sandbox/Sandbox.h
Normal 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
|
||||||
56
src/modules/Archimedes-Modules/Sandbox/default.nix
Normal file
56
src/modules/Archimedes-Modules/Sandbox/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
50
src/modules/Archimedes-Modules/Terminal/default.nix
Normal file
50
src/modules/Archimedes-Modules/Terminal/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
38
src/modules/Archimedes-Modules/TestClay/default.nix
Normal file
38
src/modules/Archimedes-Modules/TestClay/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
50
src/modules/Archimedes-Modules/TestImgui/default.nix
Normal file
50
src/modules/Archimedes-Modules/TestImgui/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ void TestNotCurses::onLoad() {
|
|||||||
ncInstance = notcurses_init(&opts, NULL);
|
ncInstance = notcurses_init(&opts, NULL);
|
||||||
|
|
||||||
if(!ncInstance) {
|
if(!ncInstance) {
|
||||||
app->stopModule(getName());
|
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
39
src/modules/Archimedes-Modules/TestNotCurses/default.nix
Normal file
39
src/modules/Archimedes-Modules/TestNotCurses/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
67
src/modules/Archimedes-Modules/TestTriangle/TestTriangle.cpp
Normal file
67
src/modules/Archimedes-Modules/TestTriangle/TestTriangle.cpp
Normal 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;
|
||||||
|
}
|
||||||
64
src/modules/Archimedes-Modules/TestTriangle/TestTriangle.h
Normal file
64
src/modules/Archimedes-Modules/TestTriangle/TestTriangle.h
Normal 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
|
||||||
48
src/modules/Archimedes-Modules/TestTriangle/default.nix
Normal file
48
src/modules/Archimedes-Modules/TestTriangle/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
40
src/modules/ClientModule/default.nix
Normal file
40
src/modules/ClientModule/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,9 +15,7 @@ ImguiModule::~ImguiModule() {
|
|||||||
if(app) {
|
if(app) {
|
||||||
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
|
WindowModule* wm; { wm = (WindowModule*) moduleInstances[WindowModule()]; }
|
||||||
|
|
||||||
wm->getRenderer()->getCmdList().erase(rcmd_it);
|
#ifdef WINDOW_SDL3
|
||||||
|
|
||||||
#if WINDOW == 2
|
|
||||||
wm->removeEventFn(ecmd_it);
|
wm->removeEventFn(ecmd_it);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -38,10 +36,10 @@ void ImguiModule::onLoad() {
|
|||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
window = wm->aquireWindow();
|
window = (Archimedes::WindowGLFW*) wm->aquireWindow();
|
||||||
|
|
||||||
#if RENDERER == 2
|
#ifdef RENDERER_SDL3
|
||||||
renderer = window->getRenderer()->getRendererImpl().renderer;
|
renderer = window->getRenderer()->getRendererImpl()->renderer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
@@ -51,7 +49,7 @@ void ImguiModule::onLoad() {
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
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
|
#ifdef CUSTOMFONT
|
||||||
io.Fonts->AddFontFromFileTTF(STRINGIZE_VALUE_OF(CUSTOMFONT), 13.0f);
|
io.Fonts->AddFontFromFileTTF(STRINGIZE_VALUE_OF(CUSTOMFONT), 13.0f);
|
||||||
@@ -60,6 +58,18 @@ void ImguiModule::onLoad() {
|
|||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//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
|
// Setup Platform/Renderer backends
|
||||||
if(!windowInit())
|
if(!windowInit())
|
||||||
std::cout << "windowInit failed\n";
|
std::cout << "windowInit failed\n";
|
||||||
@@ -68,19 +78,7 @@ void ImguiModule::onLoad() {
|
|||||||
std::cout << "rendererInit failed!\n" << std::endl;
|
std::cout << "rendererInit failed!\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
wm->getRenderer()->getCmdList().push_back([this](){
|
#ifdef WINDOW_SDL3
|
||||||
ImGui::Render();
|
|
||||||
|
|
||||||
rendererRenderDrawData();
|
|
||||||
|
|
||||||
rendererNewFrame();
|
|
||||||
windowNewFrame();
|
|
||||||
ImGui::NewFrame();
|
|
||||||
});
|
|
||||||
|
|
||||||
rcmd_it = --wm->getRenderer()->getCmdList().end()++;
|
|
||||||
|
|
||||||
#if WINDOW == 2
|
|
||||||
ecmd_it = wm->addEventFn([](Archimedes::Event* e){
|
ecmd_it = wm->addEventFn([](Archimedes::Event* e){
|
||||||
if(e->userData.type() == typeid(SDL_Event*)) {
|
if(e->userData.type() == typeid(SDL_Event*)) {
|
||||||
ImGui_ImplSDL3_ProcessEvent(std::any_cast<SDL_Event*>(e->userData));
|
ImGui_ImplSDL3_ProcessEvent(std::any_cast<SDL_Event*>(e->userData));
|
||||||
@@ -92,30 +90,27 @@ void ImguiModule::onLoad() {
|
|||||||
rendererNewFrame();
|
rendererNewFrame();
|
||||||
windowNewFrame();
|
windowNewFrame();
|
||||||
ImGui::NewFrame();
|
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) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -6,22 +6,24 @@
|
|||||||
|
|
||||||
#include "modules/WindowModule/WindowModule.h"
|
#include "modules/WindowModule/WindowModule.h"
|
||||||
|
|
||||||
#if RENDERER == 1
|
#ifdef RENDERER_OPENGL
|
||||||
|
|
||||||
#include "backends/imgui_impl_opengl3.h"
|
#include "backends/imgui_impl_opengl3.h"
|
||||||
|
|
||||||
#elif RENDERER == 2
|
#endif
|
||||||
|
#ifdef RENDERER_SDL3
|
||||||
|
|
||||||
#include "backends/imgui_impl_sdlrenderer3.h"
|
#include "backends/imgui_impl_sdlrenderer3.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WINDOW == 1
|
#ifdef WINDOW_GLFW
|
||||||
|
|
||||||
#include "backends/imgui_impl_glfw.h"
|
#include "backends/imgui_impl_glfw.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#elif WINDOW == 2
|
#endif
|
||||||
|
#ifdef WINDOW_SDL3
|
||||||
|
|
||||||
#include "backends/imgui_impl_sdl3.h"
|
#include "backends/imgui_impl_sdl3.h"
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
@@ -39,6 +41,8 @@ class ImguiModule : public Archimedes::Module {
|
|||||||
|
|
||||||
void onLoad() override;
|
void onLoad() override;
|
||||||
|
|
||||||
|
void run() override;
|
||||||
|
|
||||||
bool onEvent(const Archimedes::Event&) override;
|
bool onEvent(const Archimedes::Event&) override;
|
||||||
|
|
||||||
ImGuiContext* aquireContext() {
|
ImGuiContext* aquireContext() {
|
||||||
@@ -60,20 +64,20 @@ class ImguiModule : public Archimedes::Module {
|
|||||||
|
|
||||||
ImGuiContext* context;
|
ImGuiContext* context;
|
||||||
|
|
||||||
Archimedes::Window* window;
|
Archimedes::WindowGLFW* window;
|
||||||
|
|
||||||
std::list<std::function<void()>>::iterator rcmd_it;
|
std::list<std::function<void()>>::iterator rcmd_it;
|
||||||
|
|
||||||
std::list<std::function<void(Archimedes::Event*)>>::iterator ecmd_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"); }
|
auto rendererInit() { return ImGui_ImplOpenGL3_Init("#version 330"); }
|
||||||
void rendererShutdown() { ImGui_ImplOpenGL3_Shutdown(); }
|
void rendererShutdown() { ImGui_ImplOpenGL3_Shutdown(); }
|
||||||
|
|
||||||
void rendererNewFrame() { ImGui_ImplOpenGL3_NewFrame(); }
|
void rendererNewFrame() { ImGui_ImplOpenGL3_NewFrame(); }
|
||||||
void rendererRenderDrawData() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); }
|
void rendererRenderDrawData() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); }
|
||||||
|
#endif
|
||||||
#elif RENDERER == 2
|
#ifdef RENDERER_SDL3
|
||||||
SDL_Renderer* renderer;
|
SDL_Renderer* renderer;
|
||||||
auto rendererInit() { return ImGui_ImplSDLRenderer3_Init(renderer); }
|
auto rendererInit() { return ImGui_ImplSDLRenderer3_Init(renderer); }
|
||||||
void rendererShutdown() { ImGui_ImplSDLRenderer3_Shutdown(); }
|
void rendererShutdown() { ImGui_ImplSDLRenderer3_Shutdown(); }
|
||||||
@@ -82,20 +86,23 @@ class ImguiModule : public Archimedes::Module {
|
|||||||
void rendererRenderDrawData() { ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer); }
|
void rendererRenderDrawData() { ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WINDOW == 1
|
#ifdef WINDOW_GLFW
|
||||||
#if RENDERER == 1
|
#ifdef RENDERER_OPENGL
|
||||||
auto windowInit() { return ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true); }
|
auto windowInit() { return ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl()->getWindow(), true); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void windowShutdown() { ImGui_ImplGlfw_Shutdown(); }
|
void windowShutdown() { ImGui_ImplGlfw_Shutdown(); }
|
||||||
|
|
||||||
void windowNewFrame() { ImGui_ImplGlfw_NewFrame(); }
|
void windowNewFrame() { ImGui_ImplGlfw_NewFrame(); }
|
||||||
|
|
||||||
#elif WINDOW == 2
|
#endif
|
||||||
#if RENDERER == 1
|
|
||||||
auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl().getWindow(), window->getWindowImpl().getContext()); }
|
#ifdef WINDOW_SDL3
|
||||||
#elif RENDERER == 2
|
#ifdef RENDERER_OPENGL
|
||||||
auto windowInit() { return ImGui_ImplSDL3_InitForSDLRenderer(window->getWindowImpl().getWindow(), renderer); }
|
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
|
#endif
|
||||||
|
|
||||||
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }
|
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }
|
||||||
50
src/modules/ImguiModule/default.nix
Normal file
50
src/modules/ImguiModule/default.nix
Normal 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -56,6 +56,8 @@ void MainGUI::run() {
|
|||||||
|
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
ImGui::ShowDemoWindow();
|
||||||
} else {
|
} else {
|
||||||
app->end();
|
app->end();
|
||||||
}
|
}
|
||||||
50
src/modules/MainGUI/default.nix
Normal file
50
src/modules/MainGUI/default.nix
Normal 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
Reference in New Issue
Block a user