From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Luis_Souto_Gra=C3=B1a?= Newsgroups: gmane.lisp.guile.user Subject: Re: Function set-gl-vertex-array in Guile-opengl Date: Sat, 9 Feb 2019 19:59:15 +0100 Message-ID: References: <36DB9AAC-0B1F-4E3F-9FEC-B25A180F07CE@bluewin.ch> <66F77153-4A14-470C-BEEA-F5D0A27CE4F9@bluewin.ch> <0BE53CE6-E3F3-4D2B-AB56-DAEE9A87F114@bluewin.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="238336"; mail-complaints-to="usenet@blaine.gmane.org" Cc: guile-user To: Daniel Llorens Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Feb 09 19:00:13 2019 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsWvF-000zuy-4D for guile-user@m.gmane.org; Sat, 09 Feb 2019 19:00:13 +0100 Original-Received: from localhost ([127.0.0.1]:48284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsWvE-0006WR-6a for guile-user@m.gmane.org; Sat, 09 Feb 2019 13:00:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsWus-0006WL-D1 for guile-user@gnu.org; Sat, 09 Feb 2019 12:59:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsWuo-0008HV-6s for guile-user@gnu.org; Sat, 09 Feb 2019 12:59:48 -0500 Original-Received: from mail-it1-x12a.google.com ([2607:f8b0:4864:20::12a]:52113) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gsWuj-00086i-8o for guile-user@gnu.org; Sat, 09 Feb 2019 12:59:43 -0500 Original-Received: by mail-it1-x12a.google.com with SMTP id y184so10579008itc.1 for ; Sat, 09 Feb 2019 09:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cjsAEY3bP/IEg80PQBi8QN2G5A8jOcwTwjtyizSsPSw=; b=Zrky6zTds4irv0bT8q9n6Wa2ItLKotPeqaPCmtNbiTqUE85Ps8nRBBqwtaQA+JrjIX SUqfzzf9Ti7lmfOgdBB+5B9CViIQDxR3HKrbcZRQH+aYzIZrChuxUUA9hu+aKmsyEOTb SsG4onxkSwTBkb7ayumCMXQNGjuu2WWkmR4OEMkbu02Z+xpDprCYB6bzNYJQIxpFVUnv b8fuhZJTK4s2fLEERw+FP+4zsdMvjW5qW3r0rfxJUSqdEet+QZ/BPGfDrWmSfYzfamr6 CctMIFu7Vxu0AJqG0FuJPbFQNcOt8AnEaiMH47q91n4Rybw6y6kGpy6wWOpk9DboW+xa a1OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cjsAEY3bP/IEg80PQBi8QN2G5A8jOcwTwjtyizSsPSw=; b=pkPsGc0Hzzs0fakNdgc4MQJhjXC6YjxbEe2MwF1Js+NopD700Ov4UgF0BEIT53+dZv orvuTySOYVhvXqVDIOQdCMU8dfgwIB/gjKVtRqqYwExUza5dxk86Q4v5fu9XpXbFu2md E4gA/OtUi/UF3BT1hDpkwKWVAaIyFgMtAMfX8YWao6O8UZEnuzaCylWfInxe/8dk+k1Q gFthbIh9uaq0WVPAYLHBC2vCNJ8ARPS5P60rdpSFWT8ycQ6f6CpZOiIYqoHYn3/Wk0qY YPgyEIwZZ6BMa/cmgUgNHgwPmzwTgKg0GreJegDGLYkNuk1j3IAxjiT5cMBFhnTneFy/ p7Iw== X-Gm-Message-State: AHQUAuZ3z58otf4MGAE7hrrQpf4dQ/+hGY+F8ySNWe68DyCbGq8n3Sq7 VZE4sgrzCzs1Ltl1Uo5gIyaibDPTENMLWkp7wUw= X-Google-Smtp-Source: AHgI3IZEm28kBejCZ+plMr+SihCWbK+9uGhDD2v5hUIqvEuh45VqsHSIMBDK/BHXa01dc2kyVBS+vXNh7Xyeop54/HQ= X-Received: by 2002:a5e:8811:: with SMTP id l17mr9700620ioj.42.1549735167554; Sat, 09 Feb 2019 09:59:27 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::12a X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15299 Archived-At: I found the mistake. I only had to add two lines. It works. (use-modules (gl) (glut)) (use-modules (gl contrib packed-struct)) (define-packed-struct vertices (x float) (y float) (z float) (r float) (g float) (b float)) (define vertices-square (make-packed-array vertices 4)) (pack vertices-square 0 vertices 20.0 20.0 0.0 0.0 0.0 0.0) (pack vertices-square 1 vertices 80.0 20.0 0.0 0.0 0.0 0.0) (pack vertices-square 2 vertices 80.0 80.0 0.0 0.0 0.0 0.0) (pack vertices-square 3 vertices 20.0 80.0 0.0 0.0 0.0 0.0) ;;vertices-square ;;#vu8(0 0 160 65 0 0 160 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;; 0 0 160 66 0 0 160 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;; 0 0 160 66 0 0 160 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;; 0 0 160 65 0 0 160 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) (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-enable-client-state (enable-cap vertex-array)) (gl-enable-client-state (enable-cap color-array)) (set-gl-vertex-array (vertex-pointer-type float) vertices-square #:stride (packed-struct-size vertices) ;; 24 #:offset (packed-struct-offset vertices x)) ;; 0 (set-gl-color-array (color-pointer-type float) vertices-square #:stride (packed-struct-size vertices) ;; 24 #:offset (packed-struct-offset vertices r)) ;; 12 (gl-draw-arrays (begin-mode quads) 0 (packed-array-length vertices-square vertices))) ;; 4 (define (on-display) (init) (draw-scene) (swap-buffers)) (initialize-glut #:window-size '(800 . 800)) (make-window "hallelujah") (set-display-callback (lambda() (on-display))) (glut-main-loop) El jue., 31 ene. 2019 a las 12:14, Luis Souto Gra=C3=B1a (< luissoutobueu@gmail.com>) escribi=C3=B3: > I think I almost have it. I made a minimal example with a square. It > starts but the square doesn't appear. If anyone finds where the fault is, > please let me know. > > (use-modules (gl) (glut)) > (use-modules (gl contrib packed-struct)) > > (define-packed-struct vertices > (x float) > (y float) > (z float) > (r float) > (g float) > (b float)) > > (define vertices-square (make-packed-array vertices 4)) > (pack vertices-square 0 vertices 20.0 20.0 0.0 0.0 0.0 0.0) > (pack vertices-square 1 vertices 80.0 20.0 0.0 0.0 0.0 0.0) > (pack vertices-square 2 vertices 80.0 80.0 0.0 0.0 0.0 0.0) > (pack vertices-square 3 vertices 20.0 80.0 0.0 0.0 0.0 0.0) > > ;;vertices-square > ;;#vu8(0 0 160 65 0 0 160 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > ;; 0 0 160 66 0 0 160 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > ;; 0 0 160 66 0 0 160 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > ;; 0 0 160 65 0 0 160 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) > > > (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 polygon) > ;; (gl-vertex 20.0 20.0 0.0) > ;; (gl-vertex 80.0 20.0 0.0) > ;; (gl-vertex 80.0 80.0 0.0) > ;; (gl-vertex 20.0 80.0 0.0))) > (set-gl-vertex-array (vertex-pointer-type float) > vertices-square > #:stride (packed-struct-size vertices) ;; 24 > #:offset (packed-struct-offset vertices x)) ;; = 0 > (set-gl-color-array (color-pointer-type float) > vertices-square > #:stride (packed-struct-size vertices) ;; 24 > #:offset (packed-struct-offset vertices r)) ;; = 12 > > (gl-draw-arrays (begin-mode polygon) 0 (packed-array-length vertices-= square vertices))) ;; 4 > > (define (on-display) > (init) > (draw-scene) > (swap-buffers)) > > (initialize-glut #:window-size '(800 . 800)) > (make-window "page 24") > (set-display-callback (lambda() (on-display))) > (glut-main-loop) > > > El lun., 28 ene. 2019 a las 14:30, Luis Souto Gra=C3=B1a (< > luissoutobueu@gmail.com>) escribi=C3=B3: > >> Andy Wingo doesn't use f32vectors, he uses packed-struct.scm https:// >> github.com/guildhall/guile-ope >> ngl/blob/master/gl/contrib/packed-struct.scm . There are >> bytevector-ieee-single-native-set in it. >> >> It works because I wrote: >> >> $ cd /home/spectrumgomas/guile-opengl-01.0/examples/particle-system >> $ guile client-arrays.scm >> >> And I see the particle system. >> >> Now I just need to understand it. :) >> >> El s=C3=A1b., 26 ene. 2019 a las 16:39, Daniel Llorens (< >> daniel.llorens@bluewin.ch>) escribi=C3=B3: >> >>> >>> >>> > On 26 Jan 2019, at 17:05, Luis Souto Gra=C3=B1a >>> wrote: >>> > >>> > The structure of my byvector is: >>> > >>> > 30.0(float) --- IEE754 converter --> 0x41F00000 (hexadecimal) --- >>> little endian ---> 0000F041 --- hexadecimal to decimal converter ---> 0= 0 00 >>> 240 65 >>> > >>> > But I didn't notice and there's a lot of zeros before the next 00 00 >>> 240 65. >>> > >>> > I have to study what is the structure of a f32vector in Guile. I don'= t >>> know it. >>> >>> The storage of an f32vector is exactly the same as if you declared floa= t >>> a[n] in C, one float after another, each taking 4 bytes. Endianness doe= sn't >>> matter if you are producing and consuming the floats on the same machin= e. >>> >>> The source data is floats, OpenGL takes floats, you don't need to deal >>> with bytes. >>> >>>