… | |
… | |
6 | |
6 | |
7 | #include <SDL.h> |
7 | #include <SDL.h> |
8 | #include <SDL_opengl.h> |
8 | #include <SDL_opengl.h> |
9 | |
9 | |
10 | #include <pango/pango.h> |
10 | #include <pango/pango.h> |
|
|
11 | #include <pango/pangofc-fontmap.h> |
11 | #include <pango/pangoft2.h> |
12 | #include <pango/pangoft2.h> |
|
|
13 | |
|
|
14 | #include <sys/types.h> |
|
|
15 | #include <sys/socket.h> |
|
|
16 | #include <netinet/in.h> |
|
|
17 | #include <netinet/tcp.h> |
12 | |
18 | |
13 | static PangoContext *context; |
19 | static PangoContext *context; |
14 | static PangoFontMap *fontmap; |
20 | static PangoFontMap *fontmap; |
15 | |
21 | |
16 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
22 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
17 | |
23 | |
|
|
24 | PROTOTYPES: ENABLE |
|
|
25 | |
18 | BOOT: |
26 | BOOT: |
19 | { |
27 | { |
20 | fontmap = pango_ft2_font_map_new (); |
28 | fontmap = pango_ft2_font_map_new (); |
21 | context = pango_context_new (); |
29 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
22 | pango_context_set_font_map (context, fontmap); |
|
|
23 | } |
30 | } |
|
|
31 | |
|
|
32 | void |
|
|
33 | lowdelay (int fd, int val = 1) |
|
|
34 | CODE: |
|
|
35 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
24 | |
36 | |
25 | char * |
37 | char * |
26 | gl_version () |
38 | gl_version () |
27 | CODE: |
39 | CODE: |
28 | RETVAL = (char *)glGetString (GL_VERSION); |
40 | RETVAL = (char *)glGetString (GL_VERSION); |
… | |
… | |
33 | gl_extensions () |
45 | gl_extensions () |
34 | CODE: |
46 | CODE: |
35 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
47 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
36 | OUTPUT: |
48 | OUTPUT: |
37 | RETVAL |
49 | RETVAL |
|
|
50 | |
|
|
51 | void |
|
|
52 | add_font (char *file) |
|
|
53 | CODE: |
|
|
54 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
55 | |
|
|
56 | void |
|
|
57 | set_font (char *file) |
|
|
58 | CODE: |
|
|
59 | { |
|
|
60 | int count; |
|
|
61 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
|
|
62 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
|
|
63 | FcPatternDestroy (pattern); |
|
|
64 | pango_context_set_font_description (context, font); |
|
|
65 | } |
|
|
66 | |
|
|
67 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
38 | |
68 | |
39 | void |
69 | void |
40 | font_render (SV *text_, int height = 10) |
70 | font_render (SV *text_, int height = 10) |
41 | PPCODE: |
71 | PPCODE: |
42 | { |
72 | { |
… | |
… | |
76 | EXTEND (SP, 3); |
106 | EXTEND (SP, 3); |
77 | PUSHs (sv_2mortal (newSViv (w))); |
107 | PUSHs (sv_2mortal (newSViv (w))); |
78 | PUSHs (sv_2mortal (newSViv (h))); |
108 | PUSHs (sv_2mortal (newSViv (h))); |
79 | PUSHs (sv_2mortal (retval)); |
109 | PUSHs (sv_2mortal (retval)); |
80 | } |
110 | } |
|
|
111 | |
|
|
112 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture |
|
|
113 | |
|
|
114 | void |
|
|
115 | draw_quad (SV *self, double x, double y, double w = 0, double h = 0) |
|
|
116 | PROTOTYPE: $$$;$$ |
|
|
117 | CODE: |
|
|
118 | { |
|
|
119 | HV *hv = (HV *)SvRV (self); |
|
|
120 | double s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
|
|
121 | double t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
|
|
122 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
|
|
123 | |
|
|
124 | if (items < 5) |
|
|
125 | { |
|
|
126 | w = SvNV (*hv_fetch (hv, "width", 5, 1)); |
|
|
127 | h = SvNV (*hv_fetch (hv, "height", 6, 1)); |
|
|
128 | } |
|
|
129 | |
|
|
130 | glBindTexture (GL_TEXTURE_2D, name); |
|
|
131 | glBegin (GL_QUADS); |
|
|
132 | glTexCoord2d (0, 0); glVertex2d (x , y ); |
|
|
133 | glTexCoord2d (0, t); glVertex2d (x , y + h); |
|
|
134 | glTexCoord2d (s, t); glVertex2d (x + w, y + h); |
|
|
135 | glTexCoord2d (s, 0); glVertex2d (x + w, y ); |
|
|
136 | glEnd (); |
|
|
137 | } |