Sketchy Multi Viewports

This commit is contained in:
2026-02-05 23:59:11 -06:00
parent 8581589bfe
commit 8b0192c9b8
8 changed files with 61 additions and 15 deletions

View File

@@ -61,7 +61,7 @@
-DRENDERER=1 \ -DRENDERER=1 \
-DWINDOW=1 \ -DWINDOW=1 \
-I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lEGL -lglfw -lGLEW \ -lEGL -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11 -o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
''; '';
@@ -103,7 +103,7 @@
-DRENDERER=1 \ -DRENDERER=1 \
-DWINDOW=1 \ -DWINDOW=1 \
-I include -I $imgui -I . \ -I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11 -o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
''; '';

19
flake.lock generated
View File

@@ -49,11 +49,28 @@
"type": "github" "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",
"imgui": "imgui", "imgui": "imgui",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"nixpkgs-old": "nixpkgs-old"
} }
} }
}, },

View 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;
@@ -15,15 +16,17 @@
outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; }; pkgs-old = import inputs.nixpkgs-old { inherit system; };
viewport-overlay = final: prev: { glfw = pkgs-old.glfw; };
pkgs = import nixpkgs { inherit system; overlays = [ viewport-overlay ]; };
in { in {
Archimedes = { Archimedes = {
examples = import ./ExampleApps.nix { inherit inputs; inherit pkgs; }; examples = import ./ExampleApps.nix { inherit inputs pkgs; };
}; };
Modules = { Modules = {
examples = import ./ExampleModules.nix { inherit inputs; inherit pkgs; }; examples = import ./ExampleModules.nix { inherit inputs pkgs; };
ServerModule = pkgs.stdenvNoCC.mkDerivation { ServerModule = pkgs.stdenvNoCC.mkDerivation {
@@ -114,7 +117,7 @@
-DRENDERER=1 \ -DRENDERER=1 \
-DWINDOW=1 \ -DWINDOW=1 \
-DWINDOWMODULE_DYNAMIC \ -DWINDOWMODULE_DYNAMIC \
-lEGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11 -o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
''; '';
@@ -157,7 +160,7 @@
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \ -DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
-fpic -shared \ -fpic -shared \
-I include -I $imgui -I . \ -I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11 -o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
''; '';
@@ -243,7 +246,7 @@
-DMAINGUI_DYNAMIC \ -DMAINGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I include -I $imgui -I . \ -I include -I $imgui -I . \
-lEGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11 -o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
''; '';

View File

@@ -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) {

View File

@@ -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();

View File

@@ -60,6 +60,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";
@@ -73,9 +85,12 @@ void ImguiModule::onLoad() {
rendererRenderDrawData(); rendererRenderDrawData();
rendererNewFrame(); if(ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
windowNewFrame(); ImGui::UpdatePlatformWindows();
ImGui::NewFrame(); ImGui::RenderPlatformWindowsDefault();
window->getWindowImpl().restoreContext();
}
}); });
rcmd_it = --wm->getRenderer()->getCmdList().end()++; rcmd_it = --wm->getRenderer()->getCmdList().end()++;
@@ -92,9 +107,14 @@ void ImguiModule::onLoad() {
rendererNewFrame(); rendererNewFrame();
windowNewFrame(); windowNewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
} }
void ImguiModule::run() {
rendererNewFrame();
windowNewFrame();
ImGui::NewFrame();
};
bool ImguiModule::onEvent(const Archimedes::Event &e) { bool ImguiModule::onEvent(const Archimedes::Event &e) {
return false; return false;

View File

@@ -39,6 +39,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() {

View File

@@ -56,6 +56,8 @@ void MainGUI::run() {
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); ImGui::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();
} }