… | |
… | |
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 | |
… | |
… | |
1021 | |
1027 | |
1022 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1028 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
1023 | } |
1029 | } |
1024 | } |
1030 | } |
1025 | |
1031 | |
|
|
1032 | char * |
|
|
1033 | SDL_AudioDriverName () |
|
|
1034 | CODE: |
|
|
1035 | { |
|
|
1036 | char buf [256]; |
|
|
1037 | if (!SDL_AudioDriverName (buf, sizeof (buf))) |
|
|
1038 | XSRETURN_UNDEF; |
|
|
1039 | |
|
|
1040 | RETVAL = buf; |
|
|
1041 | } |
|
|
1042 | OUTPUT: |
|
|
1043 | RETVAL |
|
|
1044 | |
1026 | int |
1045 | int |
1027 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1046 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1028 | POSTCALL: |
1047 | POSTCALL: |
1029 | Mix_HookMusicFinished (music_finished); |
1048 | Mix_HookMusicFinished (music_finished); |
1030 | Mix_ChannelFinished (channel_finished); |
1049 | Mix_ChannelFinished (channel_finished); |
… | |
… | |
1092 | add_font (char *file) |
1111 | add_font (char *file) |
1093 | CODE: |
1112 | CODE: |
1094 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1113 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1095 | OUTPUT: |
1114 | OUTPUT: |
1096 | RETVAL |
1115 | RETVAL |
|
|
1116 | |
|
|
1117 | void |
|
|
1118 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
1097 | |
1119 | |
1098 | void |
1120 | void |
1099 | load_image_inline (SV *image_) |
1121 | load_image_inline (SV *image_) |
1100 | ALIAS: |
1122 | ALIAS: |
1101 | load_image_file = 1 |
1123 | load_image_file = 1 |
… | |
… | |
1665 | glDisable (GL_BLEND); |
1687 | glDisable (GL_BLEND); |
1666 | } |
1688 | } |
1667 | } |
1689 | } |
1668 | |
1690 | |
1669 | void |
1691 | 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) |
1692 | 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: @ |
1693 | PROTOTYPE: @ |
1672 | CODE: |
1694 | CODE: |
1673 | { |
1695 | { |
|
|
1696 | glEnable (GL_BLEND); |
|
|
1697 | glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1674 | glEnable (GL_TEXTURE_2D); |
1698 | glEnable (GL_TEXTURE_2D); |
1675 | glEnable (GL_BLEND); |
|
|
1676 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1677 | glBindTexture (GL_TEXTURE_2D, name1); |
1699 | glBindTexture (GL_TEXTURE_2D, name1); |
1678 | |
1700 | |
1679 | glColor3f (intensity, intensity, intensity); |
1701 | glColor3f (intensity, intensity, intensity); |
1680 | glPushMatrix (); |
1702 | glPushMatrix (); |
1681 | glScalef (1./3, 1./3, 1.); |
1703 | glScalef (1./3, 1./3, 1.); |
1682 | |
1704 | |
1683 | if (blend > 0.f) |
1705 | if (blend > 0.f) |
1684 | { |
1706 | { |
1685 | float S2, T2; /* 0. 0. for texture 2 */ |
1707 | float dx3 = dx * -3.f / w; |
1686 | float w = w1 > w2 ? w1 : w2; |
1708 | float dy3 = dy * -3.f / h; |
1687 | float h = h1 > h2 ? h1 : h2; |
|
|
1688 | GLfloat env_color[4] = { 0., 0., 0., blend }; |
1709 | GLfloat env_color[4] = { 0., 0., 0., blend }; |
1689 | |
1710 | |
1690 | /* interpolate the two shadow textures */ |
1711 | /* interpolate the two shadow textures */ |
1691 | /* stage 0 == rgb(glcolor) + alpha(t0) */ |
1712 | /* stage 0 == rgb(glcolor) + alpha(t0) */ |
1692 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1713 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
… | |
… | |
1697 | glBindTexture (GL_TEXTURE_2D, name2); |
1718 | glBindTexture (GL_TEXTURE_2D, name2); |
1698 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1719 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
1699 | |
1720 | |
1700 | /* rgb == rgb(glcolor) */ |
1721 | /* rgb == rgb(glcolor) */ |
1701 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1722 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
1702 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); |
1723 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); |
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1724 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
1704 | |
1725 | |
1705 | /* alpha = interpolate t0, t1 by env_alpha */ |
1726 | /* alpha = interpolate t0, t1 by env_alpha */ |
1706 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1727 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
1707 | |
1728 | |
… | |
… | |
1713 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
1734 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
1714 | |
1735 | |
1715 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); |
1736 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); |
1716 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); |
1737 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); |
1717 | |
1738 | |
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); |
1739 | glBegin (GL_QUADS); |
1730 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx , dy ); glVertex2f ( 0, 0); |
1740 | 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); |
1741 | 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); |
1742 | 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); |
1743 | gl.MultiTexCoord2f (GL_TEXTURE0, s, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 + s, dy3 ); glVertex2i (w, 0); |
1734 | glEnd (); |
1744 | glEnd (); |
1735 | |
1745 | |
1736 | glDisable (GL_TEXTURE_2D); |
1746 | glDisable (GL_TEXTURE_2D); |
1737 | gl.ActiveTexture (GL_TEXTURE0); |
1747 | gl.ActiveTexture (GL_TEXTURE0); |
1738 | } |
1748 | } |
… | |
… | |
1740 | { |
1750 | { |
1741 | /* simple blending of one texture, also opengl <1.3 path */ |
1751 | /* simple blending of one texture, also opengl <1.3 path */ |
1742 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1752 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1743 | |
1753 | |
1744 | glBegin (GL_QUADS); |
1754 | glBegin (GL_QUADS); |
1745 | glTexCoord2f ( 0, 0); glVertex2f ( 0, 0); |
1755 | glTexCoord2f (0, 0); glVertex2f (0, 0); |
1746 | glTexCoord2f ( 0, t1); glVertex2f ( 0, h1); |
1756 | glTexCoord2f (0, t); glVertex2f (0, h); |
1747 | glTexCoord2f (s1, t1); glVertex2f (w1, h1); |
1757 | glTexCoord2f (s, t); glVertex2f (w, h); |
1748 | glTexCoord2f (s1, 0); glVertex2f (w1, 0); |
1758 | glTexCoord2f (s, 0); glVertex2f (w, 0); |
1749 | glEnd (); |
1759 | glEnd (); |
1750 | } |
1760 | } |
|
|
1761 | |
|
|
1762 | /* draw ?-marks or equivalent, this is very clumsy code :/ */ |
|
|
1763 | { |
|
|
1764 | int x, y; |
|
|
1765 | int dx3 = dx * 3; |
|
|
1766 | int dy3 = dy * 3; |
|
|
1767 | |
|
|
1768 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1769 | glBindTexture (GL_TEXTURE_2D, hidden_tex); |
|
|
1770 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1771 | glTranslatef (-1., -1., 0); |
|
|
1772 | glBegin (GL_QUADS); |
|
|
1773 | |
|
|
1774 | for (y = 1; y < h; y += 3) |
|
|
1775 | { |
|
|
1776 | int y1 = y - dy3; |
|
|
1777 | int y1valid = y1 >= 0 && y1 < h; |
|
|
1778 | |
|
|
1779 | for (x = 1; x < w; x += 3) |
|
|
1780 | { |
|
|
1781 | int x1 = x - dx3; |
|
|
1782 | uint8_t h1 = data1 [x + y * w] == DARKNESS_ADJUST (255 - FOW_DARKNESS); |
|
|
1783 | uint8_t h2; |
|
|
1784 | |
|
|
1785 | if (y1valid && x1 >= 0 && x1 < w) |
|
|
1786 | h2 = data2 [x1 + y1 * w] == DARKNESS_ADJUST (255 - FOW_DARKNESS); |
|
|
1787 | else |
|
|
1788 | h2 = 1; /* out of range == invisible */ |
|
|
1789 | |
|
|
1790 | if (h1 || h2) |
|
|
1791 | { |
|
|
1792 | float alpha = h1 == h2 ? 1.f : h1 ? 1.f - blend : blend; |
|
|
1793 | glColor4f (1., 1., 1., alpha); |
|
|
1794 | |
|
|
1795 | glTexCoord2f (0, 0.); glVertex2i (x , y ); |
|
|
1796 | glTexCoord2f (0, 1.); glVertex2i (x , y + 3); |
|
|
1797 | glTexCoord2f (1, 1.); glVertex2i (x + 3, y + 3); |
|
|
1798 | glTexCoord2f (1, 0.); glVertex2i (x + 3, y ); |
|
|
1799 | } |
|
|
1800 | } |
|
|
1801 | } |
|
|
1802 | } |
|
|
1803 | |
|
|
1804 | glEnd (); |
1751 | |
1805 | |
1752 | glPopMatrix (); |
1806 | glPopMatrix (); |
1753 | |
1807 | |
1754 | glDisable (GL_TEXTURE_2D); |
1808 | glDisable (GL_TEXTURE_2D); |
1755 | glDisable (GL_BLEND); |
1809 | glDisable (GL_BLEND); |
… | |
… | |
1976 | { |
2030 | { |
1977 | ext = *data++; |
2031 | ext = *data++; |
1978 | cmd = ext & 0x7f; |
2032 | cmd = ext & 0x7f; |
1979 | |
2033 | |
1980 | if (cmd < 4) |
2034 | if (cmd < 4) |
1981 | cell->darkness = 255 - ext * 64 + 1; |
2035 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
1982 | else if (cmd == 5) // health |
2036 | else if (cmd == 5) // health |
1983 | { |
2037 | { |
1984 | cell->stat_width = 1; |
2038 | cell->stat_width = 1; |
1985 | cell->stat_hp = *data++; |
2039 | cell->stat_hp = *data++; |
1986 | } |
2040 | } |
… | |
… | |
2107 | int pl_x, pl_y; |
2161 | int pl_x, pl_y; |
2108 | maptex pl_tex; |
2162 | maptex pl_tex; |
2109 | rc_t *rc = rc_alloc (); |
2163 | rc_t *rc = rc_alloc (); |
2110 | rc_t *rc_ov = rc_alloc (); |
2164 | rc_t *rc_ov = rc_alloc (); |
2111 | rc_key_t key; |
2165 | rc_key_t key; |
2112 | rc_array_t *arr, *arr_hidden; |
2166 | rc_array_t *arr; |
2113 | |
2167 | |
2114 | pl_tex.name = 0; |
2168 | pl_tex.name = 0; |
2115 | |
2169 | |
2116 | // that's current max. sorry. |
2170 | // that's current max. sorry. |
2117 | if (sw > 255) sw = 255; |
2171 | if (sw > 255) sw = 255; |
… | |
… | |
2154 | } |
2208 | } |
2155 | |
2209 | |
2156 | glEnable (GL_BLEND); |
2210 | glEnable (GL_BLEND); |
2157 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2211 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2158 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2212 | 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 | |
2213 | |
2163 | for (z = 0; z <= 2; z++) |
2214 | for (z = 0; z <= 2; z++) |
2164 | { |
2215 | { |
2165 | memset (smooth_level, 0, sizeof (smooth_level)); |
2216 | memset (smooth_level, 0, sizeof (smooth_level)); |
2166 | key.texname = -1; |
2217 | key.texname = -1; |
… | |
… | |
2246 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2297 | 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); |
2298 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2248 | } |
2299 | } |
2249 | } |
2300 | } |
2250 | |
2301 | |
2251 | if (expect_false (z == 2)) |
2302 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2252 | { |
2303 | { |
2253 | /* draw question marks on top of hidden spaces */ |
2304 | // overlays such as the speech bubble, probably more to come |
2254 | if (!cell->darkness) |
2305 | if (cell->flags & 1) |
2255 | { |
2306 | { |
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; |
2307 | rc_key_t key_ov = key; |
2272 | maptex tex = self->tex [TEXID_SPEECH]; |
2308 | maptex tex = self->tex [TEXID_SPEECH]; |
2273 | rc_array_t *arr; |
2309 | rc_array_t *arr; |
2274 | int px = x * T + T * 2 / 32; |
2310 | int px = x * T + T * 2 / 32; |
2275 | int py = y * T - T * 6 / 32; |
2311 | int py = y * T - T * 6 / 32; |
2276 | |
2312 | |
2277 | key_ov.texname = tex.name; |
2313 | key_ov.texname = tex.name; |
2278 | arr = rc_array (rc_ov, &key_ov); |
2314 | arr = rc_array (rc_ov, &key_ov); |
2279 | |
2315 | |
2280 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2316 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2281 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
2317 | 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); |
2318 | 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); |
2319 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
2284 | } |
|
|
2285 | } |
2320 | } |
2286 | } |
2321 | } |
2287 | } |
2322 | } |
2288 | } |
2323 | } |
2289 | |
2324 | |
… | |
… | |
2463 | int x, y; |
2498 | int x, y; |
2464 | |
2499 | |
2465 | glEnable (GL_TEXTURE_2D); |
2500 | glEnable (GL_TEXTURE_2D); |
2466 | /* GL_REPLACE would be correct, as we don't need to modulate alpha, |
2501 | /* GL_REPLACE would be correct, as we don't need to modulate alpha, |
2467 | * but the nvidia driver (185.18.14) mishandles alpha textures |
2502 | * but the nvidia driver (185.18.14) mishandles alpha textures |
2468 | * ansd takes the colour from god knows where instead of using |
2503 | * and takes the colour from god knows where instead of using |
2469 | * Cp. MODULATE results in the same colour, but slightly different |
2504 | * Cp. MODULATE results in the same colour, but slightly different |
2470 | * alpha, but atcually gives us the correct colour with nvidia. |
2505 | * alpha, but atcually gives us the correct colour with nvidia. |
2471 | */ |
2506 | */ |
2472 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
2507 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
2473 | glEnable (GL_BLEND); |
2508 | glEnable (GL_BLEND); |
… | |
… | |
2502 | void |
2537 | void |
2503 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2538 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2504 | PPCODE: |
2539 | PPCODE: |
2505 | { |
2540 | { |
2506 | int x, y; |
2541 | int x, y; |
2507 | int sw1 = sw + 2; |
2542 | int sw1 = sw + 2; |
2508 | int sh1 = sh + 2; |
2543 | int sh1 = sh + 2; |
2509 | int sh3 = sh * 3; |
2544 | int sh3 = sh * 3; |
2510 | int sw34 = (sw * 3 + 3) & ~3; |
2545 | int sw3 = sw * 3; |
2511 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
2546 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
2512 | SV *darkness3_sv = sv_2mortal (newSV (sw34 * sh3)); |
2547 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2513 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2548 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2514 | |
2549 | |
2515 | SvPOK_only (darkness3_sv); |
2550 | SvPOK_only (darkness3_sv); |
2516 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2551 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2517 | |
2552 | |
2518 | mx += self->x - 1; |
2553 | mx += self->x - 1; |
2519 | my += self->y - 1; |
2554 | my += self->y - 1; |
2520 | |
|
|
2521 | memset (darkness1, DARKNESS_ADJUST (255 - FOW_DARKNESS), sw1 * sh1); |
|
|
2522 | |
2555 | |
2523 | for (y = 0; y < sh1; y++) |
2556 | for (y = 0; y < sh1; y++) |
2524 | if (0 <= y + my && y + my < self->rows) |
2557 | if (0 <= y + my && y + my < self->rows) |
2525 | { |
2558 | { |
2526 | maprow *row = self->row + (y + my); |
2559 | maprow *row = self->row + (y + my); |
… | |
… | |
2559 | |
2592 | |
2560 | uint8_t r13 = (d13 + d23 + d12) / 3; |
2593 | uint8_t r13 = (d13 + d23 + d12) / 3; |
2561 | uint8_t r23 = d23; |
2594 | uint8_t r23 = d23; |
2562 | uint8_t r33 = (d23 + d33 + d32) / 3; |
2595 | uint8_t r33 = (d23 + d33 + d32) / 3; |
2563 | |
2596 | |
2564 | darkness3 [(y * 3 ) * sw34 + (x * 3 )] = MAX (d22, r11); |
2597 | darkness3 [(y * 3 ) * sw3 + (x * 3 )] = MAX (d22, r11); |
2565 | darkness3 [(y * 3 ) * sw34 + (x * 3 + 1)] = MAX (d22, r21); |
2598 | darkness3 [(y * 3 ) * sw3 + (x * 3 + 1)] = MAX (d22, r21); |
2566 | darkness3 [(y * 3 ) * sw34 + (x * 3 + 2)] = MAX (d22, r31); |
2599 | darkness3 [(y * 3 ) * sw3 + (x * 3 + 2)] = MAX (d22, r31); |
2567 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 )] = MAX (d22, r12); |
2600 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 )] = MAX (d22, r12); |
2568 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 + 1)] = MAX (d22, r22); |
2601 | 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); |
2602 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 + 2)] = MAX (d22, r32); |
2570 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 )] = MAX (d22, r13); |
2603 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 )] = MAX (d22, r13); |
2571 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 + 1)] = MAX (d22, r23); |
2604 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 + 1)] = MAX (d22, r23); |
2572 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 + 2)] = MAX (d22, r33); |
2605 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 + 2)] = MAX (d22, r33); |
2573 | } |
2606 | } |
2574 | |
2607 | |
2575 | free (darkness1); |
2608 | free (darkness1); |
2576 | |
2609 | |
2577 | EXTEND (SP, 3); |
2610 | EXTEND (SP, 3); |
2578 | PUSHs (sv_2mortal (newSViv (sw34))); |
2611 | PUSHs (sv_2mortal (newSViv (sw3))); |
2579 | PUSHs (sv_2mortal (newSViv (sh3))); |
2612 | PUSHs (sv_2mortal (newSViv (sh3))); |
2580 | PUSHs (darkness3_sv); |
2613 | PUSHs (darkness3_sv); |
2581 | } |
2614 | } |
2582 | |
2615 | |
2583 | SV * |
2616 | SV * |
… | |
… | |
2781 | if (RETVAL < 0) |
2814 | if (RETVAL < 0) |
2782 | { |
2815 | { |
2783 | RETVAL = Mix_GroupOldest (-1); |
2816 | RETVAL = Mix_GroupOldest (-1); |
2784 | |
2817 | |
2785 | if (RETVAL < 0) |
2818 | if (RETVAL < 0) |
|
|
2819 | { |
|
|
2820 | // happens sometimes, maybe it just stopped playing(?) |
|
|
2821 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2822 | |
|
|
2823 | if (RETVAL < 0) |
2786 | XSRETURN_UNDEF; |
2824 | XSRETURN_UNDEF; |
2787 | |
2825 | } |
|
|
2826 | else |
2788 | Mix_HaltChannel (RETVAL); |
2827 | Mix_HaltChannel (RETVAL); |
2789 | } |
2828 | } |
2790 | |
2829 | |
2791 | Mix_UnregisterAllEffects (RETVAL); |
2830 | Mix_UnregisterAllEffects (RETVAL); |
2792 | Mix_Volume (RETVAL, 128); |
2831 | Mix_Volume (RETVAL, 128); |
2793 | } |
2832 | } |
… | |
… | |
2852 | Mix_SetReverseStereo (self, flip); |
2891 | Mix_SetReverseStereo (self, flip); |
2853 | |
2892 | |
2854 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2893 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2855 | |
2894 | |
2856 | PROTOTYPES: DISABLE |
2895 | PROTOTYPES: DISABLE |
|
|
2896 | |
|
|
2897 | void |
|
|
2898 | decoders () |
|
|
2899 | PPCODE: |
|
|
2900 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2901 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2902 | EXTEND (SP, num); |
|
|
2903 | for (i = 0; i < num; ++i) |
|
|
2904 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2905 | #else |
|
|
2906 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2907 | #endif |
2857 | |
2908 | |
2858 | DC::MixChunk |
2909 | DC::MixChunk |
2859 | new (SV *class, DC::RW rwops) |
2910 | new (SV *class, DC::RW rwops) |
2860 | CODE: |
2911 | CODE: |
2861 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2912 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
… | |
… | |
2894 | OUTPUT: |
2945 | OUTPUT: |
2895 | RETVAL |
2946 | RETVAL |
2896 | |
2947 | |
2897 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2948 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2898 | |
2949 | |
|
|
2950 | void |
|
|
2951 | decoders () |
|
|
2952 | PPCODE: |
|
|
2953 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2954 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
2955 | EXTEND (SP, num); |
|
|
2956 | for (i = 0; i < num; ++i) |
|
|
2957 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
2958 | #else |
|
|
2959 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2960 | #endif |
|
|
2961 | |
2899 | int |
2962 | int |
2900 | volume (int volume = -1) |
2963 | volume (int volume = -1) |
2901 | PROTOTYPE: ;$ |
2964 | PROTOTYPE: ;$ |
2902 | CODE: |
2965 | CODE: |
2903 | if (items > 0) |
2966 | if (items > 0) |
… | |
… | |
2913 | |
2976 | |
2914 | void |
2977 | void |
2915 | halt () |
2978 | halt () |
2916 | CODE: |
2979 | CODE: |
2917 | Mix_HaltMusic (); |
2980 | Mix_HaltMusic (); |
|
|
2981 | |
|
|
2982 | int |
|
|
2983 | playing () |
|
|
2984 | CODE: |
|
|
2985 | RETVAL = Mix_PlayingMusic (); |
|
|
2986 | OUTPUT: |
|
|
2987 | RETVAL |
2918 | |
2988 | |
2919 | DC::MixMusic |
2989 | DC::MixMusic |
2920 | new (SV *class, DC::RW rwops) |
2990 | new (SV *class, DC::RW rwops) |
2921 | CODE: |
2991 | CODE: |
2922 | RETVAL = Mix_LoadMUS_RW (rwops); |
2992 | RETVAL = Mix_LoadMUS_RW (rwops); |
… | |
… | |
3117 | |
3187 | |
3118 | int glGetError () |
3188 | int glGetError () |
3119 | |
3189 | |
3120 | void glFinish () |
3190 | void glFinish () |
3121 | |
3191 | |
|
|
3192 | void glFlush () |
|
|
3193 | |
3122 | void glClear (int mask) |
3194 | void glClear (int mask) |
3123 | |
3195 | |
3124 | void glClearColor (float r, float g, float b, float a = 1.0) |
3196 | void glClearColor (float r, float g, float b, float a = 1.0) |
3125 | PROTOTYPE: @ |
3197 | PROTOTYPE: @ |
3126 | |
3198 | |
… | |
… | |
3296 | void glNewList (int list, int mode = GL_COMPILE) |
3368 | void glNewList (int list, int mode = GL_COMPILE) |
3297 | |
3369 | |
3298 | void glEndList () |
3370 | void glEndList () |
3299 | |
3371 | |
3300 | void glCallList (int list) |
3372 | void glCallList (int list) |
|
|
3373 | |
|
|
3374 | void c_init () |
|
|
3375 | CODE: |
|
|
3376 | glPixelStorei (GL_PACK_ALIGNMENT , 1); |
|
|
3377 | glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
3301 | |
3378 | |
3302 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
3379 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
3303 | |
3380 | |
3304 | PROTOTYPES: DISABLE |
3381 | PROTOTYPES: DISABLE |
3305 | |
3382 | |