--- deliantra/Deliantra-Client/Client.xs 2006/04/09 17:34:15 1.10 +++ deliantra/Deliantra-Client/Client.xs 2006/04/11 12:27:51 1.13 @@ -21,6 +21,8 @@ MODULE = Crossfire::Client PACKAGE = Crossfire::Client +PROTOTYPES: ENABLE + BOOT: { fontmap = pango_ft2_font_map_new (); @@ -47,17 +49,23 @@ RETVAL void +add_font (char *file) + CODE: + FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ + +void set_font (char *file) CODE: { int count; FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); - FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); FcPatternDestroy (pattern); pango_context_set_font_description (context, font); } +MODULE = Crossfire::Client PACKAGE = Crossfire::Client + void font_render (SV *text_, int height = 10) PPCODE: @@ -100,3 +108,30 @@ PUSHs (sv_2mortal (newSViv (h))); PUSHs (sv_2mortal (retval)); } + +MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture + +void +draw_quad (SV *self, double x, double y, double w = 0, double h = 0) + PROTOTYPE: $$$;$$ + CODE: +{ + HV *hv = (HV *)SvRV (self); + double s = SvNV (*hv_fetch (hv, "s", 1, 1)); + double t = SvNV (*hv_fetch (hv, "t", 1, 1)); + int name = SvIV (*hv_fetch (hv, "name", 4, 1)); + + if (items < 5) + { + w = SvNV (*hv_fetch (hv, "width", 5, 1)); + h = SvNV (*hv_fetch (hv, "height", 6, 1)); + } + + glBindTexture (GL_TEXTURE_2D, name); + glBegin (GL_QUADS); + glTexCoord2d (0, 0); glVertex2d (x , y ); + glTexCoord2d (0, t); glVertex2d (x , y + h); + glTexCoord2d (s, t); glVertex2d (x + w, y + h); + glTexCoord2d (s, 0); glVertex2d (x + w, y ); + glEnd (); +}