… | |
… | |
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 16 |
87 | |
87 | |
88 | #define MAP_EXTEND_X 32 |
88 | #define MAP_EXTEND_X 32 |
89 | #define MAP_EXTEND_Y 512 |
89 | #define MAP_EXTEND_Y 512 |
90 | |
90 | |
91 | #define MIN_FONT_HEIGHT 10 |
91 | #define MIN_FONT_HEIGHT 10 |
… | |
… | |
233 | int w, h; |
233 | int w, h; |
234 | float s, t; |
234 | float s, t; |
235 | uint8_t r, g, b, a; |
235 | uint8_t r, g, b, a; |
236 | tileid smoothtile; |
236 | tileid smoothtile; |
237 | uint8_t smoothlevel; |
237 | uint8_t smoothlevel; |
|
|
238 | uint8_t unused; /* set to zero on use */ |
238 | } maptex; |
239 | } maptex; |
239 | |
240 | |
240 | typedef struct { |
241 | typedef struct { |
241 | uint32_t player; |
242 | uint32_t player; |
242 | tileid tile[3]; |
243 | tileid tile[3]; |
… | |
… | |
1206 | #if DEBUG |
1207 | #if DEBUG |
1207 | VALGRIND_DO_LEAK_CHECK; |
1208 | VALGRIND_DO_LEAK_CHECK; |
1208 | #endif |
1209 | #endif |
1209 | } |
1210 | } |
1210 | |
1211 | |
|
|
1212 | int |
|
|
1213 | SvREFCNT (SV *sv) |
|
|
1214 | CODE: |
|
|
1215 | RETVAL = SvREFCNT (sv); |
|
|
1216 | OUTPUT: |
|
|
1217 | RETVAL |
|
|
1218 | |
1211 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1219 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1212 | |
1220 | |
1213 | PROTOTYPES: DISABLE |
1221 | PROTOTYPES: DISABLE |
1214 | |
1222 | |
1215 | DC::Font |
1223 | DC::Font |
… | |
… | |
1759 | //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
1767 | //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
1760 | // use uglier nearest interpolation because linear suffers |
1768 | // use uglier nearest interpolation because linear suffers |
1761 | // from transparent color bleeding and ugly wrapping effects. |
1769 | // from transparent color bleeding and ugly wrapping effects. |
1762 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1770 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1763 | } |
1771 | } |
|
|
1772 | |
|
|
1773 | void |
|
|
1774 | expire_textures (DC::Map self, int texid, int count) |
|
|
1775 | PPCODE: |
|
|
1776 | for (; texid < self->texs && count; ++texid, --count) |
|
|
1777 | { |
|
|
1778 | maptex *tex = self->tex + texid; |
|
|
1779 | |
|
|
1780 | if (tex->name) |
|
|
1781 | { |
|
|
1782 | if (tex->unused) |
|
|
1783 | { |
|
|
1784 | tex->name = 0; |
|
|
1785 | tex->unused = 0; |
|
|
1786 | XPUSHs (sv_2mortal (newSViv (texid))); |
|
|
1787 | } |
|
|
1788 | else |
|
|
1789 | tex->unused = 1; |
|
|
1790 | } |
|
|
1791 | } |
1764 | |
1792 | |
1765 | int |
1793 | int |
1766 | ox (DC::Map self) |
1794 | ox (DC::Map self) |
1767 | ALIAS: |
1795 | ALIAS: |
1768 | oy = 1 |
1796 | oy = 1 |
… | |
… | |
1889 | cell->tile [z] = self->face2tile [face]; |
1917 | cell->tile [z] = self->face2tile [face]; |
1890 | |
1918 | |
1891 | if (cell->tile [z]) |
1919 | if (cell->tile [z]) |
1892 | { |
1920 | { |
1893 | maptex *tex = self->tex + cell->tile [z]; |
1921 | maptex *tex = self->tex + cell->tile [z]; |
|
|
1922 | tex->unused = 0; |
1894 | if (!tex->name) |
1923 | if (!tex->name) |
1895 | av_push (missing, newSViv (cell->tile [z])); |
1924 | av_push (missing, newSViv (cell->tile [z])); |
1896 | |
1925 | |
1897 | if (tex->smoothtile) |
1926 | if (tex->smoothtile) |
1898 | { |
1927 | { |
1899 | maptex *smooth = self->tex + tex->smoothtile; |
1928 | maptex *smooth = self->tex + tex->smoothtile; |
|
|
1929 | smooth->unused = 0; |
1900 | if (!smooth->name) |
1930 | if (!smooth->name) |
1901 | av_push (missing, newSViv (tex->smoothtile)); |
1931 | av_push (missing, newSViv (tex->smoothtile)); |
1902 | } |
1932 | } |
1903 | } |
1933 | } |
1904 | } |
1934 | } |
… | |
… | |
1995 | key.g = 255; |
2025 | key.g = 255; |
1996 | key.b = 255; |
2026 | key.b = 255; |
1997 | key.a = 255; |
2027 | key.a = 255; |
1998 | key.mode = GL_QUADS; |
2028 | key.mode = GL_QUADS; |
1999 | key.format = GL_T2F_V3F; |
2029 | key.format = GL_T2F_V3F; |
2000 | key.texname = -1; |
|
|
2001 | |
2030 | |
2002 | mx += self->x; |
2031 | mx += self->x; |
2003 | my += self->y; |
2032 | my += self->y; |
2004 | |
2033 | |
2005 | // first pass: determine smooth_max |
2034 | // first pass: determine smooth_max |
… | |
… | |
2029 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2058 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2030 | |
2059 | |
2031 | for (z = 0; z <= 2; z++) |
2060 | for (z = 0; z <= 2; z++) |
2032 | { |
2061 | { |
2033 | memset (smooth_level, 0, sizeof (smooth_level)); |
2062 | memset (smooth_level, 0, sizeof (smooth_level)); |
|
|
2063 | key.texname = -1; |
2034 | |
2064 | |
2035 | for (y = 0; y < sh; y++) |
2065 | for (y = 0; y < sh; y++) |
2036 | if (0 <= y + my && y + my < self->rows) |
2066 | if (0 <= y + my && y + my < self->rows) |
2037 | { |
2067 | { |
2038 | maprow *row = self->row + (y + my); |
2068 | maprow *row = self->row + (y + my); |
… | |
… | |
2049 | int px = (x + 1) * T - tex.w; |
2079 | int px = (x + 1) * T - tex.w; |
2050 | int py = (y + 1) * T - tex.h; |
2080 | int py = (y + 1) * T - tex.h; |
2051 | |
2081 | |
2052 | if (key.texname != tex.name) |
2082 | if (key.texname != tex.name) |
2053 | { |
2083 | { |
|
|
2084 | self->tex [tile].unused = 0; |
|
|
2085 | |
2054 | if (!tex.name) |
2086 | if (!tex.name) |
2055 | tex = self->tex [2]; /* missing, replace by noface */ |
2087 | tex = self->tex [2]; /* missing, replace by noface */ |
2056 | |
2088 | |
2057 | key.texname = tex.name; |
2089 | key.texname = tex.name; |
2058 | arr = rc_array (rc, &key); |
2090 | arr = rc_array (rc, &key); |
… | |
… | |
2180 | { |
2212 | { |
2181 | // this time avoiding texture state changes |
2213 | // this time avoiding texture state changes |
2182 | // save gobs of state changes. |
2214 | // save gobs of state changes. |
2183 | if (key.texname != tex.name) |
2215 | if (key.texname != tex.name) |
2184 | { |
2216 | { |
|
|
2217 | self->tex [skey->tile].unused = 0; |
|
|
2218 | |
2185 | glEnd (); |
2219 | glEnd (); |
2186 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2220 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2187 | glBegin (GL_QUADS); |
2221 | glBegin (GL_QUADS); |
2188 | } |
2222 | } |
2189 | |
2223 | |
… | |
… | |
2251 | { |
2285 | { |
2252 | mapcell *cell = row->col + (x + mx - row->c0); |
2286 | mapcell *cell = row->col + (x + mx - row->c0); |
2253 | |
2287 | |
2254 | int px = x * T; |
2288 | int px = x * T; |
2255 | int py = y * T; |
2289 | int py = y * T; |
|
|
2290 | |
|
|
2291 | if (expect_false (cell->player == player)) |
|
|
2292 | { |
|
|
2293 | px += sdx; |
|
|
2294 | py += sdy; |
|
|
2295 | } |
2256 | |
2296 | |
2257 | if (cell->stat_hp) |
2297 | if (cell->stat_hp) |
2258 | { |
2298 | { |
2259 | int width = cell->stat_width * T; |
2299 | int width = cell->stat_width * T; |
2260 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2300 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
… | |
… | |
3001 | void glRotate (float angle, float x, float y, float z) |
3041 | void glRotate (float angle, float x, float y, float z) |
3002 | CODE: |
3042 | CODE: |
3003 | glRotatef (angle, x, y, z); |
3043 | glRotatef (angle, x, y, z); |
3004 | |
3044 | |
3005 | void glColor (float r, float g, float b, float a = 1.0) |
3045 | void glColor (float r, float g, float b, float a = 1.0) |
|
|
3046 | PROTOTYPE: @ |
3006 | ALIAS: |
3047 | ALIAS: |
3007 | glColor_premultiply = 1 |
3048 | glColor_premultiply = 1 |
3008 | CODE: |
3049 | CODE: |
3009 | if (ix) |
3050 | if (ix) |
3010 | { |
3051 | { |