… | |
… | |
15 | |
15 | |
16 | #include "EXTERN.h" |
16 | #include "EXTERN.h" |
17 | #include "perl.h" |
17 | #include "perl.h" |
18 | #include "XSUB.h" |
18 | #include "XSUB.h" |
19 | |
19 | |
|
|
20 | #include "flat_hash_map.hpp" |
|
|
21 | |
20 | #ifdef _WIN32 |
22 | #ifdef _WIN32 |
21 | # undef pipe |
23 | # undef pipe |
22 | // microsoft vs. C |
24 | // microsoft vs. C |
23 | # define sqrtf(x) sqrt(x) |
25 | # define sqrtf(x) sqrt(x) |
24 | # define atan2f(x,y) atan2(x,y) |
26 | # define atan2f(x,y) atan2(x,y) |
25 | # define M_PI 3.14159265f |
27 | # define M_PI 3.14159265f |
26 | #endif |
28 | #endif |
27 | |
29 | |
28 | #include <assert.h> |
30 | #include <cassert> |
29 | #include <math.h> |
31 | #include <cmath> |
30 | #include <string.h> |
32 | #include <cstring> |
31 | #include <stdio.h> |
33 | #include <cstdio> |
32 | #include <stdlib.h> |
34 | #include <cstdlib> |
|
|
35 | |
|
|
36 | #include <utility> |
33 | |
37 | |
34 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
38 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
35 | |
39 | |
36 | #include <SDL.h> |
40 | #include <SDL.h> |
37 | #include <SDL_thread.h> |
41 | #include <SDL_thread.h> |
… | |
… | |
48 | #endif |
52 | #endif |
49 | |
53 | |
50 | #define PANGO_ENABLE_BACKEND |
54 | #define PANGO_ENABLE_BACKEND |
51 | #define G_DISABLE_CAST_CHECKS |
55 | #define G_DISABLE_CAST_CHECKS |
52 | |
56 | |
53 | #include <glib/gmacros.h> |
57 | #include <glib.h> |
54 | |
58 | |
55 | #include <pango/pango.h> |
59 | #include <pango/pango.h> |
56 | |
60 | |
57 | #ifndef PANGO_VERSION_CHECK |
61 | #ifndef PANGO_VERSION_CHECK |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
62 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
… | |
… | |
184 | { |
188 | { |
185 | GSList *attrs = run->item->analysis.extra_attrs; |
189 | GSList *attrs = run->item->analysis.extra_attrs; |
186 | |
190 | |
187 | while (attrs) |
191 | while (attrs) |
188 | { |
192 | { |
189 | PangoAttribute *attr = attrs->data; |
193 | PangoAttribute *attr = (PangoAttribute *)attrs->data; |
190 | |
194 | |
191 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
195 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
192 | return 1; |
196 | return 1; |
193 | |
197 | |
194 | attrs = attrs->next; |
198 | attrs = attrs->next; |
… | |
… | |
212 | static void |
216 | static void |
213 | substitute_func (FcPattern *pattern, gpointer data) |
217 | substitute_func (FcPattern *pattern, gpointer data) |
214 | { |
218 | { |
215 | FcPatternAddBool (pattern, FC_HINTING, 1); |
219 | FcPatternAddBool (pattern, FC_HINTING, 1); |
216 | #ifdef FC_HINT_STYLE |
220 | #ifdef FC_HINT_STYLE |
217 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
221 | FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
218 | #endif |
222 | #endif |
219 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
223 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
220 | } |
224 | } |
221 | |
225 | |
222 | static void |
226 | static void |
… | |
… | |
439 | CELL_CLEAR (cell); |
443 | CELL_CLEAR (cell); |
440 | } |
444 | } |
441 | } |
445 | } |
442 | } |
446 | } |
443 | |
447 | |
444 | typedef struct { |
448 | struct smooth_key |
|
|
449 | { |
445 | tileid tile; |
450 | tileid tile; |
446 | uint8_t x, y, level; |
451 | uint8_t x, y, level; |
447 | } smooth_key; |
452 | |
|
|
453 | bool operator == (const smooth_key &o) const |
|
|
454 | { |
|
|
455 | return tile == o.tile && x == o.x && y == o.y && level == o.level; |
|
|
456 | } |
|
|
457 | }; |
|
|
458 | |
|
|
459 | typedef ska::flat_hash_map<smooth_key, IV> smooth_hash; |
|
|
460 | |
|
|
461 | namespace std { |
|
|
462 | template <> |
|
|
463 | struct hash<smooth_key> |
|
|
464 | { |
|
|
465 | size_t operator () (const smooth_key &v) const |
|
|
466 | { |
|
|
467 | return v.tile + (v.x << 8) + (v.y << 16) + (v.level << 24); |
|
|
468 | } |
|
|
469 | }; |
|
|
470 | } |
448 | |
471 | |
449 | static void |
472 | static void |
450 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
473 | smooth_or_bits (smooth_hash &h, smooth_key &key, IV bits) |
451 | { |
474 | { |
452 | SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); |
475 | auto &&it = h.find (key); |
453 | |
476 | |
454 | if (SvIOK (*sv)) |
477 | if (it == h.end ()) |
455 | SvIV_set (*sv, SvIVX (*sv) | bits); |
478 | h.insert (std::make_pair (key, bits)); |
456 | else |
479 | else |
457 | sv_setiv (*sv, bits); |
480 | it->second |= bits; |
458 | } |
481 | } |
459 | |
482 | |
460 | static void |
483 | static void |
461 | music_finished (void) |
484 | music_finished (void) |
462 | { |
485 | { |
… | |
… | |
481 | ev.data2 = 0; |
504 | ev.data2 = 0; |
482 | |
505 | |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
506 | SDL_PushEvent ((SDL_Event *)&ev); |
484 | } |
507 | } |
485 | |
508 | |
|
|
509 | // approximately divide by 255 |
486 | static unsigned int |
510 | static unsigned int |
487 | div255 (unsigned int n) |
511 | div255 (unsigned int n) |
488 | { |
512 | { |
489 | return (n + (n >> 8)) >> 8; |
513 | return (n + (n >> 8)) >> 8; |
490 | } |
514 | } |
… | |
… | |
889 | void SDL_QuitSubSystem (U32 flags) |
913 | void SDL_QuitSubSystem (U32 flags) |
890 | |
914 | |
891 | void SDL_Quit () |
915 | void SDL_Quit () |
892 | |
916 | |
893 | int SDL_GL_SetAttribute (int attr, int value) |
917 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
918 | C_ARGS: (SDL_GLattr)attr, value |
894 | |
919 | |
895 | int SDL_GL_GetAttribute (int attr) |
920 | int SDL_GL_GetAttribute (int attr) |
896 | CODE: |
921 | CODE: |
897 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
922 | if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL)) |
898 | XSRETURN_UNDEF; |
923 | XSRETURN_UNDEF; |
899 | OUTPUT: |
924 | OUTPUT: |
900 | RETVAL |
925 | RETVAL |
901 | |
926 | |
902 | void |
927 | void |
… | |
… | |
975 | void |
1000 | void |
976 | SDL_GL_SwapBuffers () |
1001 | SDL_GL_SwapBuffers () |
977 | |
1002 | |
978 | char * |
1003 | char * |
979 | SDL_GetKeyName (int sym) |
1004 | SDL_GetKeyName (int sym) |
|
|
1005 | C_ARGS: (SDLKey)sym |
980 | |
1006 | |
981 | int |
1007 | int |
982 | SDL_GetAppState () |
1008 | SDL_GetAppState () |
983 | |
1009 | |
984 | int |
1010 | int |
… | |
… | |
1081 | OUTPUT: |
1107 | OUTPUT: |
1082 | RETVAL |
1108 | RETVAL |
1083 | |
1109 | |
1084 | int |
1110 | int |
1085 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1111 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1086 | POSTCALL: |
1112 | POSTCALL: |
1087 | Mix_HookMusicFinished (music_finished); |
1113 | Mix_HookMusicFinished (music_finished); |
1088 | Mix_ChannelFinished (channel_finished); |
1114 | Mix_ChannelFinished (channel_finished); |
1089 | |
1115 | |
1090 | void |
1116 | void |
1091 | Mix_QuerySpec () |
1117 | Mix_QuerySpec () |
… | |
… | |
1212 | |
1238 | |
1213 | SDL_LockSurface (surface2); |
1239 | SDL_LockSurface (surface2); |
1214 | EXTEND (SP, 6); |
1240 | EXTEND (SP, 6); |
1215 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1241 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1216 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1242 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1217 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
1243 | PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch))); |
1218 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1244 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1219 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1245 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1220 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1246 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1221 | SDL_UnlockSurface (surface2); |
1247 | SDL_UnlockSurface (surface2); |
1222 | |
1248 | |
… | |
… | |
1294 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1320 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1295 | |
1321 | |
1296 | PROTOTYPES: DISABLE |
1322 | PROTOTYPES: DISABLE |
1297 | |
1323 | |
1298 | DC::Font |
1324 | DC::Font |
1299 | new_from_file (SV *class, char *path, int id = 0) |
1325 | new_from_file (SV *klass, char *path, int id = 0) |
1300 | CODE: |
1326 | CODE: |
1301 | { |
1327 | { |
1302 | int count; |
1328 | int count; |
1303 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1329 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1304 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
1330 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
… | |
… | |
1333 | PROTOTYPE: |
1359 | PROTOTYPE: |
1334 | CODE: |
1360 | CODE: |
1335 | tc_restore (); |
1361 | tc_restore (); |
1336 | |
1362 | |
1337 | DC::Layout |
1363 | DC::Layout |
1338 | new (SV *class) |
1364 | new (SV *klass) |
1339 | CODE: |
1365 | CODE: |
1340 | New (0, RETVAL, 1, struct cf_layout); |
1366 | New (0, RETVAL, 1, struct cf_layout); |
1341 | |
1367 | |
1342 | RETVAL->pl = pango_layout_new (opengl_context); |
1368 | RETVAL->pl = pango_layout_new (opengl_context); |
1343 | RETVAL->r = 1.; |
1369 | RETVAL->r = 1.; |
… | |
… | |
1492 | |
1518 | |
1493 | void |
1519 | void |
1494 | set_height (DC::Layout self, int base_height) |
1520 | set_height (DC::Layout self, int base_height) |
1495 | CODE: |
1521 | CODE: |
1496 | if (self->base_height != base_height) |
1522 | if (self->base_height != base_height) |
1497 | { |
1523 | { |
1498 | self->base_height = base_height; |
1524 | self->base_height = base_height; |
1499 | layout_update_font (self); |
1525 | layout_update_font (self); |
1500 | } |
1526 | } |
1501 | |
1527 | |
1502 | void |
1528 | void |
… | |
… | |
1866 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1892 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1867 | |
1893 | |
1868 | PROTOTYPES: DISABLE |
1894 | PROTOTYPES: DISABLE |
1869 | |
1895 | |
1870 | DC::Map |
1896 | DC::Map |
1871 | new (SV *class) |
1897 | new (SV *klass) |
1872 | CODE: |
1898 | CODE: |
1873 | New (0, RETVAL, 1, struct map); |
1899 | New (0, RETVAL, 1, struct map); |
1874 | RETVAL->x = 0; |
1900 | RETVAL->x = 0; |
1875 | RETVAL->y = 0; |
1901 | RETVAL->y = 0; |
1876 | RETVAL->w = 0; |
1902 | RETVAL->w = 0; |
… | |
… | |
1915 | |
1941 | |
1916 | void |
1942 | void |
1917 | set_smooth (DC::Map self, int face, int smooth, int level) |
1943 | set_smooth (DC::Map self, int face, int smooth, int level) |
1918 | CODE: |
1944 | CODE: |
1919 | { |
1945 | { |
1920 | tileid texid; |
1946 | tileid texid; |
1921 | maptex *tex; |
1947 | maptex *tex; |
1922 | |
1948 | |
1923 | if (face < 0 || face >= self->faces) |
1949 | if (face < 0 || face >= self->faces) |
1924 | return; |
1950 | return; |
1925 | |
1951 | |
1926 | if (smooth < 0 || smooth >= self->faces) |
1952 | if (smooth < 0 || smooth >= self->faces) |
1927 | return; |
1953 | return; |
1928 | |
1954 | |
1929 | texid = self->face2tile [face]; |
1955 | texid = self->face2tile [face]; |
1930 | |
1956 | |
1931 | if (!texid) |
1957 | if (!texid) |
1932 | return; |
1958 | return; |
1933 | |
1959 | |
1934 | tex = self->tex + texid; |
1960 | tex = self->tex + texid; |
… | |
… | |
1967 | } |
1993 | } |
1968 | |
1994 | |
1969 | void |
1995 | void |
1970 | expire_textures (DC::Map self, int texid, int count) |
1996 | expire_textures (DC::Map self, int texid, int count) |
1971 | PPCODE: |
1997 | PPCODE: |
1972 | for (; texid < self->texs && count; ++texid, --count) |
1998 | for (; texid < self->texs && count; ++texid, --count) |
1973 | { |
1999 | { |
1974 | maptex *tex = self->tex + texid; |
2000 | maptex *tex = self->tex + texid; |
1975 | |
2001 | |
1976 | if (tex->name) |
2002 | if (tex->name) |
1977 | { |
2003 | { |
… | |
… | |
2179 | | (b << 16) |
2205 | | (b << 16) |
2180 | | (a << 24); |
2206 | | (a << 24); |
2181 | } |
2207 | } |
2182 | } |
2208 | } |
2183 | |
2209 | |
2184 | RETVAL = map_sv; |
2210 | RETVAL = map_sv; |
2185 | } |
2211 | } |
2186 | OUTPUT: |
2212 | OUTPUT: |
2187 | RETVAL |
2213 | RETVAL |
2188 | |
2214 | |
2189 | void |
2215 | void |
2190 | draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2216 | draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2191 | CODE: |
2217 | CODE: |
2192 | { |
2218 | { |
2193 | int x, y, z; |
2219 | int x, y, z; |
2194 | |
2220 | |
2195 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
|
|
2196 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2221 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2197 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2222 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2198 | smooth_key skey; |
2223 | smooth_key skey; |
2199 | int pl_x, pl_y; |
2224 | int pl_x, pl_y; |
2200 | maptex pl_tex; |
2225 | maptex pl_tex; |
… | |
… | |
2249 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2274 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2250 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2275 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2251 | |
2276 | |
2252 | for (z = 0; z <= 2; z++) |
2277 | for (z = 0; z <= 2; z++) |
2253 | { |
2278 | { |
|
|
2279 | smooth_hash smooth; |
2254 | memset (smooth_level, 0, sizeof (smooth_level)); |
2280 | memset (smooth_level, 0, sizeof (smooth_level)); |
2255 | key.texname = -1; |
2281 | key.texname = -1; |
2256 | |
2282 | |
2257 | for (y = 0; y < sh; y++) |
2283 | for (y = 0; y < sh; y++) |
2258 | if (0 <= y + my && y + my < self->rows) |
2284 | if (0 <= y + my && y + my < self->rows) |
… | |
… | |
2319 | |
2345 | |
2320 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2346 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2321 | // ·· ·· ·┏ ┓· |
2347 | // ·· ·· ·┏ ┓· |
2322 | |
2348 | |
2323 | // full tile |
2349 | // full tile |
2324 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); |
2350 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x1000); |
2325 | |
2351 | |
2326 | // borders |
2352 | // borders |
2327 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); |
2353 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0091); |
2328 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); |
2354 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0032); |
2329 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); |
2355 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0064); |
2330 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); |
2356 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, skey, 0x00c8); |
2331 | |
2357 | |
2332 | // corners |
2358 | // corners |
2333 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2359 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0100); |
2334 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2360 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0200); |
2335 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2361 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); |
2336 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2362 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); |
2337 | } |
2363 | } |
2338 | } |
2364 | } |
2339 | |
2365 | |
2340 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2366 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2341 | { |
2367 | { |
… | |
… | |
2378 | if (smask & (((uint32_t)1) << b)) |
2404 | if (smask & (((uint32_t)1) << b)) |
2379 | { |
2405 | { |
2380 | int level = (w << 5) | b; |
2406 | int level = (w << 5) | b; |
2381 | HE *he; |
2407 | HE *he; |
2382 | |
2408 | |
2383 | hv_iterinit (smooth); |
2409 | for (auto &&it = smooth.begin (); it != smooth.end (); ++it) |
2384 | while ((he = hv_iternext (smooth))) |
|
|
2385 | { |
2410 | { |
2386 | smooth_key *skey = (smooth_key *)HeKEY (he); |
2411 | smooth_key &skey = it->first; |
2387 | IV bits = SvIVX (HeVAL (he)); |
2412 | IV bits = it->second; |
2388 | |
2413 | |
2389 | if (!(bits & 0x1000) |
2414 | if (!(bits & 0x1000) |
2390 | && skey->level == level |
2415 | && skey.level == level |
2391 | && level > smooth_max [skey->x][skey->y]) |
2416 | && level > smooth_max [skey.x][skey.y]) |
2392 | { |
2417 | { |
2393 | maptex tex = self->tex [skey->tile]; |
2418 | maptex tex = self->tex [skey.tile]; |
2394 | int px = (((int)skey->x) - 1) * Tw; |
2419 | int px = (((int)skey.x) - 1) * Tw; |
2395 | int py = (((int)skey->y) - 1) * Th; |
2420 | int py = (((int)skey.y) - 1) * Th; |
2396 | int border = bits & 15; |
2421 | int border = bits & 15; |
2397 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2422 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2398 | float dx = tex.s * .0625f; // 16 images/row |
2423 | float dx = tex.s * .0625f; // 16 images/row |
2399 | float dy = tex.t * .5f ; // 2 images/column |
2424 | float dy = tex.t * .5f ; // 2 images/column |
2400 | |
2425 | |
… | |
… | |
2402 | { |
2427 | { |
2403 | // this time avoiding texture state changes |
2428 | // this time avoiding texture state changes |
2404 | // save gobs of state changes. |
2429 | // save gobs of state changes. |
2405 | if (key.texname != tex.name) |
2430 | if (key.texname != tex.name) |
2406 | { |
2431 | { |
2407 | self->tex [skey->tile].unused = 0; |
2432 | self->tex [skey.tile].unused = 0; |
2408 | |
2433 | |
2409 | glEnd (); |
2434 | glEnd (); |
2410 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2435 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2411 | glBegin (GL_QUADS); |
2436 | glBegin (GL_QUADS); |
2412 | } |
2437 | } |
… | |
… | |
2438 | |
2463 | |
2439 | glEnd (); |
2464 | glEnd (); |
2440 | glDisable (GL_TEXTURE_2D); |
2465 | glDisable (GL_TEXTURE_2D); |
2441 | key.texname = -1; |
2466 | key.texname = -1; |
2442 | } |
2467 | } |
2443 | |
|
|
2444 | hv_clear (smooth); |
|
|
2445 | } |
2468 | } |
2446 | |
2469 | |
2447 | if (pl_tex.name) |
2470 | if (pl_tex.name) |
2448 | { |
2471 | { |
2449 | maptex tex = pl_tex; |
2472 | maptex tex = pl_tex; |
… | |
… | |
2718 | else |
2741 | else |
2719 | *data++ = 0; |
2742 | *data++ = 0; |
2720 | } |
2743 | } |
2721 | } |
2744 | } |
2722 | |
2745 | |
2723 | /* if size is w*h + 5 then no data has been found */ |
2746 | /* if size is w*h + 5 then no data has been found */ |
2724 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2747 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2725 | { |
2748 | { |
2726 | SvPOK_only (data_sv); |
2749 | SvPOK_only (data_sv); |
2727 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2750 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2728 | } |
2751 | } |
2729 | |
2752 | |
2730 | RETVAL = data_sv; |
2753 | RETVAL = data_sv; |
2731 | } |
2754 | } |
2732 | OUTPUT: |
2755 | OUTPUT: |
2733 | RETVAL |
2756 | RETVAL |
2734 | |
2757 | |
2735 | void |
2758 | void |
… | |
… | |
2742 | STRLEN len; |
2765 | STRLEN len; |
2743 | uint8_t *data, *end; |
2766 | uint8_t *data, *end; |
2744 | |
2767 | |
2745 | len = SvLEN (data_sv); |
2768 | len = SvLEN (data_sv); |
2746 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2769 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2747 | data = SvPVbyte_nolen (data_sv); |
2770 | data = (uint8_t *)SvPVbyte_nolen (data_sv); |
2748 | end = data + len + 8; |
2771 | end = data + len + 8; |
2749 | |
2772 | |
2750 | if (len < 5) |
2773 | if (len < 5) |
2751 | XSRETURN_EMPTY; |
2774 | XSRETURN_EMPTY; |
2752 | |
2775 | |
… | |
… | |
2813 | } |
2836 | } |
2814 | |
2837 | |
2815 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2838 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2816 | |
2839 | |
2817 | DC::RW |
2840 | DC::RW |
2818 | new (SV *class, SV *data_sv) |
2841 | new (SV *klass, SV *data_sv) |
2819 | CODE: |
2842 | CODE: |
2820 | { |
2843 | { |
2821 | STRLEN datalen; |
2844 | STRLEN datalen; |
2822 | char *data = SvPVbyte (data_sv, datalen); |
2845 | char *data = SvPVbyte (data_sv, datalen); |
2823 | |
2846 | |
… | |
… | |
2825 | } |
2848 | } |
2826 | OUTPUT: |
2849 | OUTPUT: |
2827 | RETVAL |
2850 | RETVAL |
2828 | |
2851 | |
2829 | DC::RW |
2852 | DC::RW |
2830 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2853 | new_from_file (SV *klass, const char *path, const char *mode = "rb") |
2831 | CODE: |
2854 | CODE: |
2832 | RETVAL = SDL_RWFromFile (path, mode); |
2855 | RETVAL = SDL_RWFromFile (path, mode); |
2833 | OUTPUT: |
2856 | OUTPUT: |
2834 | RETVAL |
2857 | RETVAL |
2835 | |
2858 | |
… | |
… | |
2944 | #else |
2967 | #else |
2945 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2968 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2946 | #endif |
2969 | #endif |
2947 | |
2970 | |
2948 | DC::MixChunk |
2971 | DC::MixChunk |
2949 | new (SV *class, DC::RW rwops) |
2972 | new (SV *klass, DC::RW rwops) |
2950 | CODE: |
2973 | CODE: |
2951 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2974 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2952 | OUTPUT: |
2975 | OUTPUT: |
2953 | RETVAL |
2976 | RETVAL |
2954 | |
2977 | |
… | |
… | |
3024 | RETVAL = Mix_PlayingMusic (); |
3047 | RETVAL = Mix_PlayingMusic (); |
3025 | OUTPUT: |
3048 | OUTPUT: |
3026 | RETVAL |
3049 | RETVAL |
3027 | |
3050 | |
3028 | DC::MixMusic |
3051 | DC::MixMusic |
3029 | new (SV *class, DC::RW rwops) |
3052 | new (SV *klass, DC::RW rwops) |
3030 | CODE: |
3053 | CODE: |
3031 | RETVAL = Mix_LoadMUS_RW (rwops); |
3054 | RETVAL = Mix_LoadMUS_RW (rwops); |
3032 | OUTPUT: |
3055 | OUTPUT: |
3033 | RETVAL |
3056 | RETVAL |
3034 | |
3057 | |
… | |
… | |
3187 | gl.BlendFuncSeparateEXT = 0; |
3210 | gl.BlendFuncSeparateEXT = 0; |
3188 | |
3211 | |
3189 | void |
3212 | void |
3190 | apple_nvidia_bug (int enable) |
3213 | apple_nvidia_bug (int enable) |
3191 | |
3214 | |
3192 | char * |
3215 | const char * |
3193 | gl_vendor () |
3216 | gl_vendor () |
3194 | CODE: |
3217 | CODE: |
3195 | RETVAL = (char *)glGetString (GL_VENDOR); |
3218 | RETVAL = (const char *)glGetString (GL_VENDOR); |
3196 | OUTPUT: |
3219 | OUTPUT: |
3197 | RETVAL |
3220 | RETVAL |
3198 | |
3221 | |
3199 | char * |
3222 | const char * |
3200 | gl_version () |
3223 | gl_version () |
3201 | CODE: |
3224 | CODE: |
3202 | RETVAL = (char *)glGetString (GL_VERSION); |
3225 | RETVAL = (const char *)glGetString (GL_VERSION); |
3203 | OUTPUT: |
3226 | OUTPUT: |
3204 | RETVAL |
3227 | RETVAL |
3205 | |
3228 | |
3206 | char * |
3229 | const char * |
3207 | gl_extensions () |
3230 | gl_extensions () |
3208 | CODE: |
3231 | CODE: |
3209 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
3232 | RETVAL = (const char *)glGetString (GL_EXTENSIONS); |
3210 | OUTPUT: |
3233 | OUTPUT: |
3211 | RETVAL |
3234 | RETVAL |
3212 | |
3235 | |
3213 | const char *glGetString (GLenum pname) |
3236 | const char *glGetString (GLenum pname) |
|
|
3237 | CODE: |
|
|
3238 | RETVAL = (const char *)glGetString (pname); |
|
|
3239 | OUTPUT: |
|
|
3240 | RETVAL |
3214 | |
3241 | |
3215 | GLint glGetInteger (GLenum pname) |
3242 | GLint glGetInteger (GLenum pname) |
3216 | CODE: |
3243 | CODE: |
3217 | glGetIntegerv (pname, &RETVAL); |
3244 | glGetIntegerv (pname, &RETVAL); |
3218 | OUTPUT: |
3245 | OUTPUT: |
… | |
… | |
3421 | |
3448 | |
3422 | void |
3449 | void |
3423 | find_widget (SV *self, NV x, NV y) |
3450 | find_widget (SV *self, NV x, NV y) |
3424 | PPCODE: |
3451 | PPCODE: |
3425 | { |
3452 | { |
3426 | if (within_widget (self, x, y)) |
3453 | if (within_widget (self, x, y)) |
3427 | XPUSHs (self); |
3454 | XPUSHs (self); |
3428 | } |
3455 | } |
3429 | |
3456 | |
3430 | BOOT: |
3457 | BOOT: |
3431 | { |
3458 | { |
… | |
… | |
3439 | |
3466 | |
3440 | void |
3467 | void |
3441 | draw (SV *self) |
3468 | draw (SV *self) |
3442 | CODE: |
3469 | CODE: |
3443 | { |
3470 | { |
3444 | HV *hv; |
3471 | HV *hv; |
3445 | SV **svp; |
3472 | SV **svp; |
3446 | NV x, y, w, h; |
3473 | NV x, y, w, h; |
3447 | SV *draw_x_sv = GvSV (draw_x_gv); |
3474 | SV *draw_x_sv = GvSV (draw_x_gv); |
3448 | SV *draw_y_sv = GvSV (draw_y_gv); |
3475 | SV *draw_y_sv = GvSV (draw_y_gv); |
3449 | SV *draw_w_sv = GvSV (draw_w_gv); |
3476 | SV *draw_w_sv = GvSV (draw_w_gv); |
3450 | SV *draw_h_sv = GvSV (draw_h_gv); |
3477 | SV *draw_h_sv = GvSV (draw_h_gv); |