added resetgl command to restart renderer in-game

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1642 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-02-12 03:30:52 +00:00
parent 968bbcca96
commit 072cc6d525
9 changed files with 229 additions and 73 deletions
+41 -2
View File
@@ -130,6 +130,7 @@ Texture *textureload(const char *name, int clamp)
t->xs = xs;
t->ys = ys;
t->bpp = bpp;
t->clamp = clamp;
t->id = id;
return t;
}
@@ -174,6 +175,36 @@ Texture *lookuptexture(int tex)
return t;
}
void cleanuptextures()
{
enumerate(textures, Texture, t,
if(t.id) { glDeleteTextures(1, &t.id); t.id = 0; }
);
}
bool reloadtexture(Texture &t)
{
if(t.id) return true;
int xs = 1, ys = 1, bpp = 0;
t.id = loadsurface(t.name, xs, ys, bpp, t.clamp);
t.xs = xs;
t.ys = ys;
t.bpp = bpp;
return t.id!=0;
}
bool reloadtexture(const char *name)
{
Texture *t = textures.access(path(name, true));
if(t) return reloadtexture(*t);
return false;
}
void reloadtextures()
{
enumerate(textures, Texture, t, reloadtexture(t));
}
Texture *sky[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
void loadsky(char *basename)
@@ -273,7 +304,9 @@ struct tmu
{ GL_MODULATE, { GL_TEXTURE, GL_PREVIOUS_ARB, GL_CONSTANT_ARB }, { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, 1 } \
}
tmu tmus[4] =
#define MAXTMUS 4
tmu tmus[MAXTMUS] =
{
INVALIDTMU,
INVALIDTMU,
@@ -377,7 +410,7 @@ void inittmus()
else if(hasTE && hasMT)
{
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &val);
maxtmus = max(1, min(4, int(val)));
maxtmus = max(1, min(MAXTMUS, int(val)));
loopi(maxtmus)
{
glActiveTexture_(GL_TEXTURE0_ARB+i);
@@ -387,3 +420,9 @@ void inittmus()
}
}
void cleanuptmus()
{
tmu invalidtmu = INVALIDTMU;
loopi(MAXTMUS) tmus[i] = invalidtmu;
}