From 60e28d143c3beb811e52c03784172a84e42e5e0e Mon Sep 17 00:00:00 2001 From: jsancho Date: Tue, 17 May 2011 23:57:42 +0000 Subject: [PATCH] --- Makefile | 4 +- configure.ac | 6 +++ src/Makefile.am | 2 +- src/gacela.c | 14 ++++--- src/gacela_FTGL.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++ src/gacela_FTGL.h | 18 ++++++++ 6 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 src/gacela_FTGL.c create mode 100644 src/gacela_FTGL.h diff --git a/Makefile b/Makefile index 56409d1..8b2e0be 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ AUTOMAKE = ${SHELL} /home/jsancho/proyectos/gacela/trunk/missing --run automake- AWK = mawk CC = gcc CCDEPMODE = depmode=gcc3 -CFLAGS = -g -O2 +CFLAGS = -g -O2 -I/usr/include/freetype2 CPPFLAGS = CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H @@ -107,7 +107,7 @@ INSTALL_SCRIPT = ${INSTALL} INSTALL_STRIP_PROGRAM = $(install_sh) -c -s LDFLAGS = LIBOBJS = -LIBS = -lSDL -lSDL_image -lSDL_mixer -lGL -lGLU +LIBS = -lSDL -lSDL_image -lSDL_mixer -lGL -lGLU -lftgl LTLIBOBJS = MAKEINFO = ${SHELL} /home/jsancho/proyectos/gacela/trunk/missing --run makeinfo MKDIR_P = /bin/mkdir -p diff --git a/configure.ac b/configure.ac index 29d0f81..b86920c 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,7 @@ AC_INIT([gacela], [0.5], [jsf@jsancho.org]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC GUILE_FLAGS +CFLAGS="$CFLAGS -I/usr/include/freetype2" AC_CHECK_LIB(SDL, main, LIBS="$LIBS -lSDL", @@ -27,6 +28,11 @@ AC_CHECK_LIB(GLU, LIBS="$LIBS -lGLU", AC_MSG_ERROR([*** GLU library not found!]) ) +AC_CHECK_LIB(ftgl, + main, + LIBS="$LIBS -lftgl", + AC_MSG_ERROR([*** FTGL library not found!]) +) AC_CONFIG_SRCDIR([src/gacela_SDL.h]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ diff --git a/src/Makefile.am b/src/Makefile.am index 948db53..e1c7d16 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ bin_PROGRAMS = gacela -gacela_SOURCES = gacela.c gacela_SDL.c gacela_GL.c +gacela_SOURCES = gacela.c gacela_SDL.c gacela_GL.c gacela_FTGL.c gacela_LDADD = @GUILE_LDFLAGS@ diff --git a/src/gacela.c b/src/gacela.c index ad85b74..1f80b76 100644 --- a/src/gacela.c +++ b/src/gacela.c @@ -19,21 +19,17 @@ #include #include "gacela_SDL.h" #include "gacela_GL.h" +#include "gacela_FTGL.h" static void* register_functions (void* data) { SDL_register_functions (NULL); GL_register_functions (NULL); + FTGL_register_functions (NULL); return NULL; } -void -load_scheme_files (char *path) -{ - load_scheme_file (path, "gacela.scm"); -} - void load_scheme_file (char *path, char *filename) { @@ -46,6 +42,12 @@ load_scheme_file (char *path, char *filename) scm_c_primitive_load (fn); } +void +load_scheme_files (char *path) +{ + load_scheme_file (path, "gacela.scm"); +} + int main (int argc, char *argv[]) { diff --git a/src/gacela_FTGL.c b/src/gacela_FTGL.c new file mode 100644 index 0000000..15232fa --- /dev/null +++ b/src/gacela_FTGL.c @@ -0,0 +1,103 @@ +/* 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 . +*/ + +#include +#include +#include "gacela_FTGL.h" + +struct font +{ + SCM filename; + FTGLfont *font_address; +}; + +static scm_t_bits font_tag; + + +SCM +gacela_ftglCreateTextureFont (SCM file) +{ + SCM smob; + struct font *font; + FTGLfont *font_address = NULL; + + font_address = ftglCreateTextureFont (scm_to_locale_string (file)); + + if (font_address) { + font = (struct font *) scm_gc_malloc (sizeof (struct font), "font"); + + font->filename = SCM_BOOL_F; + font->font_address = NULL; + + SCM_NEWSMOB (smob, font_tag, font); + + font->filename = file; + font->font_address = font_address; + + return smob; + } + else { + return SCM_UNSPECIFIED; + } +} + +SCM +gacela_ftglSetFontFaceSize (SCM font, SCM size, SCM res) +{ + return scm_from_int (ftglSetFontFaceSize ((FTGLfont *)scm_to_int (font), scm_to_int (size), scm_to_int (res))); +} + +SCM +gacela_ftglSetFontCharMap (SCM font, SCM encoding) +{ + return scm_from_int (ftglSetFontCharMap ((FTGLfont *)scm_to_int (font), scm_to_int (encoding))); +} + +SCM +gacela_ftglRenderFont (SCM font, SCM string, SCM mode) +{ + ftglRenderFont ((FTGLfont *)scm_to_int (font), scm_to_locale_string(string), scm_to_int (mode)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_ftglDestroyFont (SCM font) +{ + ftglDestroyFont ((FTGLfont *)scm_to_int (font)); + return SCM_UNSPECIFIED; +} + +void* +FTGL_register_functions (void* data) +{ + font_tag = scm_make_smob_type ("font", sizeof (struct font)); + // scm_set_smob_mark (surface_tag, mark_surface); + // scm_set_smob_free (surface_tag, free_surface); + // scm_set_smob_print (surface_tag, print_surface); + // scm_set_smob_equalp (surface_tag, equalp_surface); + + scm_c_define ("ft_encoding_unicode", scm_from_int (ft_encoding_unicode)); + scm_c_define ("FTGL_RENDER_ALL", scm_from_int (FTGL_RENDER_ALL)); + + scm_c_define_gsubr ("ftglCreateTextureFont", 1, 0, 0, gacela_ftglCreateTextureFont); + 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); + scm_c_define_gsubr ("ftglDestroyFont", 1, 0, 0, gacela_ftglDestroyFont); + + return NULL; +} diff --git a/src/gacela_FTGL.h b/src/gacela_FTGL.h new file mode 100644 index 0000000..83111e9 --- /dev/null +++ b/src/gacela_FTGL.h @@ -0,0 +1,18 @@ +/* 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); -- 2.39.5