--- deliantra/Deliantra-Client/Client.xs 2006/05/12 00:16:34 1.77 +++ deliantra/Deliantra-Client/Client.xs 2006/05/19 23:18:40 1.88 @@ -1,5 +1,7 @@ #ifdef _WIN32 +# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls # include +# include # pragma warning(disable:4244) #endif @@ -7,6 +9,7 @@ #include "perl.h" #include "XSUB.h" +#include #include #include @@ -83,7 +86,11 @@ substitute_func (FcPattern *pattern, gpointer data) { FcPatternAddBool (pattern, FC_HINTING , 1); +#ifdef _WIN32 + FcPatternAddBool (pattern, FC_AUTOHINT, 1); +#else FcPatternAddBool (pattern, FC_AUTOHINT, 0); +#endif } static void @@ -406,13 +413,19 @@ for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); +} - ft2_fontmap = pango_ft2_font_map_new (); - pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); - ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); +void +pango_init () + CODE: +{ + // delayed, so it can pick up new fonts added by AddFontResourceEx + ft2_fontmap = pango_ft2_font_map_new (); + pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); + ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); - cairo_fontmap = pango_cairo_font_map_get_default (); - cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); + cairo_fontmap = pango_cairo_font_map_get_default (); + cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); } int @@ -432,14 +445,15 @@ SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1); + SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); + SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); - SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0); SDL_EnableUNICODE (1); SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); @@ -458,6 +472,9 @@ } } +char * +SDL_GetError () + int SDL_SetVideoMode (int w, int h, int fullscreen) CODE: @@ -561,6 +578,10 @@ add_font (char *file) CODE: FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ +#ifdef _WIN32 + // cairo... sigh... requires win2000 + AddFontResourceEx (file, FR_PRIVATE, 0); +#endif void load_image_inline (SV *image_) @@ -654,19 +675,17 @@ void error (char *message) CODE: -#ifdef _WIN32 - MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); -#else fprintf (stderr, "ERROR: %s\n", message); +#ifdef _WIN32 + MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); #endif void fatal (char *message) CODE: -#ifdef _WIN32 - MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); -#else fprintf (stderr, "FATAL: %s\n", message); +#ifdef _WIN32 + MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); #endif exit (1); @@ -699,6 +718,9 @@ CFClient::Layout new (SV *class, int rgba = 0) CODE: +#if _WIN32 + rgba = 0;//D +#endif New (0, RETVAL, 1, struct cf_layout); RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context); @@ -788,6 +810,31 @@ pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); void +set_indent (CFClient::Layout self, int indent) + CODE: + pango_layout_set_indent (self->pl, indent * PANGO_SCALE); + +void +set_spacing (CFClient::Layout self, int spacing) + CODE: + pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); + +void +set_ellipsise (CFClient::Layout self, int ellipsise) + CODE: + pango_layout_set_ellipsize (self->pl, + ellipsise == 1 ? PANGO_ELLIPSIZE_START + : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE + : ellipsise == 3 ? PANGO_ELLIPSIZE_END + : PANGO_ELLIPSIZE_NONE + ); + +void +set_single_paragraph_mode (CFClient::Layout self, int spm) + CODE: + pango_layout_set_single_paragraph_mode (self->pl, !!spm); + +void size (CFClient::Layout self) PPCODE: { @@ -863,6 +910,18 @@ { uint32_t rgba = *p; rgba = (rgba >> 24) | (rgba << 8); +#if 0 +#ifdef _WIN32 + {//D + uint8_t r = rgba >> 24; + uint8_t g = rgba >> 16; + uint8_t b = rgba >> 8; + uint8_t a = rgba >> 0; + + rgba = (rgba & 0xffffff00) | a; + } +#endif +#endif rgba = SDL_SwapBE32 (rgba); *p++ = rgba; } @@ -929,6 +988,8 @@ { glEnable (GL_BLEND); glBlendFunc (ix == 1 ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_ALPHA_TEST); + glAlphaFunc (GL_GREATER, 0.01f); } glBindTexture (GL_TEXTURE_2D, name); @@ -947,7 +1008,10 @@ glEnd (); if (ix) - glDisable (GL_BLEND); + { + glDisable (GL_ALPHA_TEST); + glDisable (GL_BLEND); + } } MODULE = CFClient PACKAGE = CFClient::Map @@ -1480,7 +1544,9 @@ const_iv (GL_RGBA), const_iv (GL_UNSIGNED_BYTE), const_iv (GL_ALPHA), + const_iv (GL_INTENSITY), const_iv (GL_LUMINANCE), + const_iv (GL_LUMINANCE_ALPHA), const_iv (GL_FLOAT), const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), const_iv (GL_COMPILE), @@ -1579,7 +1645,10 @@ void glColor (float r, float g, float b, float a = 1.0) PROTOTYPE: @ CODE: - glColor4ub (r * 255.999, g * 255.999, b * 255.999, a * 255.999); + glColor4ub (MIN ((int)(r * 255.f), 255), + MIN ((int)(g * 255.f), 255), + MIN ((int)(b * 255.f), 255), + MIN ((int)(a * 255.f), 255)); void glVertex (float x, float y, float z = 0.) CODE: