… | |
… | |
33 | typedef signed char int8_t; |
33 | typedef signed char int8_t; |
34 | typedef signed short int16_t; |
34 | typedef signed short int16_t; |
35 | typedef signed int int32_t; |
35 | typedef signed int int32_t; |
36 | #endif |
36 | #endif |
37 | |
37 | |
|
|
38 | #include "glext.h" |
|
|
39 | |
38 | #define FOW_DARKNESS 32 |
40 | #define FOW_DARKNESS 32 |
39 | |
41 | |
40 | #define MAP_EXTEND_X 32 |
42 | #define MAP_EXTEND_X 32 |
41 | #define MAP_EXTEND_Y 512 |
43 | #define MAP_EXTEND_Y 512 |
|
|
44 | |
|
|
45 | #define MIN_FONT_HEIGHT 8 * PANGO_SCALE |
42 | |
46 | |
43 | typedef Mix_Chunk *CFClient__MixChunk; |
47 | typedef Mix_Chunk *CFClient__MixChunk; |
44 | typedef Mix_Music *CFClient__MixMusic; |
48 | typedef Mix_Music *CFClient__MixMusic; |
45 | |
49 | |
46 | static PangoContext *context; |
50 | static PangoContext *context; |
… | |
… | |
62 | layout_update (CFClient__Layout self) |
66 | layout_update (CFClient__Layout self) |
63 | { |
67 | { |
64 | /* use a random scale factor to account for unknown descenders, 0.8 works |
68 | /* use a random scale factor to account for unknown descenders, 0.8 works |
65 | * reasonably well with bitstream vera |
69 | * reasonably well with bitstream vera |
66 | */ |
70 | */ |
67 | PangoFontDescription *font = pango_context_get_font_description (context); |
71 | PangoFontDescription *font = pango_layout_get_font_description (self->pl); |
68 | |
72 | |
69 | int height = self->base_height * (PANGO_SCALE * 8 / 10); |
73 | int height = self->base_height * (PANGO_SCALE * 8 / 10); |
|
|
74 | |
|
|
75 | if (height < MIN_FONT_HEIGHT) |
|
|
76 | height = MIN_FONT_HEIGHT; |
70 | |
77 | |
71 | if (pango_font_description_get_size (font) != height) |
78 | if (pango_font_description_get_size (font) != height) |
72 | { |
79 | { |
|
|
80 | font = pango_font_description_copy (font); |
73 | pango_font_description_set_absolute_size (font, height); |
81 | pango_font_description_set_absolute_size (font, height); |
74 | pango_layout_context_changed (self->pl); |
82 | pango_layout_set_font_description (self->pl, font); |
75 | } |
83 | } |
76 | } |
84 | } |
77 | |
85 | |
78 | static void |
86 | static void |
79 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
87 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
… | |
… | |
237 | break; |
245 | break; |
238 | |
246 | |
239 | row->col[x - row->c0].darkness = -1; |
247 | row->col[x - row->c0].darkness = -1; |
240 | } |
248 | } |
241 | } |
249 | } |
|
|
250 | } |
|
|
251 | |
|
|
252 | static void |
|
|
253 | music_finished () |
|
|
254 | { |
|
|
255 | SDL_UserEvent ev; |
|
|
256 | |
|
|
257 | ev.type = SDL_USEREVENT; |
|
|
258 | ev.code = 0; |
|
|
259 | ev.data1 = 0; |
|
|
260 | ev.data2 = 0; |
|
|
261 | |
|
|
262 | SDL_PushEvent ((SDL_Event *)&ev); |
242 | } |
263 | } |
243 | |
264 | |
244 | MODULE = CFClient PACKAGE = CFClient |
265 | MODULE = CFClient PACKAGE = CFClient |
245 | |
266 | |
246 | PROTOTYPES: ENABLE |
267 | PROTOTYPES: ENABLE |
… | |
… | |
463 | } |
484 | } |
464 | } |
485 | } |
465 | |
486 | |
466 | int |
487 | int |
467 | Mix_OpenAudio (int frequency = 22050, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 512) |
488 | Mix_OpenAudio (int frequency = 22050, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 512) |
|
|
489 | POSTCALL: |
|
|
490 | Mix_HookMusicFinished (music_finished); |
468 | |
491 | |
469 | void |
492 | void |
470 | Mix_CloseAudio () |
493 | Mix_CloseAudio () |
471 | |
494 | |
472 | int |
495 | int |
… | |
… | |
504 | { |
527 | { |
505 | int count; |
528 | int count; |
506 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
529 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
507 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
530 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
508 | FcPatternDestroy (pattern); |
531 | FcPatternDestroy (pattern); |
|
|
532 | pango_font_description_set_absolute_size (font, MIN_FONT_HEIGHT); |
509 | pango_context_set_font_description (context, font); |
533 | pango_context_set_font_description (context, font); |
510 | } |
534 | } |
511 | |
535 | |
512 | void |
536 | void |
513 | load_image_inline (SV *image_) |
537 | load_image_inline (SV *image_) |
… | |
… | |
615 | CODE: |
639 | CODE: |
616 | New (0, RETVAL, 1, struct cf_layout); |
640 | New (0, RETVAL, 1, struct cf_layout); |
617 | RETVAL->base_height = base_height; |
641 | RETVAL->base_height = base_height; |
618 | RETVAL->pl = pango_layout_new (context); |
642 | RETVAL->pl = pango_layout_new (context); |
619 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
643 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
|
|
644 | pango_layout_set_font_description (RETVAL->pl, |
|
|
645 | pango_font_description_copy ( |
|
|
646 | pango_context_get_font_description (context))); |
620 | OUTPUT: |
647 | OUTPUT: |
621 | RETVAL |
648 | RETVAL |
622 | |
649 | |
623 | void |
650 | void |
624 | DESTROY (CFClient::Layout self) |
651 | DESTROY (CFClient::Layout self) |
… | |
… | |
933 | cell->darkness = -1; |
960 | cell->darkness = -1; |
934 | } |
961 | } |
935 | } |
962 | } |
936 | |
963 | |
937 | SV * |
964 | SV * |
938 | mapmap (CFClient::Map self, int w, int h) |
965 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
939 | CODE: |
966 | CODE: |
940 | { |
967 | { |
941 | int x0, x1, x; |
968 | int x1, x; |
942 | int y0, y1, y; |
969 | int y1, y; |
943 | int z; |
970 | int z; |
944 | SV *map_sv = newSV (w * h * sizeof (uint32_t)); |
971 | SV *map_sv = newSV (w * h * sizeof (uint32_t)); |
945 | uint32_t *map = (uint32_t *)SvPVX (map_sv); |
972 | uint32_t *map = (uint32_t *)SvPVX (map_sv); |
946 | |
973 | |
947 | SvPOK_only (map_sv); |
974 | SvPOK_only (map_sv); |
948 | SvCUR_set (map_sv, w * h * sizeof (uint32_t)); |
975 | SvCUR_set (map_sv, w * h * sizeof (uint32_t)); |
949 | |
976 | |
950 | x0 = self->x - w / 2; x1 = x0 + w; |
977 | x0 += self->x; x1 = x0 + w; |
951 | y0 = self->y - h / 2; y1 = y0 + h; |
978 | y0 += self->y; y1 = y0 + h; |
952 | |
979 | |
953 | for (y = y0; y < y1; y++) |
980 | for (y = y0; y < y1; y++) |
954 | { |
981 | { |
955 | maprow *row = 0 <= y && y < self->rows |
982 | maprow *row = 0 <= y && y < self->rows |
956 | ? self->row + y |
983 | ? self->row + y |
… | |
… | |
1096 | *data++ = 0; /* version 0 format */ |
1123 | *data++ = 0; /* version 0 format */ |
1097 | *data++ = w >> 8; *data++ = w; |
1124 | *data++ = w >> 8; *data++ = w; |
1098 | *data++ = h >> 8; *data++ = h; |
1125 | *data++ = h >> 8; *data++ = h; |
1099 | |
1126 | |
1100 | // we need to do this 'cause we don't keep an absolute coord system for rows |
1127 | // we need to do this 'cause we don't keep an absolute coord system for rows |
1101 | // TODO: treat rows as we treat |
1128 | // TODO: treat rows as we treat columns |
1102 | map_get_row (self, y0 + self->y - self->oy);//D |
1129 | map_get_row (self, y0 + self->y - self->oy);//D |
1103 | map_get_row (self, y0 + self->y - self->oy + h - 1);//D |
1130 | map_get_row (self, y0 + self->y - self->oy + h - 1);//D |
1104 | |
1131 | |
1105 | x0 += self->x - self->ox; |
1132 | x0 += self->x - self->ox; |
1106 | y0 += self->y - self->oy; |
1133 | y0 += self->y - self->oy; |
… | |
… | |
1170 | |
1197 | |
1171 | w = *data++ << 8; w |= *data++; |
1198 | w = *data++ << 8; w |= *data++; |
1172 | h = *data++ << 8; h |= *data++; |
1199 | h = *data++ << 8; h |= *data++; |
1173 | |
1200 | |
1174 | // we need to do this 'cause we don't keep an absolute coord system for rows |
1201 | // we need to do this 'cause we don't keep an absolute coord system for rows |
1175 | // TODO: treat rows as we treat |
1202 | // TODO: treat rows as we treat columns |
1176 | map_get_row (self, y0 + self->y - self->oy);//D |
1203 | map_get_row (self, y0 + self->y - self->oy);//D |
1177 | map_get_row (self, y0 + self->y - self->oy + h - 1);//D |
1204 | map_get_row (self, y0 + self->y - self->oy + h - 1);//D |
1178 | |
1205 | |
1179 | x0 += self->x - self->ox; |
1206 | x0 += self->x - self->ox; |
1180 | y0 += self->y - self->oy; |
1207 | y0 += self->y - self->oy; |
… | |
… | |
1308 | const_iv (GL_TEXTURE_WRAP_T), |
1335 | const_iv (GL_TEXTURE_WRAP_T), |
1309 | const_iv (GL_CLAMP), |
1336 | const_iv (GL_CLAMP), |
1310 | const_iv (GL_REPEAT), |
1337 | const_iv (GL_REPEAT), |
1311 | const_iv (GL_NEAREST), |
1338 | const_iv (GL_NEAREST), |
1312 | const_iv (GL_LINEAR), |
1339 | const_iv (GL_LINEAR), |
|
|
1340 | const_iv (GL_NEAREST_MIPMAP_NEAREST), |
|
|
1341 | const_iv (GL_LINEAR_MIPMAP_NEAREST), |
|
|
1342 | const_iv (GL_NEAREST_MIPMAP_LINEAR), |
|
|
1343 | const_iv (GL_LINEAR_MIPMAP_LINEAR), |
|
|
1344 | const_iv (GL_GENERATE_MIPMAP), |
|
|
1345 | const_iv (GL_LINEAR), |
1313 | const_iv (GL_MODULATE), |
1346 | const_iv (GL_MODULATE), |
1314 | const_iv (GL_REPLACE), |
1347 | const_iv (GL_REPLACE), |
1315 | const_iv (GL_COLOR_BUFFER_BIT), |
1348 | const_iv (GL_COLOR_BUFFER_BIT), |
1316 | const_iv (GL_PROJECTION), |
1349 | const_iv (GL_PROJECTION), |
1317 | const_iv (GL_MODELVIEW), |
1350 | const_iv (GL_MODELVIEW), |
… | |
… | |
1319 | const_iv (GL_CONVOLUTION_2D), |
1352 | const_iv (GL_CONVOLUTION_2D), |
1320 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1353 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1321 | const_iv (GL_CONSTANT_BORDER), |
1354 | const_iv (GL_CONSTANT_BORDER), |
1322 | const_iv (GL_LINES), |
1355 | const_iv (GL_LINES), |
1323 | const_iv (GL_QUADS), |
1356 | const_iv (GL_QUADS), |
|
|
1357 | const_iv (GL_LINE_LOOP), |
1324 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
1358 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
1325 | const_iv (GL_FASTEST), |
1359 | const_iv (GL_FASTEST), |
1326 | # undef const_iv |
1360 | # undef const_iv |
1327 | }; |
1361 | }; |
1328 | |
1362 | |