1

This is the code fragment of the error:

(defn end-render
  [fb]
  (let [width (get-in fb [:dimen :width])
        height (get-in fb [:dimen :height])
        msfbo (:msfbo fb)
        fbo (:fbo fb)]
    (println fb)
    (GL33/glBindFramebuffer GL33/GL_READ_FRAMEBUFFER msfbo)
    (GL33/glBindFramebuffer GL33/GL_DRAW_FRAMEBUFFER fbo) ; this is line 116
    (GL33/glBlitFramebuffer 0 0 width height 0 0 width height GL33/GL_COLOR_BUFFER_BIT GL33/GL_NEAREST)
    (GL33/glBindFramebuffer GL33/GL_FRAMEBUFFER 0)))

from which I'm getting this error:

 = EXECUTION ERROR =
java.lang.NullPointerException: Cannot invoke "java.lang.Character.charValue()" because "x" is null
 - clojure.lang.RT: intCast (RT.java:1221)
 - breakout.fx$end_render: invokeStatic (fx.clj:116)
 - breakout.fx$end_render: invoke (fx.clj:108)
 - breakout.game$draw: invokeStatic (game.clj:245)
 - breakout.game$draw: invoke (game.clj:241)
 - util.window$game_loop: invokeStatic (window.clj:47)
 - util.window$game_loop: invoke (window.clj:37)
 - breakout.core$_main: invokeStatic (core.clj:14)

I've seen errors like this before, when I try to access an element in a map that isn't there. But that doesn't seem to be the case here. The output from the (println fb) looks fine:

{:dimen {:widht 800, :height 600}, :msfbo 1, :fbo 2, :rbo 1, :vao 2, :texture 7}

Note that the line number of the error might not be correct.

The full code can be found here.

1

1 Answer 1

2

The exception message tells us that a null cannot be cast to an int value.

Reason is, the code references key :width but you have :widht in your data EDN.

Sign up to request clarification or add additional context in comments.

3 Comments

What is wrong with clojure error messages? Why is the line number not 110 - the line with (let [width (get-in fb [:dimen :width])? And why isn't there a more appropriate error message like "key :width does not exists in map 'dimen'"?
It's not an error in Clojure to query a map for a key it does not contain. The result is just nil, which you can handle however you like. So the reason there's no "more appropriate" error message is that from Clojure's perspective, no error has occurred until you pass the nil to a function that expects a non-nil value.
Ok, I understand. The error is therefore not on line 110, but on line 117. But definitely not on line 116.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.