… | |
… | |
205 | struct cf_layout { |
205 | struct cf_layout { |
206 | PangoLayout *pl; |
206 | PangoLayout *pl; |
207 | float r, g, b, a; // default color for rgba mode |
207 | float r, g, b, a; // default color for rgba mode |
208 | int base_height; |
208 | int base_height; |
209 | DC__Font font; |
209 | DC__Font font; |
210 | rc_t *rc; |
210 | rc_t rc; |
211 | }; |
211 | }; |
212 | |
212 | |
213 | typedef cf_layout *DC__Layout; |
213 | typedef cf_layout *DC__Layout; |
214 | |
214 | |
215 | static DC__Font default_font; |
215 | static DC__Font default_font; |
… | |
… | |
287 | }; |
287 | }; |
288 | |
288 | |
289 | struct mapgrid { |
289 | struct mapgrid { |
290 | int x, y, w, h; |
290 | int x, y, w, h; |
291 | int ox, oy; /* offset to virtual global coordinate system */ |
291 | int ox, oy; /* offset to virtual global coordinate system */ |
292 | int faces; tileid *face2tile; // [faceid] |
292 | std::vector<tileid> tile; |
293 | int texs; maptex *tex; // [tileid] |
293 | std::vector<maptex> tex; |
294 | |
294 | |
295 | int32_t rows; |
295 | int32_t rows; |
296 | maprow *row; |
296 | maprow *row; |
|
|
297 | |
|
|
298 | ~mapgrid () |
|
|
299 | { |
|
|
300 | clear_cells (); |
|
|
301 | } |
|
|
302 | |
|
|
303 | void clear_cells (); |
297 | }; |
304 | }; |
298 | |
305 | |
299 | typedef mapgrid *DC__Map; |
306 | typedef mapgrid *DC__Map; |
300 | |
307 | |
301 | static char * |
308 | static char * |
… | |
… | |
320 | return ptr; |
327 | return ptr; |
321 | } |
328 | } |
322 | |
329 | |
323 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
330 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
324 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
331 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
325 | |
|
|
326 | static void |
|
|
327 | need_facenum (struct mapgrid *self, faceid face) |
|
|
328 | { |
|
|
329 | while (self->faces <= face) |
|
|
330 | { |
|
|
331 | Append (tileid, self->face2tile, self->faces, self->faces); |
|
|
332 | self->faces *= 2; |
|
|
333 | } |
|
|
334 | } |
|
|
335 | |
|
|
336 | static void |
|
|
337 | need_texid (struct mapgrid *self, int texid) |
|
|
338 | { |
|
|
339 | while (self->texs <= texid) |
|
|
340 | { |
|
|
341 | Append (maptex, self->tex, self->texs, self->texs); |
|
|
342 | self->texs *= 2; |
|
|
343 | } |
|
|
344 | } |
|
|
345 | |
332 | |
346 | static maprow * |
333 | static maprow * |
347 | map_get_row (mapgrid *self, int y) |
334 | map_get_row (mapgrid *self, int y) |
348 | { |
335 | { |
349 | if (0 > y) |
336 | if (0 > y) |
… | |
… | |
395 | map_get_cell (mapgrid *self, int x, int y) |
382 | map_get_cell (mapgrid *self, int x, int y) |
396 | { |
383 | { |
397 | return row_get_cell (map_get_row (self, y), x); |
384 | return row_get_cell (map_get_row (self, y), x); |
398 | } |
385 | } |
399 | |
386 | |
400 | static void |
387 | void mapgrid::clear_cells () |
401 | map_clear (mapgrid *self) |
|
|
402 | { |
388 | { |
403 | int r; |
389 | int r; |
404 | |
390 | |
405 | for (r = 0; r < self->rows; r++) |
391 | for (r = 0; r < rows; r++) |
406 | Safefree (self->row[r].col); |
392 | Safefree (row[r].col); |
407 | |
393 | |
408 | Safefree (self->row); |
394 | Safefree (row); |
409 | |
395 | |
410 | self->x = 0; |
396 | x = 0; |
411 | self->y = 0; |
397 | y = 0; |
412 | self->ox = 0; |
398 | ox = 0; |
413 | self->oy = 0; |
399 | oy = 0; |
414 | self->row = 0; |
400 | row = 0; |
415 | self->rows = 0; |
401 | rows = 0; |
416 | } |
402 | } |
417 | |
403 | |
418 | #define CELL_CLEAR(cell) \ |
404 | #define CELL_CLEAR(cell) \ |
419 | do { \ |
405 | do { \ |
420 | if ((cell)->player) \ |
406 | if ((cell)->player) \ |
… | |
… | |
1369 | tc_restore (); |
1355 | tc_restore (); |
1370 | |
1356 | |
1371 | DC::Layout |
1357 | DC::Layout |
1372 | new (SV *klass) |
1358 | new (SV *klass) |
1373 | CODE: |
1359 | CODE: |
1374 | New (0, RETVAL, 1, struct cf_layout); |
1360 | RETVAL = new cf_layout; |
1375 | |
1361 | |
1376 | RETVAL->pl = pango_layout_new (opengl_context); |
1362 | RETVAL->pl = pango_layout_new (opengl_context); |
1377 | RETVAL->r = 1.; |
1363 | RETVAL->r = 1.; |
1378 | RETVAL->g = 1.; |
1364 | RETVAL->g = 1.; |
1379 | RETVAL->b = 1.; |
1365 | RETVAL->b = 1.; |
1380 | RETVAL->a = 1.; |
1366 | RETVAL->a = 1.; |
1381 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1367 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1382 | RETVAL->font = 0; |
1368 | RETVAL->font = 0; |
1383 | RETVAL->rc = rc_alloc (); |
|
|
1384 | |
1369 | |
1385 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1370 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1386 | layout_update_font (RETVAL); |
1371 | layout_update_font (RETVAL); |
1387 | OUTPUT: |
1372 | OUTPUT: |
1388 | RETVAL |
1373 | RETVAL |
1389 | |
1374 | |
1390 | void |
1375 | void |
1391 | DESTROY (DC::Layout self) |
1376 | DESTROY (DC::Layout self) |
1392 | CODE: |
1377 | CODE: |
1393 | g_object_unref (self->pl); |
1378 | g_object_unref (self->pl); |
1394 | rc_free (self->rc); |
|
|
1395 | Safefree (self); |
1379 | delete self; |
1396 | |
1380 | |
1397 | void |
1381 | void |
1398 | set_text (DC::Layout self, SV *text_) |
1382 | set_text (DC::Layout self, SV *text_) |
1399 | CODE: |
1383 | CODE: |
1400 | { |
1384 | { |
… | |
… | |
1654 | } |
1638 | } |
1655 | |
1639 | |
1656 | void |
1640 | void |
1657 | render (DC::Layout self, float x, float y, int flags = 0) |
1641 | render (DC::Layout self, float x, float y, int flags = 0) |
1658 | CODE: |
1642 | CODE: |
1659 | rc_clear (self->rc); |
1643 | self->rc.clear (); |
1660 | pango_opengl_render_layout_subpixel ( |
1644 | pango_opengl_render_layout_subpixel ( |
1661 | self->pl, |
1645 | self->pl, |
1662 | self->rc, |
1646 | &self->rc, |
1663 | x * PANGO_SCALE, y * PANGO_SCALE, |
1647 | x * PANGO_SCALE, y * PANGO_SCALE, |
1664 | self->r, self->g, self->b, self->a, |
1648 | self->r, self->g, self->b, self->a, |
1665 | flags |
1649 | flags |
1666 | ); |
1650 | ); |
1667 | // we assume that context_change actually clears/frees stuff |
1651 | // we assume that context_change actually clears/frees stuff |
… | |
… | |
1678 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
1662 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
1679 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
1663 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
1680 | glEnable (GL_ALPHA_TEST); |
1664 | glEnable (GL_ALPHA_TEST); |
1681 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
1665 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
1682 | |
1666 | |
1683 | rc_draw (self->rc); |
1667 | self->rc.draw (); |
1684 | |
1668 | |
1685 | glDisable (GL_ALPHA_TEST); |
1669 | glDisable (GL_ALPHA_TEST); |
1686 | glDisable (GL_BLEND); |
1670 | glDisable (GL_BLEND); |
1687 | glDisable (GL_TEXTURE_2D); |
1671 | glDisable (GL_TEXTURE_2D); |
1688 | } |
1672 | } |
… | |
… | |
1902 | PROTOTYPES: DISABLE |
1886 | PROTOTYPES: DISABLE |
1903 | |
1887 | |
1904 | DC::Map |
1888 | DC::Map |
1905 | new (SV *klass) |
1889 | new (SV *klass) |
1906 | CODE: |
1890 | CODE: |
1907 | New (0, RETVAL, 1, mapgrid); |
1891 | RETVAL = new mapgrid; |
1908 | RETVAL->x = 0; |
1892 | RETVAL->x = 0; |
1909 | RETVAL->y = 0; |
1893 | RETVAL->y = 0; |
1910 | RETVAL->w = 0; |
1894 | RETVAL->w = 0; |
1911 | RETVAL->h = 0; |
1895 | RETVAL->h = 0; |
1912 | RETVAL->ox = 0; |
1896 | RETVAL->ox = 0; |
1913 | RETVAL->oy = 0; |
1897 | RETVAL->oy = 0; |
1914 | RETVAL->faces = 8192; Newz (0, RETVAL->face2tile, RETVAL->faces, tileid); |
|
|
1915 | RETVAL->texs = 8192; Newz (0, RETVAL->tex , RETVAL->texs , maptex); |
|
|
1916 | RETVAL->rows = 0; |
1898 | RETVAL->rows = 0; |
1917 | RETVAL->row = 0; |
1899 | RETVAL->row = 0; |
1918 | OUTPUT: |
1900 | OUTPUT: |
1919 | RETVAL |
1901 | RETVAL |
1920 | |
1902 | |
1921 | void |
1903 | void |
1922 | DESTROY (DC::Map self) |
1904 | DESTROY (DC::Map self) |
1923 | CODE: |
1905 | CODE: |
1924 | { |
1906 | { |
1925 | map_clear (self); |
|
|
1926 | Safefree (self->face2tile); |
|
|
1927 | Safefree (self->tex); |
|
|
1928 | Safefree (self); |
1907 | delete self; |
1929 | } |
1908 | } |
1930 | |
1909 | |
1931 | void |
1910 | void |
1932 | resize (DC::Map self, int map_width, int map_height) |
1911 | resize (DC::Map self, int map_width, int map_height) |
1933 | CODE: |
1912 | CODE: |
… | |
… | |
1935 | self->h = map_height; |
1914 | self->h = map_height; |
1936 | |
1915 | |
1937 | void |
1916 | void |
1938 | clear (DC::Map self) |
1917 | clear (DC::Map self) |
1939 | CODE: |
1918 | CODE: |
1940 | map_clear (self); |
1919 | self->clear_cells (); |
1941 | |
1920 | |
1942 | void |
1921 | void |
1943 | set_tileid (DC::Map self, int face, int tile) |
1922 | set_tileid (DC::Map self, int face, int tile) |
1944 | CODE: |
1923 | CODE: |
1945 | { |
1924 | { |
1946 | need_facenum (self, face); self->face2tile [face] = tile; |
1925 | if (self->tile.size () <= face) self->tile.resize (face + 1); |
1947 | need_texid (self, tile); |
1926 | self->tile[face] = tile; |
|
|
1927 | if (self->tex.size () <= tile) self->tex .resize (tile + 1); |
1948 | } |
1928 | } |
1949 | |
1929 | |
1950 | void |
1930 | void |
1951 | set_smooth (DC::Map self, int face, int smooth, int level) |
1931 | set_smooth (DC::Map self, int face, int smooth, int level) |
1952 | CODE: |
1932 | CODE: |
1953 | { |
1933 | { |
1954 | tileid texid; |
|
|
1955 | maptex *tex; |
|
|
1956 | |
|
|
1957 | if (face < 0 || face >= self->faces) |
1934 | if (face < 0 || face >= self->tile.size ()) |
1958 | return; |
1935 | return; |
1959 | |
1936 | |
1960 | if (smooth < 0 || smooth >= self->faces) |
1937 | if (smooth < 0 || smooth >= self->tile.size ()) |
1961 | return; |
1938 | return; |
1962 | |
1939 | |
1963 | texid = self->face2tile [face]; |
1940 | tileid texid = self->tile[face]; |
1964 | |
1941 | |
1965 | if (!texid) |
1942 | if (!texid) |
1966 | return; |
1943 | return; |
1967 | |
1944 | |
1968 | tex = self->tex + texid; |
1945 | maptex &tex = self->tex[texid]; |
1969 | tex->smoothtile = self->face2tile [smooth]; |
1946 | tex.smoothtile = self->tile[smooth]; |
1970 | tex->smoothlevel = level; |
1947 | tex.smoothlevel = level; |
1971 | } |
1948 | } |
1972 | |
1949 | |
1973 | void |
1950 | void |
1974 | set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1951 | set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1975 | CODE: |
1952 | CODE: |
1976 | { |
1953 | { |
1977 | need_texid (self, texid); |
1954 | if (self->tex.size () < texid) self->tex.resize (texid + 1); |
1978 | |
1955 | |
1979 | { |
1956 | { |
1980 | maptex *tex = self->tex + texid; |
1957 | maptex &tex = self->tex[texid]; |
1981 | |
1958 | |
1982 | tex->name = name; |
1959 | tex.name = name; |
1983 | tex->w = w; |
1960 | tex.w = w; |
1984 | tex->h = h; |
1961 | tex.h = h; |
1985 | tex->s = s; |
1962 | tex.s = s; |
1986 | tex->t = t; |
1963 | tex.t = t; |
1987 | tex->r = r; |
1964 | tex.r = r; |
1988 | tex->g = g; |
1965 | tex.g = g; |
1989 | tex->b = b; |
1966 | tex.b = b; |
1990 | tex->a = a; |
1967 | tex.a = a; |
1991 | } |
1968 | } |
1992 | |
1969 | |
1993 | // somewhat hackish, but for textures that require it, it really |
1970 | // somewhat hackish, but for textures that require it, it really |
1994 | // improves the look, and most others don't suffer. |
1971 | // improves the look, and most others don't suffer. |
1995 | glBindTexture (GL_TEXTURE_2D, name); |
1972 | glBindTexture (GL_TEXTURE_2D, name); |
… | |
… | |
2001 | } |
1978 | } |
2002 | |
1979 | |
2003 | void |
1980 | void |
2004 | expire_textures (DC::Map self, int texid, int count) |
1981 | expire_textures (DC::Map self, int texid, int count) |
2005 | PPCODE: |
1982 | PPCODE: |
2006 | for (; texid < self->texs && count; ++texid, --count) |
1983 | for (; texid < self->tex.size () && count; ++texid, --count) |
2007 | { |
1984 | { |
2008 | maptex *tex = self->tex + texid; |
1985 | maptex &tex = self->tex[texid]; |
2009 | |
1986 | |
2010 | if (tex->name) |
1987 | if (tex.name) |
2011 | { |
1988 | { |
2012 | if (tex->unused) |
1989 | if (tex.unused) |
2013 | { |
1990 | { |
2014 | tex->name = 0; |
1991 | tex.name = 0; |
2015 | tex->unused = 0; |
1992 | tex.unused = 0; |
2016 | XPUSHs (sv_2mortal (newSViv (texid))); |
1993 | XPUSHs (sv_2mortal (newSViv (texid))); |
2017 | } |
1994 | } |
2018 | else |
1995 | else |
2019 | tex->unused = 1; |
1996 | tex.unused = 1; |
2020 | } |
1997 | } |
2021 | } |
1998 | } |
2022 | |
1999 | |
2023 | int |
2000 | int |
2024 | ox (DC::Map self) |
2001 | ox (DC::Map self) |
… | |
… | |
2135 | } |
2112 | } |
2136 | |
2113 | |
2137 | for (z = 0; z <= 2; ++z) |
2114 | for (z = 0; z <= 2; ++z) |
2138 | if (flags & (4 >> z)) |
2115 | if (flags & (4 >> z)) |
2139 | { |
2116 | { |
2140 | faceid face = (data [0] << 8) + data [1]; data += 2; |
2117 | faceid face = (data[0] << 8) + data[1]; data += 2; |
2141 | need_facenum (self, face); |
2118 | if (self->tile.size () <= face) self->tile.resize (face + 1); |
2142 | cell->tile [z] = self->face2tile [face]; |
2119 | cell->tile[z] = self->tile[face]; |
2143 | |
2120 | |
2144 | if (cell->tile [z]) |
2121 | if (cell->tile[z]) |
2145 | { |
2122 | { |
2146 | maptex *tex = self->tex + cell->tile [z]; |
2123 | maptex &tex = self->tex[cell->tile[z]]; |
2147 | tex->unused = 0; |
2124 | tex.unused = 0; |
2148 | if (!tex->name) |
2125 | if (!tex.name) |
2149 | av_push (missing, newSViv (cell->tile [z])); |
2126 | av_push (missing, newSViv (cell->tile [z])); |
2150 | |
2127 | |
2151 | if (tex->smoothtile) |
2128 | if (tex.smoothtile) |
2152 | { |
2129 | { |
2153 | maptex *smooth = self->tex + tex->smoothtile; |
2130 | maptex &smooth = self->tex[tex.smoothtile]; |
2154 | smooth->unused = 0; |
2131 | smooth.unused = 0; |
2155 | if (!smooth->name) |
2132 | if (!smooth.name) |
2156 | av_push (missing, newSViv (tex->smoothtile)); |
2133 | av_push (missing, newSViv (tex.smoothtile)); |
2157 | } |
2134 | } |
2158 | } |
2135 | } |
2159 | } |
2136 | } |
2160 | } |
2137 | } |
2161 | else |
2138 | else |
… | |
… | |
2227 | int x, y, z; |
2204 | int x, y, z; |
2228 | |
2205 | |
2229 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! |
2206 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! |
2230 | int pl_x, pl_y; |
2207 | int pl_x, pl_y; |
2231 | maptex pl_tex; |
2208 | maptex pl_tex; |
2232 | rc_t *rc = rc_alloc (); |
2209 | rc_t rc; |
2233 | rc_t *rc_ov = rc_alloc (); |
2210 | rc_t rc_ov; |
2234 | rc_key_t key; |
2211 | rc_key_t key; |
2235 | rc_array_t *arr; |
2212 | rc_t::array_t *arr; |
2236 | |
2213 | |
2237 | pl_tex.name = 0; |
2214 | pl_tex.name = 0; |
2238 | |
2215 | |
2239 | // that's current max. sorry. |
2216 | // that's current max. sorry. |
2240 | if (sw > 255) sw = 255; |
2217 | if (sw > 255) sw = 255; |
… | |
… | |
2306 | |
2283 | |
2307 | if (!tex.name) |
2284 | if (!tex.name) |
2308 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
2285 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
2309 | |
2286 | |
2310 | key.texname = tex.name; |
2287 | key.texname = tex.name; |
2311 | arr = rc_array (rc, &key); |
2288 | arr = &rc.array (key); |
2312 | } |
2289 | } |
2313 | |
2290 | |
2314 | px = (x + 1) * Th - tex.w; |
2291 | px = (x + 1) * Th - tex.w; |
2315 | py = (y + 1) * Tw - tex.h; |
2292 | py = (y + 1) * Tw - tex.h; |
2316 | |
2293 | |
… | |
… | |
2320 | pl_y = py; |
2297 | pl_y = py; |
2321 | pl_tex = tex; |
2298 | pl_tex = tex; |
2322 | continue; |
2299 | continue; |
2323 | } |
2300 | } |
2324 | |
2301 | |
2325 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2302 | arr->t2f_v3f (0 , 0 , px , py , 0); |
2326 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2303 | arr->t2f_v3f (0 , tex.t, px , py + tex.h, 0); |
2327 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2304 | arr->t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2328 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2305 | arr->t2f_v3f (tex.s, 0 , px + tex.w, py , 0); |
2329 | |
2306 | |
2330 | // update smooth hash |
2307 | // update smooth hash |
2331 | if (tex.smoothtile) |
2308 | if (tex.smoothtile) |
2332 | { |
2309 | { |
2333 | skey.tile = tex.smoothtile; |
2310 | skey.tile = tex.smoothtile; |
… | |
… | |
2371 | { |
2348 | { |
2372 | // overlays such as the speech bubble, probably more to come |
2349 | // overlays such as the speech bubble, probably more to come |
2373 | if (cell->flags & 1) |
2350 | if (cell->flags & 1) |
2374 | { |
2351 | { |
2375 | rc_key_t key_ov = key; |
2352 | rc_key_t key_ov = key; |
2376 | maptex tex = self->tex [TEXID_SPEECH]; |
2353 | maptex tex = self->tex[TEXID_SPEECH]; |
2377 | rc_array_t *arr; |
|
|
2378 | int px = x * Tw + Tw * 2 / 32; |
2354 | int px = x * Tw + Tw * 2 / 32; |
2379 | int py = y * Th - Th * 6 / 32; |
2355 | int py = y * Th - Th * 6 / 32; |
2380 | |
2356 | |
2381 | key_ov.texname = tex.name; |
2357 | key_ov.texname = tex.name; |
2382 | arr = rc_array (rc_ov, &key_ov); |
2358 | rc_t::array_t &arr = rc_ov.array (key_ov); |
2383 | |
2359 | |
2384 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2360 | arr.t2f_v3f (0 , 0 , px , py , 0); |
2385 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2361 | arr.t2f_v3f (0 , tex.t, px , py + Th, 0); |
2386 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2362 | arr.t2f_v3f (tex.s, tex.t, px + Tw, py + Th, 0); |
2387 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2363 | arr.t2f_v3f (tex.s, 0 , px + Tw, py , 0); |
2388 | } |
2364 | } |
2389 | } |
2365 | } |
2390 | } |
2366 | } |
2391 | } |
2367 | } |
2392 | |
2368 | |
2393 | rc_draw (rc); |
2369 | rc.draw (); |
2394 | rc_clear (rc); |
2370 | rc.clear (); |
2395 | |
2371 | |
2396 | // go through all smoothlevels, lowest to highest, then draw. |
2372 | // go through all smoothlevels, lowest to highest, then draw. |
2397 | // this is basically counting sort |
2373 | // this is basically counting sort |
2398 | { |
2374 | { |
2399 | int w, b; |
2375 | int w, b; |
… | |
… | |
2466 | maptex tex = pl_tex; |
2442 | maptex tex = pl_tex; |
2467 | int px = pl_x + sdx; |
2443 | int px = pl_x + sdx; |
2468 | int py = pl_y + sdy; |
2444 | int py = pl_y + sdy; |
2469 | |
2445 | |
2470 | key.texname = tex.name; |
2446 | key.texname = tex.name; |
2471 | arr = rc_array (rc, &key); |
2447 | rc_t::array_t &arr = rc.array (key); |
2472 | |
2448 | |
2473 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2449 | arr.t2f_v3f (0 , 0 , px , py , 0); |
2474 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2450 | arr.t2f_v3f (0 , tex.t, px , py + tex.h, 0); |
2475 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2451 | arr.t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2476 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2452 | arr.t2f_v3f (tex.s, 0 , px + tex.w, py , 0); |
2477 | |
2453 | |
2478 | rc_draw (rc); |
2454 | rc.draw (); |
2479 | } |
2455 | } |
2480 | |
2456 | |
2481 | rc_draw (rc_ov); |
2457 | rc_ov.draw (); |
2482 | rc_clear (rc_ov); |
2458 | rc_ov.clear (); |
2483 | |
2459 | |
2484 | glDisable (GL_BLEND); |
2460 | glDisable (GL_BLEND); |
2485 | rc_free (rc); |
|
|
2486 | rc_free (rc_ov); |
|
|
2487 | |
2461 | |
2488 | // top layer: overlays such as the health bar |
2462 | // top layer: overlays such as the health bar |
2489 | for (y = 0; y < sh; y++) |
2463 | for (y = 0; y < sh; y++) |
2490 | if (0 <= y + my && y + my < self->rows) |
2464 | if (0 <= y + my && y + my < self->rows) |
2491 | { |
2465 | { |
… | |
… | |
2813 | |
2787 | |
2814 | for (z = 0; z <= 2; z++) |
2788 | for (z = 0; z <= 2; z++) |
2815 | { |
2789 | { |
2816 | tileid t = tile [z]; |
2790 | tileid t = tile [z]; |
2817 | |
2791 | |
2818 | if (t >= self->texs || (t && !self->tex [t].name)) |
2792 | if (t >= self->tex.size () || (t && !self->tex[t].name)) |
2819 | { |
2793 | { |
2820 | PUSHs (sv_2mortal (newSViv (t))); |
2794 | PUSHs (sv_2mortal (newSViv (t))); |
2821 | need_texid (self, t); |
2795 | if (self->tex.size () <= t) self->tex.resize (t + 1); |
2822 | } |
2796 | } |
2823 | |
2797 | |
2824 | cell->tile [z] = t; |
2798 | cell->tile[z] = t; |
2825 | } |
2799 | } |
2826 | } |
2800 | } |
2827 | } |
2801 | } |
2828 | } |
2802 | } |
2829 | } |
2803 | } |