… | |
… | |
41 | #include <SDL_opengl.h> |
41 | #include <SDL_opengl.h> |
42 | |
42 | |
43 | /* work around os x broken headers */ |
43 | /* work around os x broken headers */ |
44 | #ifdef __MACOSX__ |
44 | #ifdef __MACOSX__ |
45 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); |
45 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); |
|
|
46 | typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); |
|
|
47 | typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); |
46 | #endif |
48 | #endif |
47 | |
49 | |
48 | #define PANGO_ENABLE_BACKEND |
50 | #define PANGO_ENABLE_BACKEND |
49 | #define G_DISABLE_CAST_CHECKS |
51 | #define G_DISABLE_CAST_CHECKS |
50 | |
52 | |
… | |
… | |
80 | #define expect_false(expr) expect ((expr) != 0, 0) |
82 | #define expect_false(expr) expect ((expr) != 0, 0) |
81 | #define expect_true(expr) expect ((expr) != 0, 1) |
83 | #define expect_true(expr) expect ((expr) != 0, 1) |
82 | |
84 | |
83 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
85 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
84 | |
86 | |
|
|
87 | /* this is used as fow flag as well, so has to have a different value */ |
|
|
88 | /* then anything that is computed by incoming darkness */ |
85 | #define FOW_DARKNESS 64 |
89 | #define FOW_DARKNESS 50 |
86 | #define DARKNESS_ADJUST(n) ((29 * (int)(n)) >> 5) /* times 0.9 */ |
90 | #define DARKNESS_ADJUST(n) (n) |
87 | |
91 | |
88 | #define MAP_EXTEND_X 32 |
92 | #define MAP_EXTEND_X 32 |
89 | #define MAP_EXTEND_Y 512 |
93 | #define MAP_EXTEND_Y 512 |
90 | |
94 | |
91 | #define MIN_FONT_HEIGHT 10 |
95 | #define MIN_FONT_HEIGHT 10 |
… | |
… | |
95 | |
99 | |
96 | #define KMOD_LRAM 0x10000 // our extension |
100 | #define KMOD_LRAM 0x10000 // our extension |
97 | |
101 | |
98 | #define TEXID_SPEECH 1 |
102 | #define TEXID_SPEECH 1 |
99 | #define TEXID_NOFACE 2 |
103 | #define TEXID_NOFACE 2 |
100 | #define TEXID_HIDDEN 3 |
|
|
101 | |
104 | |
102 | static AV *texture_av; |
105 | static AV *texture_av; |
103 | |
106 | |
104 | static struct |
107 | static struct |
105 | { |
108 | { |
… | |
… | |
927 | |
930 | |
928 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
931 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
929 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
932 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
930 | #include "glfunc.h" |
933 | #include "glfunc.h" |
931 | #undef GL_FUNC |
934 | #undef GL_FUNC |
|
|
935 | |
|
|
936 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
|
|
937 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
932 | } |
938 | } |
933 | } |
939 | } |
934 | OUTPUT: |
940 | OUTPUT: |
935 | RETVAL |
941 | RETVAL |
936 | |
942 | |
… | |
… | |
1665 | glDisable (GL_BLEND); |
1671 | glDisable (GL_BLEND); |
1666 | } |
1672 | } |
1667 | } |
1673 | } |
1668 | |
1674 | |
1669 | void |
1675 | void |
1670 | draw_fow_texture (float intensity, int name1, float s1, float t1, float w1, float h1, float blend = 0.f, float dx = 0.f, float dy = 0.f, int name2 = 0, float s2 = 0.f, float t2 = 0.f, float w2 = 0.f, float h2 = 0.f) |
1676 | draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) |
1671 | PROTOTYPE: @ |
1677 | PROTOTYPE: @ |
1672 | CODE: |
1678 | CODE: |
1673 | { |
1679 | { |
|
|
1680 | glEnable (GL_BLEND); |
|
|
1681 | glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1674 | glEnable (GL_TEXTURE_2D); |
1682 | glEnable (GL_TEXTURE_2D); |
1675 | glEnable (GL_BLEND); |
|
|
1676 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1677 | glBindTexture (GL_TEXTURE_2D, name1); |
1683 | glBindTexture (GL_TEXTURE_2D, name1); |
1678 | |
1684 | |
1679 | glColor3f (intensity, intensity, intensity); |
1685 | glColor3f (intensity, intensity, intensity); |
1680 | glPushMatrix (); |
1686 | glPushMatrix (); |
1681 | glScalef (1./3, 1./3, 1.); |
1687 | glScalef (1./3, 1./3, 1.); |
1682 | |
1688 | |
1683 | if (blend > 0.f) |
1689 | if (blend > 0.f) |
1684 | { |
1690 | { |
1685 | float S2, T2; /* 0. 0. for texture 2 */ |
1691 | float dx3 = dx * -3.f / w; |
1686 | float w = w1 > w2 ? w1 : w2; |
1692 | float dy3 = dy * -3.f / h; |
1687 | float h = h1 > h2 ? h1 : h2; |
|
|
1688 | GLfloat env_color[4] = { 0., 0., 0., blend }; |
1693 | GLfloat env_color[4] = { 0., 0., 0., blend }; |
1689 | |
1694 | |
1690 | /* interpolate the two shadow textures */ |
1695 | /* interpolate the two shadow textures */ |
1691 | /* stage 0 == rgb(glcolor) + alpha(t0) */ |
1696 | /* stage 0 == rgb(glcolor) + alpha(t0) */ |
1692 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1697 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
… | |
… | |
1697 | glBindTexture (GL_TEXTURE_2D, name2); |
1702 | glBindTexture (GL_TEXTURE_2D, name2); |
1698 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1699 | |
1704 | |
1700 | /* rgb == rgb(glcolor) */ |
1705 | /* rgb == rgb(glcolor) */ |
1701 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1706 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1702 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); |
1707 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); |
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1708 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1704 | |
1709 | |
1705 | /* alpha = interpolate t0, t1 by env_alpha */ |
1710 | /* alpha = interpolate t0, t1 by env_alpha */ |
1706 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1711 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1707 | |
1712 | |
… | |
… | |
1713 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
1718 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
1714 | |
1719 | |
1715 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); |
1720 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); |
1716 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); |
1721 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); |
1717 | |
1722 | |
1718 | s1 *= w / w1; |
|
|
1719 | t1 *= h / h1; |
|
|
1720 | |
|
|
1721 | dx *= -3.f / w2; |
|
|
1722 | dy *= -3.f / h2; |
|
|
1723 | dx *= w / w2; |
|
|
1724 | dy *= h / h2; |
|
|
1725 | |
|
|
1726 | s2 *= w / w2; |
|
|
1727 | t2 *= h / h2; |
|
|
1728 | |
|
|
1729 | glBegin (GL_QUADS); |
1723 | glBegin (GL_QUADS); |
1730 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx , dy ); glVertex2f ( 0, 0); |
1724 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 , dy3 ); glVertex2i (0, 0); |
1731 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, t1); gl.MultiTexCoord2f (GL_TEXTURE1, dx , dy + t2); glVertex2f ( 0, h1); |
1725 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, t); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 , dy3 + t); glVertex2i (0, h); |
1732 | gl.MultiTexCoord2f (GL_TEXTURE0, s1, t1); gl.MultiTexCoord2f (GL_TEXTURE1, dx + s2, dy + t2); glVertex2f (w1, h1); |
1726 | gl.MultiTexCoord2f (GL_TEXTURE0, s, t); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 + s, dy3 + t); glVertex2i (w, h); |
1733 | gl.MultiTexCoord2f (GL_TEXTURE0, s1, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx + s2, dy ); glVertex2f (w1, 0); |
1727 | gl.MultiTexCoord2f (GL_TEXTURE0, s, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 + s, dy3 ); glVertex2i (w, 0); |
1734 | glEnd (); |
1728 | glEnd (); |
1735 | |
1729 | |
1736 | glDisable (GL_TEXTURE_2D); |
1730 | glDisable (GL_TEXTURE_2D); |
1737 | gl.ActiveTexture (GL_TEXTURE0); |
1731 | gl.ActiveTexture (GL_TEXTURE0); |
1738 | } |
1732 | } |
… | |
… | |
1740 | { |
1734 | { |
1741 | /* simple blending of one texture, also opengl <1.3 path */ |
1735 | /* simple blending of one texture, also opengl <1.3 path */ |
1742 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1736 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1743 | |
1737 | |
1744 | glBegin (GL_QUADS); |
1738 | glBegin (GL_QUADS); |
1745 | glTexCoord2f ( 0, 0); glVertex2f ( 0, 0); |
1739 | glTexCoord2f (0, 0); glVertex2f (0, 0); |
1746 | glTexCoord2f ( 0, t1); glVertex2f ( 0, h1); |
1740 | glTexCoord2f (0, t); glVertex2f (0, h); |
1747 | glTexCoord2f (s1, t1); glVertex2f (w1, h1); |
1741 | glTexCoord2f (s, t); glVertex2f (w, h); |
1748 | glTexCoord2f (s1, 0); glVertex2f (w1, 0); |
1742 | glTexCoord2f (s, 0); glVertex2f (w, 0); |
1749 | glEnd (); |
1743 | glEnd (); |
1750 | } |
1744 | } |
|
|
1745 | |
|
|
1746 | /* draw ?-marks or equivalent, this is very clumsy code :/ */ |
|
|
1747 | { |
|
|
1748 | int x, y; |
|
|
1749 | int dx3 = dx * 3; |
|
|
1750 | int dy3 = dy * 3; |
|
|
1751 | |
|
|
1752 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1753 | glBindTexture (GL_TEXTURE_2D, hidden_tex); |
|
|
1754 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1755 | glTranslatef (-1., -1., 0); |
|
|
1756 | glBegin (GL_QUADS); |
|
|
1757 | |
|
|
1758 | for (y = 1; y < h; y += 3) |
|
|
1759 | { |
|
|
1760 | int y1 = y - dy3; |
|
|
1761 | int y1valid = y1 >= 0 && y1 < h; |
|
|
1762 | |
|
|
1763 | for (x = 1; x < w; x += 3) |
|
|
1764 | { |
|
|
1765 | int x1 = x - dx3; |
|
|
1766 | uint8_t h1 = data1 [x + y * w] == DARKNESS_ADJUST (255 - FOW_DARKNESS); |
|
|
1767 | uint8_t h2; |
|
|
1768 | |
|
|
1769 | if (y1valid && x1 >= 0 && x1 < w) |
|
|
1770 | h2 = data2 [x1 + y1 * w] == DARKNESS_ADJUST (255 - FOW_DARKNESS); |
|
|
1771 | else |
|
|
1772 | h2 = 1; /* out of range == invisible */ |
|
|
1773 | |
|
|
1774 | if (h1 || h2) |
|
|
1775 | { |
|
|
1776 | float alpha = h1 == h2 ? 1.f : h1 ? 1.f - blend : blend; |
|
|
1777 | glColor4f (1., 1., 1., alpha); |
|
|
1778 | |
|
|
1779 | glTexCoord2f (0, 0.); glVertex2i (x , y ); |
|
|
1780 | glTexCoord2f (0, 1.); glVertex2i (x , y + 3); |
|
|
1781 | glTexCoord2f (1, 1.); glVertex2i (x + 3, y + 3); |
|
|
1782 | glTexCoord2f (1, 0.); glVertex2i (x + 3, y ); |
|
|
1783 | } |
|
|
1784 | } |
|
|
1785 | } |
|
|
1786 | } |
|
|
1787 | |
|
|
1788 | glEnd (); |
1751 | |
1789 | |
1752 | glPopMatrix (); |
1790 | glPopMatrix (); |
1753 | |
1791 | |
1754 | glDisable (GL_TEXTURE_2D); |
1792 | glDisable (GL_TEXTURE_2D); |
1755 | glDisable (GL_BLEND); |
1793 | glDisable (GL_BLEND); |
… | |
… | |
1976 | { |
2014 | { |
1977 | ext = *data++; |
2015 | ext = *data++; |
1978 | cmd = ext & 0x7f; |
2016 | cmd = ext & 0x7f; |
1979 | |
2017 | |
1980 | if (cmd < 4) |
2018 | if (cmd < 4) |
1981 | cell->darkness = 255 - ext * 64 + 1; |
2019 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
1982 | else if (cmd == 5) // health |
2020 | else if (cmd == 5) // health |
1983 | { |
2021 | { |
1984 | cell->stat_width = 1; |
2022 | cell->stat_width = 1; |
1985 | cell->stat_hp = *data++; |
2023 | cell->stat_hp = *data++; |
1986 | } |
2024 | } |
… | |
… | |
2107 | int pl_x, pl_y; |
2145 | int pl_x, pl_y; |
2108 | maptex pl_tex; |
2146 | maptex pl_tex; |
2109 | rc_t *rc = rc_alloc (); |
2147 | rc_t *rc = rc_alloc (); |
2110 | rc_t *rc_ov = rc_alloc (); |
2148 | rc_t *rc_ov = rc_alloc (); |
2111 | rc_key_t key; |
2149 | rc_key_t key; |
2112 | rc_array_t *arr, *arr_hidden; |
2150 | rc_array_t *arr; |
2113 | |
2151 | |
2114 | pl_tex.name = 0; |
2152 | pl_tex.name = 0; |
2115 | |
2153 | |
2116 | // that's current max. sorry. |
2154 | // that's current max. sorry. |
2117 | if (sw > 255) sw = 255; |
2155 | if (sw > 255) sw = 255; |
… | |
… | |
2154 | } |
2192 | } |
2155 | |
2193 | |
2156 | glEnable (GL_BLEND); |
2194 | glEnable (GL_BLEND); |
2157 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2195 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2158 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2196 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2159 | |
|
|
2160 | key.texname = self->tex [TEXID_HIDDEN].name; |
|
|
2161 | arr_hidden = rc_array (rc_ov, &key); |
|
|
2162 | |
2197 | |
2163 | for (z = 0; z <= 2; z++) |
2198 | for (z = 0; z <= 2; z++) |
2164 | { |
2199 | { |
2165 | memset (smooth_level, 0, sizeof (smooth_level)); |
2200 | memset (smooth_level, 0, sizeof (smooth_level)); |
2166 | key.texname = -1; |
2201 | key.texname = -1; |
… | |
… | |
2246 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2281 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2247 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2282 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2248 | } |
2283 | } |
2249 | } |
2284 | } |
2250 | |
2285 | |
2251 | if (expect_false (z == 2)) |
2286 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2252 | { |
2287 | { |
2253 | /* draw question marks on top of hidden spaces */ |
2288 | // overlays such as the speech bubble, probably more to come |
2254 | if (!cell->darkness) |
2289 | if (cell->flags & 1) |
2255 | { |
2290 | { |
2256 | maptex tex = self->tex [TEXID_HIDDEN]; |
|
|
2257 | int px = (x + 1) * T - tex.w; |
|
|
2258 | int py = (y + 1) * T - tex.h; |
|
|
2259 | |
|
|
2260 | rc_t2f_v3f (arr_hidden, 0 , 0 , px , py , 0); |
|
|
2261 | rc_t2f_v3f (arr_hidden, 0 , tex.t, px , py + tex.h, 0); |
|
|
2262 | rc_t2f_v3f (arr_hidden, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
|
|
2263 | rc_t2f_v3f (arr_hidden, tex.s, 0 , px + tex.w, py , 0); |
|
|
2264 | } |
|
|
2265 | |
|
|
2266 | if (expect_false (cell->flags)) |
|
|
2267 | { |
|
|
2268 | // overlays such as the speech bubble, probably more to come |
|
|
2269 | if (cell->flags & 1) |
|
|
2270 | { |
|
|
2271 | rc_key_t key_ov = key; |
2291 | rc_key_t key_ov = key; |
2272 | maptex tex = self->tex [TEXID_SPEECH]; |
2292 | maptex tex = self->tex [TEXID_SPEECH]; |
2273 | rc_array_t *arr; |
2293 | rc_array_t *arr; |
2274 | int px = x * T + T * 2 / 32; |
2294 | int px = x * T + T * 2 / 32; |
2275 | int py = y * T - T * 6 / 32; |
2295 | int py = y * T - T * 6 / 32; |
2276 | |
2296 | |
2277 | key_ov.texname = tex.name; |
2297 | key_ov.texname = tex.name; |
2278 | arr = rc_array (rc_ov, &key_ov); |
2298 | arr = rc_array (rc_ov, &key_ov); |
2279 | |
2299 | |
2280 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2300 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2281 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2301 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2282 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2302 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
2283 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2303 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2284 | } |
|
|
2285 | } |
2304 | } |
2286 | } |
2305 | } |
2287 | } |
2306 | } |
2288 | } |
2307 | } |
2289 | |
2308 | |
… | |
… | |
2463 | int x, y; |
2482 | int x, y; |
2464 | |
2483 | |
2465 | glEnable (GL_TEXTURE_2D); |
2484 | glEnable (GL_TEXTURE_2D); |
2466 | /* GL_REPLACE would be correct, as we don't need to modulate alpha, |
2485 | /* GL_REPLACE would be correct, as we don't need to modulate alpha, |
2467 | * but the nvidia driver (185.18.14) mishandles alpha textures |
2486 | * but the nvidia driver (185.18.14) mishandles alpha textures |
2468 | * ansd takes the colour from god knows where instead of using |
2487 | * and takes the colour from god knows where instead of using |
2469 | * Cp. MODULATE results in the same colour, but slightly different |
2488 | * Cp. MODULATE results in the same colour, but slightly different |
2470 | * alpha, but atcually gives us the correct colour with nvidia. |
2489 | * alpha, but atcually gives us the correct colour with nvidia. |
2471 | */ |
2490 | */ |
2472 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
2491 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
2473 | glEnable (GL_BLEND); |
2492 | glEnable (GL_BLEND); |
… | |
… | |
2502 | void |
2521 | void |
2503 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2522 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2504 | PPCODE: |
2523 | PPCODE: |
2505 | { |
2524 | { |
2506 | int x, y; |
2525 | int x, y; |
2507 | int sw1 = sw + 2; |
2526 | int sw1 = sw + 2; |
2508 | int sh1 = sh + 2; |
2527 | int sh1 = sh + 2; |
2509 | int sh3 = sh * 3; |
2528 | int sh3 = sh * 3; |
2510 | int sw34 = (sw * 3 + 3) & ~3; |
2529 | int sw3 = sw * 3; |
2511 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
2530 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
2512 | SV *darkness3_sv = sv_2mortal (newSV (sw34 * sh3)); |
2531 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2513 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2532 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2514 | |
2533 | |
2515 | SvPOK_only (darkness3_sv); |
2534 | SvPOK_only (darkness3_sv); |
2516 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2535 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2517 | |
2536 | |
2518 | mx += self->x - 1; |
2537 | mx += self->x - 1; |
2519 | my += self->y - 1; |
2538 | my += self->y - 1; |
2520 | |
|
|
2521 | memset (darkness1, DARKNESS_ADJUST (255 - FOW_DARKNESS), sw1 * sh1); |
|
|
2522 | |
2539 | |
2523 | for (y = 0; y < sh1; y++) |
2540 | for (y = 0; y < sh1; y++) |
2524 | if (0 <= y + my && y + my < self->rows) |
2541 | if (0 <= y + my && y + my < self->rows) |
2525 | { |
2542 | { |
2526 | maprow *row = self->row + (y + my); |
2543 | maprow *row = self->row + (y + my); |
… | |
… | |
2559 | |
2576 | |
2560 | uint8_t r13 = (d13 + d23 + d12) / 3; |
2577 | uint8_t r13 = (d13 + d23 + d12) / 3; |
2561 | uint8_t r23 = d23; |
2578 | uint8_t r23 = d23; |
2562 | uint8_t r33 = (d23 + d33 + d32) / 3; |
2579 | uint8_t r33 = (d23 + d33 + d32) / 3; |
2563 | |
2580 | |
2564 | darkness3 [(y * 3 ) * sw34 + (x * 3 )] = MAX (d22, r11); |
2581 | darkness3 [(y * 3 ) * sw3 + (x * 3 )] = MAX (d22, r11); |
2565 | darkness3 [(y * 3 ) * sw34 + (x * 3 + 1)] = MAX (d22, r21); |
2582 | darkness3 [(y * 3 ) * sw3 + (x * 3 + 1)] = MAX (d22, r21); |
2566 | darkness3 [(y * 3 ) * sw34 + (x * 3 + 2)] = MAX (d22, r31); |
2583 | darkness3 [(y * 3 ) * sw3 + (x * 3 + 2)] = MAX (d22, r31); |
2567 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 )] = MAX (d22, r12); |
2584 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 )] = MAX (d22, r12); |
2568 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 + 1)] = MAX (d22, r22); |
2585 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 + 1)] = MAX (d22, r22); /* this MUST be == d22 */ |
2569 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 + 2)] = MAX (d22, r32); |
2586 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 + 2)] = MAX (d22, r32); |
2570 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 )] = MAX (d22, r13); |
2587 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 )] = MAX (d22, r13); |
2571 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 + 1)] = MAX (d22, r23); |
2588 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 + 1)] = MAX (d22, r23); |
2572 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 + 2)] = MAX (d22, r33); |
2589 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 + 2)] = MAX (d22, r33); |
2573 | } |
2590 | } |
2574 | |
2591 | |
2575 | free (darkness1); |
2592 | free (darkness1); |
2576 | |
2593 | |
2577 | EXTEND (SP, 3); |
2594 | EXTEND (SP, 3); |
2578 | PUSHs (sv_2mortal (newSViv (sw34))); |
2595 | PUSHs (sv_2mortal (newSViv (sw3))); |
2579 | PUSHs (sv_2mortal (newSViv (sh3))); |
2596 | PUSHs (sv_2mortal (newSViv (sh3))); |
2580 | PUSHs (darkness3_sv); |
2597 | PUSHs (darkness3_sv); |
2581 | } |
2598 | } |
2582 | |
2599 | |
2583 | SV * |
2600 | SV * |
… | |
… | |
2853 | |
2870 | |
2854 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2871 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2855 | |
2872 | |
2856 | PROTOTYPES: DISABLE |
2873 | PROTOTYPES: DISABLE |
2857 | |
2874 | |
|
|
2875 | void |
|
|
2876 | decoders () |
|
|
2877 | PPCODE: |
|
|
2878 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2879 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2880 | EXTEND (SP, num); |
|
|
2881 | for (i = 0; i < num; ++i) |
|
|
2882 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2883 | #else |
|
|
2884 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2885 | #endif |
|
|
2886 | |
2858 | DC::MixChunk |
2887 | DC::MixChunk |
2859 | new (SV *class, DC::RW rwops) |
2888 | new (SV *class, DC::RW rwops) |
2860 | CODE: |
2889 | CODE: |
2861 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2890 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2862 | OUTPUT: |
2891 | OUTPUT: |
… | |
… | |
2894 | OUTPUT: |
2923 | OUTPUT: |
2895 | RETVAL |
2924 | RETVAL |
2896 | |
2925 | |
2897 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2926 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2898 | |
2927 | |
|
|
2928 | void |
|
|
2929 | decoders () |
|
|
2930 | PPCODE: |
|
|
2931 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2932 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
2933 | EXTEND (SP, num); |
|
|
2934 | for (i = 0; i < num; ++i) |
|
|
2935 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
2936 | #else |
|
|
2937 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2938 | #endif |
|
|
2939 | |
2899 | int |
2940 | int |
2900 | volume (int volume = -1) |
2941 | volume (int volume = -1) |
2901 | PROTOTYPE: ;$ |
2942 | PROTOTYPE: ;$ |
2902 | CODE: |
2943 | CODE: |
2903 | if (items > 0) |
2944 | if (items > 0) |
… | |
… | |
2913 | |
2954 | |
2914 | void |
2955 | void |
2915 | halt () |
2956 | halt () |
2916 | CODE: |
2957 | CODE: |
2917 | Mix_HaltMusic (); |
2958 | Mix_HaltMusic (); |
|
|
2959 | |
|
|
2960 | int |
|
|
2961 | playing () |
|
|
2962 | CODE: |
|
|
2963 | RETVAL = Mix_PlayingMusic (); |
|
|
2964 | OUTPUT: |
|
|
2965 | RETVAL |
2918 | |
2966 | |
2919 | DC::MixMusic |
2967 | DC::MixMusic |
2920 | new (SV *class, DC::RW rwops) |
2968 | new (SV *class, DC::RW rwops) |
2921 | CODE: |
2969 | CODE: |
2922 | RETVAL = Mix_LoadMUS_RW (rwops); |
2970 | RETVAL = Mix_LoadMUS_RW (rwops); |
… | |
… | |
3297 | |
3345 | |
3298 | void glEndList () |
3346 | void glEndList () |
3299 | |
3347 | |
3300 | void glCallList (int list) |
3348 | void glCallList (int list) |
3301 | |
3349 | |
|
|
3350 | void c_init () |
|
|
3351 | CODE: |
|
|
3352 | glPixelStorei (GL_PACK_ALIGNMENT , 1); |
|
|
3353 | glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
|
|
3354 | |
3302 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
3355 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
3303 | |
3356 | |
3304 | PROTOTYPES: DISABLE |
3357 | PROTOTYPES: DISABLE |
3305 | |
3358 | |
3306 | void |
3359 | void |