From: "Luis Souto Graña" <luissoutobueu@gmail.com>
To: Catonano <catonano@gmail.com>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Function set-gl-vertex-array in Guile-opengl
Date: Sat, 26 Jan 2019 17:02:19 +0100 [thread overview]
Message-ID: <CA+0Zd=9SsnAJiCdhPFvkTcJTj56uvwrxd1aonQFY60c_wYGL7w@mail.gmail.com> (raw)
In-Reply-To: <CAJ98PDyWFmKe8-NKBvreUKuVJ=69Mm8-qwENba4Z3R-jP1j-dg@mail.gmail.com>
You're right. I suposse I was missing the argument type, I thought that
"type
bv-or-pointer" was one thing.
I'm in Manjaro. I just did:
Unzip guile-opengl-0.10.tar.gz
$ ./configure --prefix=/usr
$ make
$ sudo make install
And glut works well with (use-modules (gl) (glut))
The example of a circle works:
(use-modules (gl) (glut))
(define PI 3.14159265358979324)
(define radius 40.0) ; radius of circle
(define x-center 50.0) ; x-coordinate of center of circle
(define y-center 50.0) ; y-coordinate of center of circle
(define num-vertices 5) ; number of vertices on circle
(define t 0.0) ; angle parameter
(define (init)
(gl-ortho 0.0 100.0 0.0 100.0 -1.0 1.0)
(set-gl-clear-color 1.0 1.0 1.0 0.0))
(define (draw-scene)
(gl-clear (clear-buffer-mask color-buffer))
(gl-color 0 0 0)
(gl-begin (begin-mode line-loop)
(do ((i 1 (1+ i)))((> i num-vertices))
(gl-vertex (+ x-center (* radius (cos t)))
(+ y-center (* radius (sin t)))
0.0)
(set! t (+ t (/ (* 2 PI) num-vertices))))))
(define (on-display)
(init)
(draw-scene)
(swap-buffers))
(initialize-glut #:window-size '(500 . 500))
(make-window "circle")
(set-display-callback (lambda() (on-display)))
(glut-main-loop)
El sáb., 26 ene. 2019 a las 11:34, Catonano (<catonano@gmail.com>) escribió:
> Hi Luis,
>
> I hadn't guile-opengl installed, so I downloaded, built it and installed
> it uust to see if I could reproduce this error you are running into
>
> Il giorno ven 25 gen 2019 alle ore 15:58 Luis Souto Graña <
> luissoutobueu@gmail.com> ha scritto:
>
>> 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)))))))
>>
>
>
> In my test I used the f32vector that comes with guile, I don't know how
> it's different from the one you are defining here
>
>
>
>>
>> (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))
>>
>
> Ok
>
>
>
>> > 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
>>
>
>
> in my case it's
>
> scheme@(guile-user)> points
> $1 = #f32(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)
>
> I guess the difference is due to the fact that I used the one provided by
> Guile
>
> .....
>>
>> > (bytevector-length points)
>> 900
>>
>
>
> In my case:
>
> scheme@(guile-user)> (bytevector-length points)
> $2 = 120
>
>
>
>> > (bytevector->pointer points)
>> #<pointer 0x56090d909aa0>
>>
>
>
> scheme@(guile-user)> (bytevector->pointer points)
> $3 = #<pointer 0x5578953d25c0>
>
>
>>
>>
>> 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
>>
>
>
>
> The first remark: the documentation you get with ,apropos reports:
>
> (gl): set-gl-vertex-array #<procedure set-gl-vertex-array (type
> bv-or-pointer #:optional size #:key stride offset)>
>
> The function requires the first argument to be a "type" and the second
> argument to be a pointer to a bytevector
>
> Now in your call to the function, the first argument you are passing is
> not a type, it's a pointer to a bytevector
>
> And the second argument is an integer number (3)
>
> I don't now if the convention to express the types this function expects
> is to use numbers (like in enumerations), it might be
>
> But the way you're calling it seems incorrect
>
> If you try to call it with a type first and then a pointer to a
> bytevector, you might get a more interesting result
>
> In my case what I found out is that the linking to opengl is broken
>
> scheme@(guile-user)> (set-gl-vertex-array 3 (bytevector->pointer points) )
> ERROR: In procedure dynamic-link:
> In procedure dynamic-link: file: "libglut", message: "file not found"
>
> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]>
>
>
> So the libglut file can't be found
>
> The libglut file should have been identified during the configuration
> phase when I built guile-opengl
>
> But it hasn't, it seems
>
> I took a quick look at the guile-opengl configure.ac file and there's no
> attempt at finding libglut
>
> Also, the compiled files get installed in
> $(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/ccache
>
> all the other guile packages I have are installed in site-ccache, not in
> ccache
>
> So when I ,use the glut related namespaces in the REPL they get compiled
> right there and then
>
> I wondered if the unreachable ones in ccache are able to find libglut,
> maybe because of some automagic mechanism I don't know about
>
> I tried to fix the position for compiled files in the Automake.am file but
> the problem persists
>
> So this seems to be a lacking in the guile-opengl package
>
> In fact, I see that the only contributor to guile-opengl is Andy Wingo
>
> And putting the compiled files in ccache instead of site-ccache was a
> thing in guile-fibers too
>
> All other guile packages I have, put compiled files in site-ccache, I
> don't know why Andy has this habit and other packages have a different
> habit ¯\_(ツ)_/¯
>
> Often package authors can't deal with the Autotools, it seems to be too
> hard not only for me. But I doubt Andy has this kind of difficutly, I
> wonder why this is
>
> That said, being on Ubuntu 18.04.1 what should I install in order to have
> libglut on my system ?
> I see a libgle3 that seems a good candidate. Is that the right one ?
>
> If I had it I could try to sift through the internet myself and see if I
> can improve the Autotools setup of guile-opengl
>
> From there on, you could explore the code more freely.
>
> OR you could already have a better installation than I have, I don't know
> ¯\_(ツ)_/¯
>
next prev parent reply other threads:[~2019-01-26 16:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 10:36 Function set-gl-vertex-array in Guile-opengl Luis Souto Graña
2019-01-26 10:33 ` Catonano
2019-01-26 16:02 ` Luis Souto Graña [this message]
[not found] <mailman.136.1548435627.3559.guile-user@gnu.org>
2019-01-25 18:25 ` Daniel Llorens
2019-01-26 1:33 ` Luis Souto Graña
2019-01-26 12:52 ` Daniel Llorens
2019-01-26 12:58 ` Daniel Llorens
2019-01-26 16:05 ` Luis Souto Graña
2019-01-26 15:39 ` Daniel Llorens
2019-01-26 19:00 ` Luis Souto Graña
2019-01-28 13:30 ` Luis Souto Graña
2019-01-31 11:14 ` Luis Souto Graña
2019-02-09 18:59 ` Luis Souto Graña
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+0Zd=9SsnAJiCdhPFvkTcJTj56uvwrxd1aonQFY60c_wYGL7w@mail.gmail.com' \
--to=luissoutobueu@gmail.com \
--cc=catonano@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).