diff options
| author | 2026-02-13 16:46:57 -0600 | |
|---|---|---|
| committer | 2026-02-13 16:47:14 -0600 | |
| commit | 9f62c40d053161e60c12ec22c89e0eac1e86a988 (patch) | |
| tree | ceaa01a3dcc2681803f52a7c47bd9c65263321f9 | |
| parent | WIP on cjanet documentation. (diff) | |
More work on gfx2d.
| -rw-r--r-- | examples/cjanet/gl.janet | 6 | ||||
| -rw-r--r-- | spork/charts.janet | 1 | ||||
| -rw-r--r-- | spork/cjanet.janet | 6 | ||||
| -rw-r--r-- | spork/gfx2d-codegen.janet | 19 | ||||
| -rw-r--r-- | spork/path.janet | 6 |
5 files changed, 23 insertions, 15 deletions
diff --git a/examples/cjanet/gl.janet b/examples/cjanet/gl.janet index 1a00745..7da1305 100644 --- a/examples/cjanet/gl.janet +++ b/examples/cjanet/gl.janet @@ -1,6 +1,4 @@ ### -### Use cjanet JIT and libpng to generate a large fractal. -### ### Requires a c compiler and glfw ### Direct port of tutorial from https://learnopengl.com/Getting-started/Hello-Window ### @@ -16,7 +14,7 @@ (function process-input "handle key presses" [window:*GLFWwindow] -> void - (when (== GLFW_PRESS (glfwGetKey window GLFW_KEY_ESCAPE)) + (when (= GLFW_PRESS (glfwGetKey window GLFW_KEY_ESCAPE)) (glfwSetWindowShouldClose window 1))) (function render @@ -37,7 +35,7 @@ (glfwWindowHint GLFW_CONTEXT_VERSION_MAJOR 3) (glfwWindowHint GLFW_CONTEXT_VERSION_MINOR 3) (glfwWindowHint GLFW_OPENGL_PROFILE GLFW_OPENGL_CORE_PROFILE) - (def (window (* GLFWwindow)) (glfwCreateWindow w h "LearnOpenGL" NULL NULL)) + (def window:*GLFWwindow (glfwCreateWindow w h "LearnOpenGL" NULL NULL)) (unless window (printf "failed to create glfw window\n") (glfwTerminate) diff --git a/spork/charts.janet b/spork/charts.janet index 740d3fd..980368d 100644 --- a/spork/charts.janet +++ b/spork/charts.janet @@ -611,7 +611,6 @@ (g/plot-ring canvas x y point-radius color) (g/ring canvas x y (- point-radius stroke-thickness) point-radius color))))) - canvas) (defn line-chart diff --git a/spork/cjanet.janet b/spork/cjanet.janet index b05193b..6af90ee 100644 --- a/spork/cjanet.janet +++ b/spork/cjanet.janet @@ -981,14 +981,14 @@ ``` Begin C Janet JIT context. Optionally pass in options to configure compilation. The `options` argument will be passed to the `spork/cc` module to compile generated C code. Generated intermediates will be created - in the _cjanet/ directory. + in the _build/ directory. ``` [&keys options] (def compilation-unit @"#include <janet.h>\n") (def prevout (dyn *out*)) (def cont {:buffer compilation-unit - :build-dir "_cjanet" + :build-dir "_build" :opts options :old-out prevout :prefix (get options :prefix) @@ -998,7 +998,7 @@ *abstract-type-list* @[] :module-name (get options :module-name (string "cjanet" (gensym) "_" (os/getpid)))}) (setdyn *jit-context* cont) - (os/mkdir "_cjanet") + (os/mkdir "_build") (setdyn *out* compilation-unit) (setdyn *cdef-list* (get cont *cdef-list*)) (setdyn *cfun-list* (get cont *cfun-list*)) diff --git a/spork/gfx2d-codegen.janet b/spork/gfx2d-codegen.janet index e89bd5f..8913674 100644 --- a/spork/gfx2d-codegen.janet +++ b/spork/gfx2d-codegen.janet @@ -262,7 +262,7 @@ (function indexed-to-vs "Get vectors from an indexed collection. Must be freed with janet_sfree." - [coords:JanetView n:*int] -> 'V2 + [coords:JanetView n:*int] -> *V2 (if (band 1 coords.len) (janet-panic "expected an even number of point coordinates")) (def ret:*V2 (janet-smalloc (* (sizeof V2) (/ coords.len 2)))) (for [(var i:int 0) (< i coords.len) (+= i 2)] @@ -311,7 +311,7 @@ (janet-free image->data)) (return 0)) -(function gc-mark :static +(function gc-mark-image :static [p:*void s:size_t] -> int (unused s) (def image:*Image p) @@ -319,10 +319,21 @@ (janet-mark (janet-wrap-abstract image->parent))) (return 0)) +(function image-bytes :static + [p:*void s:size_t] -> JanetByteView + (unused s) + (def image:*Image p) + (def view:JanetByteView) + # TODO - for viewports, memory is non-contiguous + (set view.len (* image->stride image->height)) + (set view.bytes image->data) + (return view)) + (abstract-type Image :name "gfx2d/image" - :gcmark gc-mark - :gc gc-image) + :gcmark gc-mark-image + :gc gc-image + :bytes image-bytes) (comp-unless (dyn :shader-compile) diff --git a/spork/path.janet b/spork/path.janet index 12741a1..f518bc6 100644 --- a/spork/path.janet +++ b/spork/path.janet @@ -309,6 +309,6 @@ "relpath"]) (comptime # for flycheck - (let [pre (if (= :windows (os/which)) "win32" "posix")] - (each sym syms - (redef (string pre "/" sym) sym)))) + (let [pre (if (= :windows (os/which)) "win32" "posix")] + (each sym syms + (redef (string pre "/" sym) sym)))) |
