I'm trying to render!
a simple label on the on-render
screen function, but it doesn't work. All I get is a blank screen.
It took me some time but I finally found that this happens when I return something else but the label. For example, this works:
(defscreen main-screen
:on-show
(fn [screen entities]
(update! screen :renderer (stage))
[])
:on-render
(fn [screen _]
(clear!)
(render! screen [(label "Hello, world!" (color :white))])))
This doesn't (all that's changed is the last line on on-render
):
(defscreen main-screen
:on-show
(fn [screen entities]
(update! screen :renderer (stage))
[])
:on-render
(fn [screen _]
(clear!)
(render! screen [(label "Hello, world!" (color :white))])
["I just wanna pass my own data here, ugh.."]))
For testing, I replaced the label
with texture
and it did work.
What's causing this? it seems so arbitrary (the label I evaluate to in the first example gets completely ignored anyway! so why do I have to pass it? I don't get what's going on).
P.S. creating the label on every frame is intentional in this case, and I know I could just set it from one I make in on-show
, but I tried to be a bit more dynamic. I also tried to put a Thread/sleep
after render!
to make sure I have a visible time-window between rendering & clearing.
I'm a complete beginner I'd like to know why the above doesn't work in addition to how can I fix it?