unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Tim Meehan <btmeehan@gmail.com>
To: guile-user@gnu.org
Subject: Re: guile-user Digest, Vol 216, Issue 15
Date: Mon, 23 Nov 2020 19:54:32 -0600	[thread overview]
Message-ID: <CACgrOx+7m3rLcgVoY-YnkdTRzuk57t1v1RojUidr3_rQpz0mJA@mail.gmail.com> (raw)
In-Reply-To: <mailman.89.1605891658.3478.guile-user@gnu.org>

Ok - I'm very new to Guile, and had run across "Sly" (game framework) by
dthomson? (My assumption, based on checking out a couple of links:
https://github.com/guildhall/guile-sly, http://www.draketo.de/proj/py2guile/
at bottom of page) ...

I'm interested in learning how to do games (Guile is a hobby, games are
fun).
Based on the recent announcement of Chickadee 0.6.0, I'm assuming I should
check that out instead of Sly?

On Fri, Nov 20, 2020 at 11:02 AM <guile-user-request@gnu.org> wrote:

> Send guile-user mailing list submissions to
>         guile-user@gnu.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.gnu.org/mailman/listinfo/guile-user
> or, via email, send a message with subject or body 'help' to
>         guile-user-request@gnu.org
>
> You can reach the person managing the list at
>         guile-user-owner@gnu.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of guile-user digest..."
>
>
> Today's Topics:
>
>    1. Chickadee 0.6.0 released (Thompson, David)
>    2. getting to know the FFI ... (Tim Meehan)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 19 Nov 2020 21:11:09 -0500
> From: "Thompson, David" <dthompson2@worcester.edu>
> To: Guile User <guile-user@gnu.org>
> Subject: Chickadee 0.6.0 released
> Message-ID:
>         <CAJ=RwfbC2UmafXr=
> TrzaBkhhZ2ov+EfEmqOPZdBfjFn68tYucA@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> Hey everyone,
>
> I just released Chickadee 0.6.0.  Chickadee is a game programming
> library for Guile. It handles window management,
> keyboard/mouse/controller input, hardware-accelerated rendering,
> audio, scripting, and more.
>
> Most notably it now supports OpenGL 2 (rejoice, old thinkpad users!),
> can render TrueType/OpenType fonts, and has preliminary support for 2D
> vector graphics.
>
> See the link below for full release details and download links:
>     https://dthompson.us/chickadee-060-released.html
>
> - Dave
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 19 Nov 2020 21:02:51 -0600
> From: Tim Meehan <btmeehan@gmail.com>
> To: guile-user@gnu.org
> Subject: getting to know the FFI ...
> Message-ID:
>         <CACgrOxJZKxE4eL9keY5HBmqnT9yA22VOrq3Hn2RLd=
> BsE2PJgQ@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> I figured that I would try and do something simple-ish to see how well I
> understood the FFI. I found this GTK tutorial, written in Chez Scheme:
> https://github.com/jhidding/lyonesse/blob/master/gtk-tutorial/window.scm
> I just tried to replace the Chez FFI calls with Guile FFI calls.
>
> I'm not sure how to tell GTK about a callback that is written in Guile.
> I'm not sure how to pass a string to GTK ...
>
> Cheers,
> My bug-ridden source follows:
>
> ; The original code was in Chez Scheme, link below:
> ; https://github.com/jhidding/lyonesse/blob/master/gtk-tutorial/window.scm
>
> ; I gather that it just pops up a window?
> ; He didn't connect the "X" to the destroy action,
> ; so the window might be hard to get rid of.
>
> (use-modules (system foreign))
>
> (define libgtk (dynamic-link "libgtk-3"))
> (define libgdk (dynamic-link "libgdk-3"))
> (define libgio (dynamic-link "libgio-2.0"))
> (define libgobject (dynamic-link "libgobject-2.0"))
>
> ;; GtkApplication* -> GtkWidget*
> (define gtk-application-window-new
>     (pointer->procedure
>         '*
>         (dynamic-func "gtk_application_window_new" libgtk)
>         (list '*)))
>
>
> ;; GtkWindow*, gchar* -> void
> (define gtk-window-set-title
>     (pointer->procedure
>         void
>         (dynamic-func "gtk_window_set_title" libgtk)
>         (list '* '*)))
>
>
> (define gtk-window-set-default-size
>     (pointer->procedure
>         void
>         (dynamic-func "gtk_window_set_default_size" libgtk)
>         (list '*)))
>
>
> ;; GtkWidget* -> void
> (define gtk-widget-show-all
>     (pointer->procedure
>         void
>         (dynamic-func "gtk_widget_show_all" libgtk)
>         (list '*)))
>
>
> ;; gchar*, GApplicationFlags -> GtkApplication*
> (define gtk-application-new
>     (pointer->procedure
>         '*
>         (dynamic-func "gtk_application_new" libgtk)
>         (list '* int))) ; FIXME guess
>
>
> ;; GApplication*, int, char ** -> int
> (define g-application-run
>     (pointer->procedure
>         int
>         (dynamic-func "g_application_run" libgio)
>         (list '* int '*)))
>
>
> ;; gpointer, gchar*, GCallback, gpointer, GConnectFlags -> gulong
> (define g-signal-connect-object
>     (pointer->procedure
>         unsigned-long
>         (dynamic-func "g_signal_connect_object" libgobject)
>         (list '* '* '* '* int)))
>
>
> ;; gpointer -> void
> (define g-object-unref
>     (pointer->procedure
>         void
>         (dynamic-func "g_object_unref" libgobject)
>         (list '*)))
>
>
> (define (activate gtk-app user-data)
>     (let ([window (gtk-application-window-new gtk-app)])
>         (gtk-window-set-title window "Example Window")
>         (gtk-window-set-default-size window 200 200)
>         (gtk-widget-show-all window)))
>
>
> ;; HELP: This obviously won't work.
> ;; How would I give GTK a Guile callback?
> (define (callback p)
>     (let ([code (foreign-callable p (iptr iptr) void)])
>         (lock-object code)
>         (foreign-callable-entry-point code)))
>
>
> ;; HELP: how do you pass a string from Guile to a C function?
> (define (main)
>     (let ([argc (length (command-line))]
>           [argv (command-line)]
>           [app (gtk-application-new (scm->pointer "what needs this
> anyway?") 0)])
>         (g-signal-connect-object app "activate" (callback activate) 0 0)
>         (g-application-run app 0 0)
>         (g-object-unref app)))
>
> (main)
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> guile-user mailing list
> guile-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/guile-user
>
>
> ------------------------------
>
> End of guile-user Digest, Vol 216, Issue 15
> *******************************************
>


       reply	other threads:[~2020-11-24  1:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.89.1605891658.3478.guile-user@gnu.org>
2020-11-24  1:54 ` Tim Meehan [this message]
2020-11-24  8:19   ` guile-user Digest, Vol 216, Issue 15 Aleix Conchillo Flaqué
2020-11-24 15:13   ` [EXT] " Thompson, David

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=CACgrOx+7m3rLcgVoY-YnkdTRzuk57t1v1RojUidr3_rQpz0mJA@mail.gmail.com \
    --to=btmeehan@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).