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