| 1 |
root |
1.1 |
#include "EXTERN.h" |
| 2 |
|
|
#include "perl.h" |
| 3 |
|
|
#include "XSUB.h" |
| 4 |
|
|
|
| 5 |
root |
1.5 |
#include <string.h> |
| 6 |
|
|
|
| 7 |
root |
1.2 |
#include <SDL.h> |
| 8 |
root |
1.3 |
#include <SDL_opengl.h> |
| 9 |
root |
1.5 |
|
| 10 |
|
|
#include <pango/pango.h> |
| 11 |
|
|
#include <pango/pangoft2.h> |
| 12 |
|
|
|
| 13 |
|
|
static PangoContext *context; |
| 14 |
|
|
static PangoFontMap *fontmap; |
| 15 |
root |
1.2 |
|
| 16 |
root |
1.1 |
MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
| 17 |
|
|
|
| 18 |
root |
1.5 |
BOOT: |
| 19 |
|
|
{ |
| 20 |
|
|
fontmap = pango_ft2_font_map_new (); |
| 21 |
|
|
context = pango_context_new (); |
| 22 |
|
|
pango_context_set_font_map (context, fontmap); |
| 23 |
|
|
} |
| 24 |
|
|
|
| 25 |
root |
1.3 |
char * |
| 26 |
root |
1.4 |
gl_version () |
| 27 |
|
|
CODE: |
| 28 |
root |
1.5 |
RETVAL = (char *)glGetString (GL_VERSION); |
| 29 |
root |
1.4 |
OUTPUT: |
| 30 |
|
|
RETVAL |
| 31 |
|
|
|
| 32 |
|
|
char * |
| 33 |
root |
1.3 |
gl_extensions () |
| 34 |
|
|
CODE: |
| 35 |
root |
1.5 |
RETVAL = (char *)glGetString (GL_EXTENSIONS); |
| 36 |
root |
1.3 |
OUTPUT: |
| 37 |
|
|
RETVAL |
| 38 |
|
|
|
| 39 |
root |
1.5 |
void |
| 40 |
|
|
font_render (SV *text_, int height) |
| 41 |
|
|
PPCODE: |
| 42 |
|
|
{ |
| 43 |
|
|
STRLEN textlen; |
| 44 |
|
|
char *text = SvPVutf8 (text_, textlen); |
| 45 |
|
|
SV *retval; |
| 46 |
|
|
int w, h; |
| 47 |
|
|
FT_Bitmap bitmap; |
| 48 |
|
|
PangoLayout *layout; |
| 49 |
|
|
PangoFontDescription *font = pango_context_get_font_description (context); |
| 50 |
|
|
pango_font_description_set_absolute_size (font, 40 * PANGO_SCALE); |
| 51 |
|
|
|
| 52 |
|
|
layout = pango_layout_new (context); |
| 53 |
|
|
pango_layout_set_markup (layout, text, textlen); |
| 54 |
|
|
pango_layout_get_pixel_size (layout, &w, &h); |
| 55 |
|
|
|
| 56 |
|
|
w = (w + 3) & ~3; |
| 57 |
|
|
if (h == 0) h = 1; |
| 58 |
|
|
|
| 59 |
|
|
retval = newSV (w * h); |
| 60 |
|
|
SvPOK_only (retval); |
| 61 |
|
|
SvCUR_set (retval, w * h); |
| 62 |
|
|
|
| 63 |
|
|
bitmap.rows = h; |
| 64 |
|
|
bitmap.width = w; |
| 65 |
|
|
bitmap.pitch = w; |
| 66 |
|
|
bitmap.buffer = (unsigned char*)SvPVX (retval); |
| 67 |
|
|
bitmap.num_grays = 256; |
| 68 |
|
|
bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; |
| 69 |
|
|
|
| 70 |
|
|
memset (bitmap.buffer, 0, w * h); |
| 71 |
|
|
|
| 72 |
|
|
pango_ft2_render_layout (&bitmap, layout, 0 * PANGO_SCALE, 0 * PANGO_SCALE); |
| 73 |
|
|
g_object_unref (layout); |
| 74 |
root |
1.1 |
|
| 75 |
root |
1.5 |
EXTEND (SP, 3); |
| 76 |
|
|
PUSHs (sv_2mortal (newSViv (w))); |
| 77 |
|
|
PUSHs (sv_2mortal (newSViv (h))); |
| 78 |
|
|
PUSHs (sv_2mortal (retval)); |
| 79 |
|
|
} |