noworldtexture cleanup

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2297 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-08-08 08:14:58 +00:00
parent fce52698aa
commit 930f4e223c
5 changed files with 21 additions and 20 deletions
+1 -1
View File
@@ -535,7 +535,7 @@ int main(int argc, char **argv)
gl_checkextensions();
gl_init(scr_w, scr_h, usedcolorbits, useddepthbits, usedfsaa);
notexture = textureload("packages/misc/notexture.jpg");
notexture = noworldtexture = textureload("packages/misc/notexture.jpg");
if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)");
initlog("console");
+5 -2
View File
@@ -217,16 +217,19 @@ struct Texture
int xs, ys, bpp, clamp;
GLuint id;
};
extern Texture *notexture;
extern Texture *notexture, *noworldtexture;
extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, GLenum format);
extern Texture *textureload(const char *name, int clamp = 0);
extern Texture *lookuptexture(int tex);
extern Texture *lookuptexture(int tex, Texture *failtex = notexture);
extern void draw_envbox(int fogdist);
extern bool reloadtexture(Texture &t);
extern bool reloadtexture(const char *name);
extern void reloadtextures();
static inline Texture *lookupworldtexture(int tex)
{ return lookuptexture(tex, noworldtexture); }
extern int maxtmus;
extern void inittmus();
extern void resettmu(int n);
+7 -7
View File
@@ -46,7 +46,7 @@ int renderedtexs = 0;
void renderstripssky()
{
if(skystrips.tris.first.empty() && skystrips.tristrips.first.empty() && skystrips.quads.first.empty()) return;
glBindTexture(GL_TEXTURE_2D, lookuptexture(DEFAULT_SKY)->id);
glBindTexture(GL_TEXTURE_2D, lookupworldtexture(DEFAULT_SKY)->id);
RENDERSTRIPS(skystrips.tris, GL_TRIANGLES);
RENDERSTRIPS(skystrips.tristrips, GL_TRIANGLE_STRIP);
RENDERSTRIPS(skystrips.quads, GL_QUADS);
@@ -57,7 +57,7 @@ void renderstrips()
loopj(renderedtexs)
{
stripbatch &sb = stripbatches[j];
glBindTexture(GL_TEXTURE_2D, lookuptexture(sb.tex)->id);
glBindTexture(GL_TEXTURE_2D, lookupworldtexture(sb.tex)->id);
RENDERSTRIPS(sb.tris, GL_TRIANGLES);
RENDERSTRIPS(sb.tristrips, GL_TRIANGLE_STRIP);
RENDERSTRIPS(sb.quads, GL_QUADS);
@@ -142,7 +142,7 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr
{
if(showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; }
Texture *t = lookuptexture(wtex);
Texture *t = lookupworldtexture(wtex);
float xf = TEXTURESCALE/t->xs;
float yf = TEXTURESCALE/t->ys;
float xs = size*xf;
@@ -219,7 +219,7 @@ void render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, floa
{
if(showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; }
Texture *t = lookuptexture(wtex);
Texture *t = lookupworldtexture(wtex);
float xf = TEXTURESCALE/t->xs;
float yf = TEXTURESCALE/t->ys;
float xs = size*xf;
@@ -273,7 +273,7 @@ void render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3
{
stripend();
Texture *t = lookuptexture(h->ftex);
Texture *t = lookupworldtexture(h->ftex);
float xf = TEXTURESCALE/t->xs;
float yf = TEXTURESCALE/t->ys;
vert(x1, y1, h->floor, l1, xf*x1, yf*y1);
@@ -281,7 +281,7 @@ void render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3
vert(x3, y3, h->floor, l3, xf*x3, yf*y3);
addstrip(mergestrips ? GL_TRIANGLES : GL_TRIANGLE_STRIP, h->ftex, verts.length()-3, 3);
t = lookuptexture(h->ctex);
t = lookupworldtexture(h->ctex);
xf = TEXTURESCALE/t->xs;
yf = TEXTURESCALE/t->ys;
@@ -312,7 +312,7 @@ void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil
stripend();
if(showm) { l1 = &sbright; l2 = &sdark; }
Texture *t = lookuptexture(wtex);
Texture *t = lookupworldtexture(wtex);
float xf = TEXTURESCALE/t->xs;
float yf = TEXTURESCALE/t->ys;
float xs = size*xf;
+7 -9
View File
@@ -3,7 +3,7 @@
#include "pch.h"
#include "cube.h"
Texture *notexture = NULL;
Texture *notexture = NULL, *noworldtexture = NULL;
hashtable<char *, Texture> textures;
@@ -159,9 +159,9 @@ void texture(char *aframe, char *name)
COMMAND(texturereset, ARG_NONE);
COMMAND(texture, ARG_2STR);
Texture *lookuptexture(int tex)
Texture *lookuptexture(int tex, Texture *failtex)
{
Texture *t = notexture;
Texture *t = failtex;
if(slots.inrange(tex))
{
Slot &s = slots[tex];
@@ -169,6 +169,7 @@ Texture *lookuptexture(int tex)
{
s_sprintfd(pname)("packages/textures/%s", s.name);
s.tex = textureload(pname);
if(s.tex==notexture) s.tex = failtex;
s.loaded = true;
}
if(s.tex) t = s.tex;
@@ -223,15 +224,12 @@ COMMAND(loadsky, ARG_1STR);
void loadnotexture(char *c)
{
const char *defnotex = "packages/misc/notexture.jpg";
notexture = textureload(defnotex); // reset to default
noworldtexture = notexture; // reset to default
if(c[0])
{
s_sprintfd(p)("packages/textures/%s", c);
Texture *missingtex = textureload(p);
if(missingtex==notexture) { conoutf("could not load alternative texture '%s'.", p); s_strcpy(p, defnotex); }
else notexture = missingtex;
conoutf("using '%s' as alternative texture", p);
noworldtexture = textureload(p);
if(noworldtexture==notexture) conoutf("could not load alternative texture '%s'.", p);
}
}
COMMAND(loadnotexture, ARG_1STR);
+1 -1
View File
@@ -385,7 +385,7 @@ bool load_world(char *mname) // still supports all map formats that have
popscontext();
c2skeepalive();
loopi(256) if(texuse[i]) lookuptexture(i);
loopi(256) if(texuse[i]) lookupworldtexture(i);
c2skeepalive();
preload_mapmodels();
c2skeepalive();