From 905abebe9a3b80a9ae2723024c6df8a728076157 Mon Sep 17 00:00:00 2001 From: jsancho Date: Sun, 4 Dec 2011 08:50:18 +0000 Subject: [PATCH] Gacela as Guile modules. --- src/{gacela_FTGL.c => ftgl.c} | 12 ++++++++---- src/ftgl.scm | 25 +++++++++++++++++++++++++ src/gacela_FTGL.h | 18 ------------------ src/gacela_GL.h | 18 ------------------ src/{gacela_GL.c => gl.c} | 12 +++++++----- src/gl.scm | 25 +++++++++++++++++++++++++ src/sdl.c | 5 ++--- src/sdl.scm | 25 ++++++++++++++++++++++++- src/{gacela_ttf.scm => ttf.scm} | 3 +++ 9 files changed, 94 insertions(+), 49 deletions(-) rename src/{gacela_FTGL.c => ftgl.c} (97%) create mode 100644 src/ftgl.scm delete mode 100644 src/gacela_FTGL.h delete mode 100644 src/gacela_GL.h rename src/{gacela_GL.c => gl.c} (99%) create mode 100644 src/gl.scm rename src/{gacela_ttf.scm => ttf.scm} (95%) diff --git a/src/gacela_FTGL.c b/src/ftgl.c similarity index 97% rename from src/gacela_FTGL.c rename to src/ftgl.c index 643707e..2dc79a0 100644 --- a/src/gacela_FTGL.c +++ b/src/ftgl.c @@ -17,7 +17,6 @@ #include #include -#include "gacela_FTGL.h" struct font { @@ -124,8 +123,8 @@ gacela_ftglRenderFont (SCM font, SCM string, SCM mode) } -void* -FTGL_register_functions (void* data) +void +init_gacela_ftgl (void *data) { font_tag = scm_make_smob_type ("font", sizeof (struct font)); scm_set_smob_mark (font_tag, mark_font); @@ -140,6 +139,11 @@ FTGL_register_functions (void* data) scm_c_define_gsubr ("ftglSetFontFaceSize", 3, 0, 0, gacela_ftglSetFontFaceSize); scm_c_define_gsubr ("ftglSetFontCharMap", 2, 0, 0, gacela_ftglSetFontCharMap); scm_c_define_gsubr ("ftglRenderFont", 3, 0, 0, gacela_ftglRenderFont); +} + - return NULL; +void +scm_init_gacela_ftgl () +{ + init_gacela_ftgl (NULL); } diff --git a/src/ftgl.scm b/src/ftgl.scm new file mode 100644 index 0000000..ffcacb0 --- /dev/null +++ b/src/ftgl.scm @@ -0,0 +1,25 @@ +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2009 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + +(define-module (gacela ftgl)) + +(load-extension "libguile-gacela-ftgl" "scm_init_gacela_ftgl") + +(module-map (lambda (sym var) + (if (not (eq? sym '%module-public-interface)) + (module-export! (current-module) (list sym)))) + (current-module)) diff --git a/src/gacela_FTGL.h b/src/gacela_FTGL.h deleted file mode 100644 index 83111e9..0000000 --- a/src/gacela_FTGL.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Gacela, a GNU Guile extension for fast games development - Copyright (C) 2009 by Javier Sancho Fernandez - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -void* FTGL_register_functions (void* data); diff --git a/src/gacela_GL.h b/src/gacela_GL.h deleted file mode 100644 index 634fc47..0000000 --- a/src/gacela_GL.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Gacela, a GNU Guile extension for fast games development - Copyright (C) 2009 by Javier Sancho Fernandez - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -void* GL_register_functions (void* data); diff --git a/src/gacela_GL.c b/src/gl.c similarity index 99% rename from src/gacela_GL.c rename to src/gl.c index 541e4ab..ffdc4e8 100644 --- a/src/gacela_GL.c +++ b/src/gl.c @@ -18,8 +18,6 @@ #include #include #include -#include "gacela_GL.h" - struct glTexture { @@ -374,8 +372,8 @@ gacela_gluLookAt (SCM eyeX, SCM eyeY, SCM eyeZ, SCM centerX, SCM centerY, SCM ce } -void* -GL_register_functions (void* data) +void +init_gacela_gl (void *data) { glTexture_tag = scm_make_smob_type ("glTexture", sizeof (struct glTexture)); scm_set_smob_free (glTexture_tag, free_glTexture); @@ -482,6 +480,10 @@ GL_register_functions (void* data) scm_c_define_gsubr ("gluPerspective", 4, 0, 0, gacela_gluPerspective); scm_c_define_gsubr ("gluBuild2DMipmaps", 7, 0, 0, gacela_gluBuild2DMipmaps); scm_c_define_gsubr ("gluLookAt", 9, 0, 0, gacela_gluLookAt); +} - return NULL; +void +scm_init_gacela_gl () +{ + init_gacela_gl (NULL); } diff --git a/src/gl.scm b/src/gl.scm new file mode 100644 index 0000000..0d6541d --- /dev/null +++ b/src/gl.scm @@ -0,0 +1,25 @@ +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2009 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + +(define-module (gacela gl)) + +(load-extension "libguile-gacela-gl" "scm_init_gacela_gl") + +(module-map (lambda (sym var) + (if (not (eq? sym '%module-public-interface)) + (module-export! (current-module) (list sym)))) + (current-module)) diff --git a/src/sdl.c b/src/sdl.c index 8b9791a..b46a552 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -21,7 +21,6 @@ #include #include #include -#include "gacela_SDL.h" struct surface { @@ -531,7 +530,7 @@ init_gacela_sdl (void *data) } void -gacela_sdl_init () +scm_init_gacela_sdl () { - scm_c_define_module ("gacela sdl", init_gacela_sdl, NULL); + init_gacela_sdl (NULL); } diff --git a/src/sdl.scm b/src/sdl.scm index 103c84c..056a1dc 100644 --- a/src/sdl.scm +++ b/src/sdl.scm @@ -1,2 +1,25 @@ +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2009 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + (define-module (gacela sdl)) -(load-extension "sdl" "foo_bar_init") \ No newline at end of file + +(load-extension "libguile-gacela-sdl" "scm_init_gacela_sdl") + +(module-map (lambda (sym var) + (if (not (eq? sym '%module-public-interface)) + (module-export! (current-module) (list sym)))) + (current-module)) diff --git a/src/gacela_ttf.scm b/src/ttf.scm similarity index 95% rename from src/gacela_ttf.scm rename to src/ttf.scm index a9e64c0..5c02e54 100644 --- a/src/gacela_ttf.scm +++ b/src/ttf.scm @@ -15,6 +15,9 @@ ;;; along with this program. If not, see . +(define-module (gacela ttf) + #:use-module (gacela ftgl)) + (define* (load-font font-file #:key (size 40) (encoding ft_encoding_unicode)) (let* ((key (list font-file)) (font (get-resource-from-cache key))) -- 2.39.2