--- deliantra/Deliantra-Client/Client.xs 2008/10/02 15:59:40 1.279 +++ deliantra/Deliantra-Client/Client.xs 2008/11/26 23:08:34 1.280 @@ -235,6 +235,7 @@ uint8_t r, g, b, a; tileid smoothtile; uint8_t smoothlevel; + uint8_t unused; /* set to zero on use */ } maptex; typedef struct { @@ -1208,6 +1209,13 @@ #endif } +int +SvREFCNT (SV *sv) + CODE: + RETVAL = SvREFCNT (sv); + OUTPUT: + RETVAL + MODULE = Deliantra::Client PACKAGE = DC::Font PROTOTYPES: DISABLE @@ -1762,6 +1770,26 @@ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } +void +expire_textures (DC::Map self, int texid, int count) + PPCODE: + for (; texid < self->texs && count; ++texid, --count) + { + maptex *tex = self->tex + texid; + + if (tex->name) + { + if (tex->unused) + { + tex->name = 0; + tex->unused = 0, + XPUSHs (sv_2mortal (newSViv (texid))); + } + else + tex->unused = 1; + } + } + int ox (DC::Map self) ALIAS: @@ -1891,12 +1919,14 @@ if (cell->tile [z]) { maptex *tex = self->tex + cell->tile [z]; + tex->unused = 0; if (!tex->name) av_push (missing, newSViv (cell->tile [z])); if (tex->smoothtile) { maptex *smooth = self->tex + tex->smoothtile; + smooth->unused = 0; if (!smooth->name) av_push (missing, newSViv (tex->smoothtile)); } @@ -2051,6 +2081,8 @@ if (key.texname != tex.name) { + self->tex [tile].unused = 0; + if (!tex.name) tex = self->tex [2]; /* missing, replace by noface */ @@ -2182,6 +2214,8 @@ // save gobs of state changes. if (key.texname != tex.name) { + self->tex [skey->tile].unused = 0; + glEnd (); glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); glBegin (GL_QUADS);