From: jsancho Date: Wed, 18 May 2011 06:15:11 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=941cce3d2d26ced35c45269b15f1a0f6fda2a8c9;p=gacela.git --- diff --git a/src/gacela_FTGL.c b/src/gacela_FTGL.c index 15232fa..67966f6 100644 --- a/src/gacela_FTGL.c +++ b/src/gacela_FTGL.c @@ -27,28 +27,44 @@ struct font static scm_t_bits font_tag; - SCM -gacela_ftglCreateTextureFont (SCM file) +make_font (SCM file, FTGLfont *font_address) { SCM smob; struct font *font; - FTGLfont *font_address = NULL; - font_address = ftglCreateTextureFont (scm_to_locale_string (file)); + font = (struct font *) scm_gc_malloc (sizeof (struct font), "font"); - if (font_address) { - font = (struct font *) scm_gc_malloc (sizeof (struct font), "font"); + font->filename = SCM_BOOL_F; + font->font_address = NULL; - font->filename = SCM_BOOL_F; - font->font_address = NULL; + SCM_NEWSMOB (smob, font_tag, font); - SCM_NEWSMOB (smob, font_tag, font); + font->filename = file; + font->font_address = font_address; - font->filename = file; - font->font_address = font_address; + return smob; +} - return smob; +FTGLfont * +get_font_address (SCM font_smob) +{ + struct font *font; + + scm_assert_smob_type (font_tag, font_smob); + font = (struct font *) SCM_SMOB_DATA (font_smob); + return font->font_address; +} + +SCM +gacela_ftglCreateTextureFont (SCM file) +{ + FTGLfont *font_address = NULL; + + font_address = ftglCreateTextureFont (scm_to_locale_string (file)); + + if (font_address) { + return make_font (file, font_address); } else { return SCM_UNSPECIFIED; @@ -58,7 +74,7 @@ gacela_ftglCreateTextureFont (SCM file) 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))); + return scm_from_int (ftglSetFontFaceSize (get_font_address (font), scm_to_int (size), scm_to_int (res))); } SCM