--- deliantra/Deliantra-Client/Client.xs 2006/04/09 01:35:40 1.9 +++ deliantra/Deliantra-Client/Client.xs 2006/04/11 12:27:51 1.13 @@ -8,19 +8,32 @@ #include #include +#include #include +#include +#include +#include +#include + static PangoContext *context; static PangoFontMap *fontmap; MODULE = Crossfire::Client PACKAGE = Crossfire::Client +PROTOTYPES: ENABLE + BOOT: { fontmap = pango_ft2_font_map_new (); context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); } +void +lowdelay (int fd, int val = 1) + CODE: + setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); + char * gl_version () CODE: @@ -36,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); + 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: @@ -89,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 (); +}