guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function set-gl-vertex-array in Guile-opengl


From: Luis Souto Graña
Subject: Re: Function set-gl-vertex-array in Guile-opengl
Date: Sat, 26 Jan 2019 02:33:34 +0100

I don't know how to get *#vu8(0 0 240 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 240...*
*from srfi-4. The coordinates are for a SquareAnnulus:
https://github.com/slackmoehrle/Computer-Graphics-Through-OpenGL-2nd/blob/master/Chapter3/SquareAnnulus1/squareAnnulus1.cpp
<https://github.com/slackmoehrle/Computer-Graphics-Through-OpenGL-2nd/blob/master/Chapter3/SquareAnnulus1/squareAnnulus1.cpp>*


*10 points x 3 coordinates = 30*

*If anyone could make an minimal example with set-gl-vertex-array I would
be very grateful.*

El vie., 25 ene. 2019 a las 19:25, Daniel Llorens (<
address@hidden>) escribió:

>
> Hi Luis,
>
> I don't really have an answer to your question, but I wanted to point out
> that Guile already has make-f32vector, f32vector-set!, etc. You don't need
> to define your own. IMO it's not a good idea to use bytevector-xxx-set!/ref
> to operate on typed vectors unless you are type punning.
>
> The make-f32vector, etc. functions are in SRFI-4, they aren't specific to
> Guile.
>
> PS I didn't understand the purpose of (* n 30) on your code. The original
> you link has (* n 4) which is what I'd expect for f32.
>
> Regards
>
> Daniel
>
>
> *From: *Luis Souto Graña <address@hidden>
> *Subject: **Function set-gl-vertex-array in Guile-opengl*
> *Date: *25 January 2019 at 11:36:33 CET
> *To: address@hidden
>
>
> Hello, I'm trying to use the function set-gl-vertex-array in Guile-opengl .
> It needs a bytevector as an argument. I wrote this doing a copy-paste from
> here: https://github.com/marcomaggi/vicare/blob/master/attic/lab/gears.scm
>
> (use-modules (rnrs bytevectors))
> (use-modules (system foreign))
>
> (define (f32vector . lst)
>  (define-syntax f32set!
>    (syntax-rules ()
>      ((_ bv n value)
>       (bytevector-ieee-single-native-set! bv (* n 30) value))))
>  (let ((bv (make-bytevector (* (length lst) 30))))
>    (let loop ((i 0) (lst lst))
>      (cond ((null? lst) bv)
>        (else
>         (f32set! bv i (car lst))
>         (loop (+ i 1) (cdr lst)))))))
>
> (define points (f32vector 30.0 30.0 0.0
>                      10.0 10.0 0.0
>                      70.0 30.0 0.0
>                      90.0 10.0 0.0
>                      70.0 70.0 0.0
>                      90.0 90.0 0.0
>                      30.0 70.0 0.0
>                      10.0 90.0 0.0
>                      30.0 30.0 0.0
>                      10.0 10.0 0.0))
>
> points
>
> #vu8(0 0 240 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 240
> .....
>
> (bytevector-length points)
>
> 900
>
> (bytevector->pointer points)
>
> #<pointer 0x56090d909aa0>
>
>
> So, it works well.
>
> Now, if I write:
>
> (use-modules (gl) (glut))
>
> ,apropos set-gl-vertex-array
>
> (gl): set-gl-vertex-array    #<procedure set-gl-vertex-array (type
> bv-or-pointer #:optional size #:key stride offset)>
>
>
> (set-gl-vertex-array (bytevector->pointer points) 3)
>
>
> ERROR: In procedure scm-error:
> unhandled array-pointer type 3
>
> Can someone tell me what the solution is?
>
>
>
> _______________________________________________
> guile-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/guile-user
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]