This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-15
Channels
- # announcements (1)
- # asami (29)
- # babashka (31)
- # beginners (48)
- # calva (39)
- # cljsrn (4)
- # clojure (56)
- # clojure-dev (51)
- # clojure-doc (3)
- # clojure-europe (40)
- # clojure-gamedev (13)
- # clojure-italy (22)
- # clojure-nl (3)
- # clojure-uk (5)
- # cursive (9)
- # datomic (184)
- # events (7)
- # fulcro (8)
- # graalvm (2)
- # jobs (1)
- # malli (6)
- # meander (1)
- # nrepl (5)
- # off-topic (10)
- # pathom (9)
- # polylith (33)
- # portal (2)
- # re-frame (7)
- # reagent (12)
- # releases (3)
- # remote-jobs (3)
- # reveal (27)
- # shadow-cljs (34)
- # sql (1)
- # vim (7)
- # xtdb (62)
https://github.com/IGJoshua/cljsl This is still pre-alpha, but it's useful in its current state and I'm building stuff in my game engine with it. I'd love for others to check it out. It's a way to write shader code in Clojure (and I'll probably update it to work in CLJS too in future) for OpenGL, OpenGL ES, and technically WebGL, although as I said, it doesn't quite work in CLJS yet. It supports a good subset of the Clojure syntax, basically only lacking if expressions and lambdas, but that's because the compilation technique is a very naive recursive descent expression translator, and both of those features would require manipulation of the parsed AST before emitting the GLSL code.
It has some significant advantages over writing in GLSL because it includes namespaced identifiers and built-in dependency tracking, so you never need to worry about whether or not some library function you write for your shaders is being included (so no need for #include directives or anything), and the shader code is just inside your regular Clojure namespaces, living along side normal code.
Oh and it supports macros.
is there any way to have conditional expressions?
Oh absolutely, it has if statements and cond statements, but they're statements, not expressions.
Sorry, mistook your meaning. When I was looking last time I didn't find the ternary operator, but it's in there, but it's more limited than what you'd get out of proper clojure-style if expressions.
my apologies, i interpreted your lacking if expressions
to mean you can’t have conditionals in the clojure side
definitely can have conditionals.
okay, cool. this is very very cool
I might just throw in a ternary operator on the ?
symbol since that's the normal syntax for it and that way it's clear that it's not as powerful as if
There we go, now there's a ternary operator
Thanks! Yeah, I put in a reasonable amount of work on it. I really want to be working on a "v2" of the prototype that's a compiler that actually has intermediate steps between parsing (the clojure reader) and code generation (this library) that allows more complex things like type inference, monomorphization of generic functions and hof, defunctionalization, and more. But for now this does everything I need to make games because I'm perfectly comfortable having the sub-language be less powerful than Clojure for now.
although in theory all those extra compilation steps could be done by sufficiently advanced macros on top of my code generation functions.