massung / r-cade

Retro Game Engine for Racket
https://r-cade.io
Other
273 stars 13 forks source link

sfShader*->C: argument is not non-null `sfShader*' pointer #4

Closed aymanosman closed 4 years ago

aymanosman commented 4 years ago

Hi, I was just trying out your library. I tried to follow the tutorial and came across this error.

I'm using macos.

I ran brew install csfml openal-soft libsndfile.

When running the following racket program:

#lang racket

(require r-cade)
(require racket/match)

(define (test-button state btn x y)
  (let ([state (match state
                 [#f "not pressed"]
                 [1  "just pressed"]
                 [n  "pressed"])])
    (text x y (format "~a is ~a" btn state))))

(define (game-loop)
  (cls)

  ; test each button and show its current state
  (test-button (btn-up) 'up 2 2)
  (test-button (btn-down) 'down 2 9)
  (test-button (btn-right) 'right 2 16)
  (test-button (btn-left) 'left 2 23)
  (test-button (btn-start) 'start 2 30)
  (test-button (btn-select) 'select 2 37)
  (test-button (btn-z) 'z 2 44)
  (test-button (btn-x) 'x 2 51)

  ; quit when escape is pressed
  (when (btn-quit)
    (quit)))

(run game-loop 256 128)

I got the following error:

../../../../../Applications/Racket v7.5/collects/ffi/unsafe.rkt:1377:12: sfShader*->C: argument is not non-null `sfShader*' pointer
  argument: #f
massung commented 4 years ago

Hey thanks for giving it a try.

There were two shader issues that existed initially that have since been fixed (I believe).

Can you try using raco and ensuring that you have the latest versions of both r-cade and CSFML?

$ raco pkg update csfml
$ raco pkg update r-cade

If you still have an issue let me know. But you can pass #:shader #f to the run function to disable the shader completely for the time being if you keep having this issue.

aymanosman commented 4 years ago

Hey, thanks for getting back to me.

Updated csfml, no update available. Updated r-cade, it performed an update.

I ran the code again and got the same error.

I tried (run #:shader #f game-loop 256 128) and I still got the same error.

Thanks for your help.

massung commented 4 years ago

Okay, I could repro the bug when I passed #:shader #f as well. I fixed that and I updated CSFML to handle a possible case. Both packages have updates that should be available in ~5 minutes.

Please update both (let me know if in 30 min there's no update available), and then try. Passing #:shader #f should world no matter what. If that works, then try with the shader and see if that works. If it works, but there's obviously no shader effect, then the problem is with the shader itself (not successfully compiling on your setup).

Thanks!

aymanosman commented 4 years ago

Hey, thanks.

Initial testing on my mac yielded these results:

From the terminal, everything works! Including with omitting #:shader #f.

(Note that this is the first time I tried running it from the terminal)

From DrRacket, I get weird behaviour.

massung commented 4 years ago

Okay. Glad the shader issue is resolved and so I'm going to close this issue.

Could you open a new issue for the DrRacket problem? It would be very helpful if you also provided the following details:

I don't have a Mac, so I'll be hoping for some community help a bit. But since everything works great from the CLI my guess is this may be a bit of an issue with DrRacket on Mac (I hope not)?

aymanosman commented 4 years ago

Thanks! I've been playing around with the defenders game. Very exciting.

I see that there is already an issue about DrRacket crashes here. I won't make another one.