From f564b4e66dcd8db72e29e538de910a4be6bbab69 Mon Sep 17 00:00:00 2001 From: AzazelN28 Date: Tue, 26 Nov 2024 15:22:53 +0100 Subject: [PATCH] :tada: Add debug options to wasm --- frontend/src/app/main/ui/workspace/sidebar/debug.cljs | 2 +- frontend/src/app/render_wasm/api.cljs | 10 +++++++++- frontend/src/app/util/debug.cljs | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/debug.cljs b/frontend/src/app/main/ui/workspace/sidebar/debug.cljs index f5c73aab2..4c6a715b2 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/debug.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/debug.cljs @@ -43,7 +43,7 @@ [:div {:class (stl/css :debug-panel-inner)} (for [option (sort-by d/name dbg/options)] - [:div {:class (stl/css :checkbox-wrapper)} + [:div {:key (d/name option) :class (stl/css :checkbox-wrapper)} [:span {:class (stl/css-case :checkbox-icon true :global/checked (dbg/enabled? option)) :on-click #(on-toggle-enabled % option)} (when (dbg/enabled? option) i/status-tick)] diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index d881c212a..551164f71 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -12,6 +12,7 @@ [app.common.uuid :as uuid] [app.config :as cf] [app.render-wasm.helpers :as h] + [app.util.debug :as dbg] [app.util.functions :as fns] [app.util.http :as http] [app.util.webapi :as wapi] @@ -279,9 +280,16 @@ [width height] (h/call internal-module "_resize_viewbox" width height)) +(defn- debug-flags + [] + (let [debug-options 0] + (when (dbg/enabled? :wasm-viewbox) + (bit-or debug-options 2r00000000000000000000000000000001)))) + (defn assign-canvas [canvas] (let [gl (unchecked-get internal-module "GL") + flags (debug-flags) context (.getContext ^js canvas "webgl2" canvas-options) ;; Register the context with emscripten @@ -290,7 +298,7 @@ ;; Initialize Wasm Render Engine (h/call internal-module "_init" (/ (.-width ^js canvas) dpr) (/ (.-height ^js canvas) dpr)) - (h/call internal-module "_set_render_options" 0x01 dpr)) + (h/call internal-module "_set_render_options" flags dpr)) (set! (.-width canvas) (* dpr (.-clientWidth ^js canvas))) (set! (.-height canvas) (* dpr (.-clientHeight ^js canvas)))) diff --git a/frontend/src/app/util/debug.cljs b/frontend/src/app/util/debug.cljs index 8342da71c..d14f0793c 100644 --- a/frontend/src/app/util/debug.cljs +++ b/frontend/src/app/util/debug.cljs @@ -92,7 +92,10 @@ :bool-shapes ;; Show some information about the WebGL context. - :gl-context}) + :gl-context + + ;; Show viewbox + :wasm-viewbox}) (defn enable! [option]