… | |
… | |
81 | #define expect_false(expr) expect ((expr) != 0, 0) |
81 | #define expect_false(expr) expect ((expr) != 0, 0) |
82 | #define expect_true(expr) expect ((expr) != 0, 1) |
82 | #define expect_true(expr) expect ((expr) != 0, 1) |
83 | |
83 | |
84 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
84 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
85 | |
85 | |
86 | #define FOW_DARKNESS 32 |
86 | #define FOW_DARKNESS 64 |
|
|
87 | #define DARKNESS_ADJUST(n) ((29 * (int)(n)) >> 5) /* times 0.9 */ |
87 | |
88 | |
88 | #define MAP_EXTEND_X 32 |
89 | #define MAP_EXTEND_X 32 |
89 | #define MAP_EXTEND_Y 512 |
90 | #define MAP_EXTEND_Y 512 |
90 | |
91 | |
91 | #define MIN_FONT_HEIGHT 10 |
92 | #define MIN_FONT_HEIGHT 10 |
92 | |
93 | |
93 | /* mask out modifiers we are not interested in */ |
94 | /* mask out modifiers we are not interested in */ |
94 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
95 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
95 | |
96 | |
96 | #define KMOD_LRAM 0x10000 // our extension |
97 | #define KMOD_LRAM 0x10000 // our extension |
|
|
98 | |
|
|
99 | #define TEXID_SPEECH 1 |
|
|
100 | #define TEXID_NOFACE 2 |
|
|
101 | #define TEXID_HIDDEN 3 |
97 | |
102 | |
98 | static AV *texture_av; |
103 | static AV *texture_av; |
99 | |
104 | |
100 | static struct |
105 | static struct |
101 | { |
106 | { |
… | |
… | |
1654 | glDisable (GL_ALPHA_TEST); |
1659 | glDisable (GL_ALPHA_TEST); |
1655 | glDisable (GL_BLEND); |
1660 | glDisable (GL_BLEND); |
1656 | } |
1661 | } |
1657 | } |
1662 | } |
1658 | |
1663 | |
|
|
1664 | void |
|
|
1665 | 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) |
|
|
1666 | PROTOTYPE: @ |
|
|
1667 | CODE: |
|
|
1668 | { |
|
|
1669 | glEnable (GL_TEXTURE_2D); |
|
|
1670 | glEnable (GL_BLEND); |
|
|
1671 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1672 | glBindTexture (GL_TEXTURE_2D, name1); |
|
|
1673 | |
|
|
1674 | glColor3f (intensity, intensity, intensity); |
|
|
1675 | glPushMatrix (); |
|
|
1676 | glScalef (1./3, 1./3, 1.); |
|
|
1677 | |
|
|
1678 | if (blend > 0.f) |
|
|
1679 | { |
|
|
1680 | float S2, T2; /* 0. 0. for texture 2 */ |
|
|
1681 | float w = w1 > w2 ? w1 : w2; |
|
|
1682 | float h = h1 > h2 ? h1 : h2; |
|
|
1683 | GLfloat env_color[4] = { 0., 0., 0., blend }; |
|
|
1684 | |
|
|
1685 | /* interpolate the two shadow textures */ |
|
|
1686 | /* stage 0 == rgb(glcolor) + alpha(t0) */ |
|
|
1687 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
|
1688 | |
|
|
1689 | /* stage 1 == rgb(glcolor) + alpha(interpolate t0, t1, texenv) */ |
|
|
1690 | gl.ActiveTexture (GL_TEXTURE1); |
|
|
1691 | glEnable (GL_TEXTURE_2D); |
|
|
1692 | glBindTexture (GL_TEXTURE_2D, name2); |
|
|
1693 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
|
|
1694 | |
|
|
1695 | /* rgb == rgb(glcolor) */ |
|
|
1696 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
|
|
1697 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); |
|
|
1698 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
|
|
1699 | |
|
|
1700 | /* alpha = interpolate t0, t1 by env_alpha */ |
|
|
1701 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
|
|
1702 | |
|
|
1703 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE); |
|
|
1704 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); |
|
|
1705 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); |
|
|
1706 | |
|
|
1707 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS); |
|
|
1708 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
|
|
1709 | |
|
|
1710 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); |
|
|
1711 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); |
|
|
1712 | |
|
|
1713 | s1 *= w / w1; |
|
|
1714 | t1 *= h / h1; |
|
|
1715 | |
|
|
1716 | dx *= -3.f / w2; |
|
|
1717 | dy *= -3.f / h2; |
|
|
1718 | dx *= w / w2; |
|
|
1719 | dy *= h / h2; |
|
|
1720 | |
|
|
1721 | s2 *= w / w2; |
|
|
1722 | t2 *= h / h2; |
|
|
1723 | |
|
|
1724 | glBegin (GL_QUADS); |
|
|
1725 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx , dy ); glVertex2f ( 0, 0); |
|
|
1726 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, t1); gl.MultiTexCoord2f (GL_TEXTURE1, dx , dy + t2); glVertex2f ( 0, h1); |
|
|
1727 | gl.MultiTexCoord2f (GL_TEXTURE0, s1, t1); gl.MultiTexCoord2f (GL_TEXTURE1, dx + s2, dy + t2); glVertex2f (w1, h1); |
|
|
1728 | gl.MultiTexCoord2f (GL_TEXTURE0, s1, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx + s2, dy ); glVertex2f (w1, 0); |
|
|
1729 | glEnd (); |
|
|
1730 | |
|
|
1731 | glDisable (GL_TEXTURE_2D); |
|
|
1732 | gl.ActiveTexture (GL_TEXTURE0); |
|
|
1733 | } |
|
|
1734 | else |
|
|
1735 | { |
|
|
1736 | /* simple blending of one texture, also opengl <1.3 path */ |
|
|
1737 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
|
1738 | |
|
|
1739 | glBegin (GL_QUADS); |
|
|
1740 | glTexCoord2f ( 0, 0); glVertex2f ( 0, 0); |
|
|
1741 | glTexCoord2f ( 0, t1); glVertex2f ( 0, h1); |
|
|
1742 | glTexCoord2f (s1, t1); glVertex2f (w1, h1); |
|
|
1743 | glTexCoord2f (s1, 0); glVertex2f (w1, 0); |
|
|
1744 | glEnd (); |
|
|
1745 | } |
|
|
1746 | |
|
|
1747 | glPopMatrix (); |
|
|
1748 | |
|
|
1749 | glDisable (GL_TEXTURE_2D); |
|
|
1750 | glDisable (GL_BLEND); |
|
|
1751 | } |
|
|
1752 | |
1659 | IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type) |
1753 | IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type) |
1660 | CODE: |
1754 | CODE: |
1661 | { |
1755 | { |
1662 | GLint width; |
1756 | GLint width; |
1663 | glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0); |
1757 | glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0); |
… | |
… | |
1780 | if (tex->name) |
1874 | if (tex->name) |
1781 | { |
1875 | { |
1782 | if (tex->unused) |
1876 | if (tex->unused) |
1783 | { |
1877 | { |
1784 | tex->name = 0; |
1878 | tex->name = 0; |
1785 | tex->unused = 0, |
1879 | tex->unused = 0; |
1786 | XPUSHs (sv_2mortal (newSViv (texid))); |
1880 | XPUSHs (sv_2mortal (newSViv (texid))); |
1787 | } |
1881 | } |
1788 | else |
1882 | else |
1789 | tex->unused = 1; |
1883 | tex->unused = 1; |
1790 | } |
1884 | } |
… | |
… | |
2005 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2099 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2006 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2100 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2007 | smooth_key skey; |
2101 | smooth_key skey; |
2008 | int pl_x, pl_y; |
2102 | int pl_x, pl_y; |
2009 | maptex pl_tex; |
2103 | maptex pl_tex; |
2010 | rc_t *rc = rc_alloc (); |
2104 | rc_t *rc = rc_alloc (); |
|
|
2105 | rc_t *rc_ov = rc_alloc (); |
2011 | rc_key_t key; |
2106 | rc_key_t key; |
2012 | rc_array_t *arr; |
2107 | rc_array_t *arr, *arr_hidden; |
2013 | |
2108 | |
2014 | pl_tex.name = 0; |
2109 | pl_tex.name = 0; |
2015 | |
2110 | |
2016 | // thats current max. sorry. |
2111 | // that's current max. sorry. |
2017 | if (sw > 255) sw = 255; |
2112 | if (sw > 255) sw = 255; |
2018 | if (sh > 255) sh = 255; |
2113 | if (sh > 255) sh = 255; |
2019 | |
2114 | |
2020 | // clear key, in case of extra padding |
2115 | // clear key, in case of extra padding |
2021 | memset (&skey, 0, sizeof (skey)); |
2116 | memset (&skey, 0, sizeof (skey)); |
… | |
… | |
2025 | key.g = 255; |
2120 | key.g = 255; |
2026 | key.b = 255; |
2121 | key.b = 255; |
2027 | key.a = 255; |
2122 | key.a = 255; |
2028 | key.mode = GL_QUADS; |
2123 | key.mode = GL_QUADS; |
2029 | key.format = GL_T2F_V3F; |
2124 | key.format = GL_T2F_V3F; |
2030 | key.texname = -1; |
|
|
2031 | |
2125 | |
2032 | mx += self->x; |
2126 | mx += self->x; |
2033 | my += self->y; |
2127 | my += self->y; |
2034 | |
2128 | |
2035 | // first pass: determine smooth_max |
2129 | // first pass: determine smooth_max |
… | |
… | |
2056 | |
2150 | |
2057 | glEnable (GL_BLEND); |
2151 | glEnable (GL_BLEND); |
2058 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2152 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2059 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2153 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2060 | |
2154 | |
|
|
2155 | key.texname = self->tex [TEXID_HIDDEN].name; |
|
|
2156 | arr_hidden = rc_array (rc_ov, &key); |
|
|
2157 | |
2061 | for (z = 0; z <= 2; z++) |
2158 | for (z = 0; z <= 2; z++) |
2062 | { |
2159 | { |
2063 | memset (smooth_level, 0, sizeof (smooth_level)); |
2160 | memset (smooth_level, 0, sizeof (smooth_level)); |
|
|
2161 | key.texname = -1; |
2064 | |
2162 | |
2065 | for (y = 0; y < sh; y++) |
2163 | for (y = 0; y < sh; y++) |
2066 | if (0 <= y + my && y + my < self->rows) |
2164 | if (0 <= y + my && y + my < self->rows) |
2067 | { |
2165 | { |
2068 | maprow *row = self->row + (y + my); |
2166 | maprow *row = self->row + (y + my); |
… | |
… | |
2074 | tileid tile = cell->tile [z]; |
2172 | tileid tile = cell->tile [z]; |
2075 | |
2173 | |
2076 | if (tile) |
2174 | if (tile) |
2077 | { |
2175 | { |
2078 | maptex tex = self->tex [tile]; |
2176 | maptex tex = self->tex [tile]; |
2079 | int px = (x + 1) * T - tex.w; |
2177 | int px, py; |
2080 | int py = (y + 1) * T - tex.h; |
|
|
2081 | |
2178 | |
2082 | if (key.texname != tex.name) |
2179 | if (key.texname != tex.name) |
2083 | { |
2180 | { |
2084 | self->tex [tile].unused = 0; |
2181 | self->tex [tile].unused = 0; |
2085 | |
2182 | |
2086 | if (!tex.name) |
2183 | if (!tex.name) |
2087 | tex = self->tex [2]; /* missing, replace by noface */ |
2184 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
2088 | |
2185 | |
2089 | key.texname = tex.name; |
2186 | key.texname = tex.name; |
2090 | arr = rc_array (rc, &key); |
2187 | arr = rc_array (rc, &key); |
2091 | } |
2188 | } |
|
|
2189 | |
|
|
2190 | px = (x + 1) * T - tex.w; |
|
|
2191 | py = (y + 1) * T - tex.h; |
2092 | |
2192 | |
2093 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2193 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2094 | { |
2194 | { |
2095 | pl_x = px; |
2195 | pl_x = px; |
2096 | pl_y = py; |
2196 | pl_y = py; |
… | |
… | |
2101 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2201 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2102 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2202 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2103 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2203 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2104 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2204 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2105 | |
2205 | |
2106 | if (expect_false (cell->flags) && expect_false (z == 2)) |
|
|
2107 | { |
|
|
2108 | // overlays such as the speech bubble, probably more to come |
|
|
2109 | if (cell->flags & 1) |
|
|
2110 | { |
|
|
2111 | maptex tex = self->tex [1]; |
|
|
2112 | int px = x * T + T * 2 / 32; |
|
|
2113 | int py = y * T - T * 6 / 32; |
|
|
2114 | |
|
|
2115 | if (tex.name) |
|
|
2116 | { |
|
|
2117 | if (key.texname != tex.name) |
|
|
2118 | { |
|
|
2119 | key.texname = tex.name; |
|
|
2120 | arr = rc_array (rc, &key); |
|
|
2121 | } |
|
|
2122 | |
|
|
2123 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2124 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
2125 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
2126 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
|
|
2127 | } |
|
|
2128 | } |
|
|
2129 | } |
|
|
2130 | |
|
|
2131 | // update smooth hash |
2206 | // update smooth hash |
2132 | if (tex.smoothtile) |
2207 | if (tex.smoothtile) |
2133 | { |
2208 | { |
2134 | skey.tile = tex.smoothtile; |
2209 | skey.tile = tex.smoothtile; |
2135 | skey.level = tex.smoothlevel; |
2210 | skey.level = tex.smoothlevel; |
… | |
… | |
2163 | // corners |
2238 | // corners |
2164 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2239 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2165 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2240 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2166 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2241 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2167 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2242 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
|
|
2243 | } |
|
|
2244 | } |
|
|
2245 | |
|
|
2246 | if (expect_false (z == 2)) |
|
|
2247 | { |
|
|
2248 | /* draw question marks on top of hidden spaces */ |
|
|
2249 | if (!cell->darkness) |
|
|
2250 | { |
|
|
2251 | maptex tex = self->tex [TEXID_HIDDEN]; |
|
|
2252 | int px = (x + 1) * T - tex.w; |
|
|
2253 | int py = (y + 1) * T - tex.h; |
|
|
2254 | |
|
|
2255 | rc_t2f_v3f (arr_hidden, 0 , 0 , px , py , 0); |
|
|
2256 | rc_t2f_v3f (arr_hidden, 0 , tex.t, px , py + tex.h, 0); |
|
|
2257 | rc_t2f_v3f (arr_hidden, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
|
|
2258 | rc_t2f_v3f (arr_hidden, tex.s, 0 , px + tex.w, py , 0); |
|
|
2259 | } |
|
|
2260 | |
|
|
2261 | if (expect_false (cell->flags)) |
|
|
2262 | { |
|
|
2263 | // overlays such as the speech bubble, probably more to come |
|
|
2264 | if (cell->flags & 1) |
|
|
2265 | { |
|
|
2266 | rc_key_t key_ov = key; |
|
|
2267 | maptex tex = self->tex [TEXID_SPEECH]; |
|
|
2268 | rc_array_t *arr; |
|
|
2269 | int px = x * T + T * 2 / 32; |
|
|
2270 | int py = y * T - T * 6 / 32; |
|
|
2271 | |
|
|
2272 | key_ov.texname = tex.name; |
|
|
2273 | arr = rc_array (rc_ov, &key_ov); |
|
|
2274 | |
|
|
2275 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2276 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
2277 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
2278 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
|
|
2279 | } |
2168 | } |
2280 | } |
2169 | } |
2281 | } |
2170 | } |
2282 | } |
2171 | } |
2283 | } |
2172 | |
2284 | |
… | |
… | |
2269 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2381 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2270 | |
2382 | |
2271 | rc_draw (rc); |
2383 | rc_draw (rc); |
2272 | } |
2384 | } |
2273 | |
2385 | |
|
|
2386 | rc_draw (rc_ov); |
|
|
2387 | rc_clear (rc_ov); |
|
|
2388 | |
2274 | glDisable (GL_BLEND); |
2389 | glDisable (GL_BLEND); |
2275 | rc_free (rc); |
2390 | rc_free (rc); |
|
|
2391 | rc_free (rc_ov); |
2276 | |
2392 | |
2277 | // top layer: overlays such as the health bar |
2393 | // top layer: overlays such as the health bar |
2278 | for (y = 0; y < sh; y++) |
2394 | for (y = 0; y < sh; y++) |
2279 | if (0 <= y + my && y + my < self->rows) |
2395 | if (0 <= y + my && y + my < self->rows) |
2280 | { |
2396 | { |
… | |
… | |
2340 | }; |
2456 | }; |
2341 | |
2457 | |
2342 | int x, y; |
2458 | int x, y; |
2343 | |
2459 | |
2344 | glEnable (GL_TEXTURE_2D); |
2460 | glEnable (GL_TEXTURE_2D); |
|
|
2461 | /* GL_REPLACE would be correct, as we don't need to modulate alpha, |
|
|
2462 | * but the nvidia driver (185.18.14) mishandles alpha textures |
|
|
2463 | * ansd takes the colour from god knows where instead of using |
|
|
2464 | * Cp. MODULATE results in the same colour, but slightly different |
|
|
2465 | * alpha, but atcually gives us the correct colour with nvidia. |
|
|
2466 | */ |
2345 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2467 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
2346 | glEnable (GL_BLEND); |
2468 | glEnable (GL_BLEND); |
2347 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2469 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2348 | glBegin (GL_QUADS); |
2470 | glBegin (GL_QUADS); |
2349 | |
2471 | |
2350 | for (y = 0; y < h; y++) |
2472 | for (y = 0; y < h; y++) |
… | |
… | |
2357 | float *c = color [m & 15]; |
2479 | float *c = color [m & 15]; |
2358 | |
2480 | |
2359 | float tx1 = m & 0x40 ? 0.5 : 0.; |
2481 | float tx1 = m & 0x40 ? 0.5 : 0.; |
2360 | float tx2 = tx1 + 0.5; |
2482 | float tx2 = tx1 + 0.5; |
2361 | |
2483 | |
2362 | glColor4f (c[0], c[1], c[2], 0.75); |
2484 | glColor4f (c[0], c[1], c[2], 1); |
2363 | glTexCoord2f (tx1, 0.); glVertex2i (x , y ); |
2485 | glTexCoord2f (tx1, 0.); glVertex2i (x , y ); |
2364 | glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); |
2486 | glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); |
2365 | glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); |
2487 | glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); |
2366 | glTexCoord2f (tx2, 0.); glVertex2i (x + 1, y ); |
2488 | glTexCoord2f (tx2, 0.); glVertex2i (x + 1, y ); |
2367 | } |
2489 | } |
… | |
… | |
2389 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2511 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2390 | |
2512 | |
2391 | mx += self->x - 1; |
2513 | mx += self->x - 1; |
2392 | my += self->y - 1; |
2514 | my += self->y - 1; |
2393 | |
2515 | |
2394 | memset (darkness1, 255 - FOW_DARKNESS, sw1 * sh1); |
2516 | memset (darkness1, DARKNESS_ADJUST (255 - FOW_DARKNESS), sw1 * sh1); |
2395 | |
2517 | |
2396 | for (y = 0; y < sh1; y++) |
2518 | for (y = 0; y < sh1; y++) |
2397 | if (0 <= y + my && y + my < self->rows) |
2519 | if (0 <= y + my && y + my < self->rows) |
2398 | { |
2520 | { |
2399 | maprow *row = self->row + (y + my); |
2521 | maprow *row = self->row + (y + my); |
… | |
… | |
2402 | if (row->c0 <= x + mx && x + mx < row->c1) |
2524 | if (row->c0 <= x + mx && x + mx < row->c1) |
2403 | { |
2525 | { |
2404 | mapcell *cell = row->col + (x + mx - row->c0); |
2526 | mapcell *cell = row->col + (x + mx - row->c0); |
2405 | |
2527 | |
2406 | darkness1 [y * sw1 + x] = cell->darkness |
2528 | darkness1 [y * sw1 + x] = cell->darkness |
2407 | ? 255 - (cell->darkness - 1) |
2529 | ? DARKNESS_ADJUST (255 - (cell->darkness - 1)) |
2408 | : 255 - FOW_DARKNESS; |
2530 | : DARKNESS_ADJUST (255 - FOW_DARKNESS); |
2409 | } |
2531 | } |
2410 | } |
2532 | } |
2411 | |
2533 | |
2412 | for (y = 0; y < sh; ++y) |
2534 | for (y = 0; y < sh; ++y) |
2413 | for (x = 0; x < sw; ++x) |
2535 | for (x = 0; x < sw; ++x) |
… | |
… | |
2826 | } *civ, const_iv[] = { |
2948 | } *civ, const_iv[] = { |
2827 | # define const_iv(name) { # name, (IV)name } |
2949 | # define const_iv(name) { # name, (IV)name } |
2828 | const_iv (GL_VENDOR), |
2950 | const_iv (GL_VENDOR), |
2829 | const_iv (GL_VERSION), |
2951 | const_iv (GL_VERSION), |
2830 | const_iv (GL_EXTENSIONS), |
2952 | const_iv (GL_EXTENSIONS), |
|
|
2953 | const_iv (GL_MAX_TEXTURE_UNITS), |
2831 | const_iv (GL_COLOR_MATERIAL), |
2954 | const_iv (GL_COLOR_MATERIAL), |
2832 | const_iv (GL_SMOOTH), |
2955 | const_iv (GL_SMOOTH), |
2833 | const_iv (GL_FLAT), |
2956 | const_iv (GL_FLAT), |
2834 | const_iv (GL_DITHER), |
2957 | const_iv (GL_DITHER), |
2835 | const_iv (GL_BLEND), |
2958 | const_iv (GL_BLEND), |
… | |
… | |
2847 | const_iv (GL_ZERO), |
2970 | const_iv (GL_ZERO), |
2848 | const_iv (GL_SRC_ALPHA), |
2971 | const_iv (GL_SRC_ALPHA), |
2849 | const_iv (GL_DST_ALPHA), |
2972 | const_iv (GL_DST_ALPHA), |
2850 | const_iv (GL_ONE_MINUS_SRC_ALPHA), |
2973 | const_iv (GL_ONE_MINUS_SRC_ALPHA), |
2851 | const_iv (GL_ONE_MINUS_DST_ALPHA), |
2974 | const_iv (GL_ONE_MINUS_DST_ALPHA), |
|
|
2975 | const_iv (GL_SRC_COLOR), |
|
|
2976 | const_iv (GL_DST_COLOR), |
|
|
2977 | const_iv (GL_ONE_MINUS_SRC_COLOR), |
|
|
2978 | const_iv (GL_ONE_MINUS_DST_COLOR), |
2852 | const_iv (GL_SRC_ALPHA_SATURATE), |
2979 | const_iv (GL_SRC_ALPHA_SATURATE), |
2853 | const_iv (GL_RGB), |
2980 | const_iv (GL_RGB), |
2854 | const_iv (GL_RGBA), |
2981 | const_iv (GL_RGBA), |
2855 | const_iv (GL_RGBA4), |
2982 | const_iv (GL_RGBA4), |
2856 | const_iv (GL_RGBA8), |
2983 | const_iv (GL_RGBA8), |
… | |
… | |
2924 | const_iv (GL_NICEST), |
3051 | const_iv (GL_NICEST), |
2925 | const_iv (GL_V2F), |
3052 | const_iv (GL_V2F), |
2926 | const_iv (GL_V3F), |
3053 | const_iv (GL_V3F), |
2927 | const_iv (GL_T2F_V3F), |
3054 | const_iv (GL_T2F_V3F), |
2928 | const_iv (GL_T2F_N3F_V3F), |
3055 | const_iv (GL_T2F_N3F_V3F), |
|
|
3056 | const_iv (GL_FUNC_ADD), |
|
|
3057 | const_iv (GL_FUNC_SUBTRACT), |
|
|
3058 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
2929 | # undef const_iv |
3059 | # undef const_iv |
2930 | }; |
3060 | }; |
2931 | |
3061 | |
2932 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3062 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
2933 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3063 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
2940 | disable_GL_EXT_blend_func_separate () |
3070 | disable_GL_EXT_blend_func_separate () |
2941 | CODE: |
3071 | CODE: |
2942 | gl.BlendFuncSeparate = 0; |
3072 | gl.BlendFuncSeparate = 0; |
2943 | gl.BlendFuncSeparateEXT = 0; |
3073 | gl.BlendFuncSeparateEXT = 0; |
2944 | |
3074 | |
|
|
3075 | void |
|
|
3076 | apple_nvidia_bug (int enable) |
|
|
3077 | |
2945 | char * |
3078 | char * |
2946 | gl_vendor () |
3079 | gl_vendor () |
2947 | CODE: |
3080 | CODE: |
2948 | RETVAL = (char *)glGetString (GL_VENDOR); |
3081 | RETVAL = (char *)glGetString (GL_VENDOR); |
2949 | OUTPUT: |
3082 | OUTPUT: |
… | |
… | |
2997 | void glBlendFunc (int sfactor, int dfactor) |
3130 | void glBlendFunc (int sfactor, int dfactor) |
2998 | |
3131 | |
2999 | void glBlendFuncSeparate (int sa, int da, int saa, int daa) |
3132 | void glBlendFuncSeparate (int sa, int da, int saa, int daa) |
3000 | CODE: |
3133 | CODE: |
3001 | gl_BlendFuncSeparate (sa, da, saa, daa); |
3134 | gl_BlendFuncSeparate (sa, da, saa, daa); |
|
|
3135 | |
|
|
3136 | # void glBlendEquation (int se) |
3002 | |
3137 | |
3003 | void glDepthMask (int flag) |
3138 | void glDepthMask (int flag) |
3004 | |
3139 | |
3005 | void glLogicOp (int opcode) |
3140 | void glLogicOp (int opcode) |
3006 | |
3141 | |