[racket] Bugfix for opengl package: load-shader erroneously strips newlines

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sun Sep 22 00:02:48 EDT 2013

Hi Michael,

I'm not the author, but I use it a lot and have helped out a little.
I'd suggest making a pull request to Stephan. Also, I've CC'd him if
he wants to just jump in make the change without a request.

https://github.com/stephanh42/RacketGL/tree/master

Jay


On Sat, Sep 21, 2013 at 7:34 PM, Michael Wilber <gcr at sneakygcr.net> wrote:
> (sorry about the possible duplicate; I sent this from the wrong email
> address...)
>
> Hey there! I found a bug in the `opengl` package. (Not the sgl bindings!
> The opengl you get by doing raco pkg install opengl)
>
> Since http://pkg.racket-lang.org is down, and because there's no
> authorship information in the README or info.rkt, I can't find the
> maintainer of the `opengl` package. (Jay perhaps?) Since it's likely
> that they're reading the mailing list, I'll just send it to everyone via
> the "shotgun responsibility" approach :)
>
> Problem: (load-shader-source shader port) strips newlines from each line
> in the port. This has consequences: any shaders that start with a
> #version proeprocessor definition fail with "preprocessor error: syntax
> error, unexpected IDENTIFIER, expecting NEWLINE", and shaders that
> contain comments also fail similarly.
>
> Fix: Replace the load-shader-source function with the following:
>
>     (define (load-shader-source shader port)
>       (let* ((lines (for/vector ((line (in-lines port))) (string-append line "\n")))
>              (sizes (for/list ((line (in-vector lines))) (string-length line)))
>              (sizes (list->s32vector sizes)))
>        (glShaderSource shader (vector-length lines) lines sizes)))
>
> Note the (string-append line "\n").
>
> Hope that helps!
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.