diff --git a/source/src/client.cpp b/source/src/client.cpp index 19844ddf..c3fcf639 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -219,7 +219,7 @@ void initclientnet() { clientpassword[0] = 0; newname("unnamed"); - ctf_team("red"); + ctf_team("cube"); }; void sendpackettoserv(int chan, ENetPacket *packet) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 8d96538e..3e40e010 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -147,7 +147,7 @@ void parsepositions(ucharbuf &p) void parsemessages(int cn, dynent *d, ucharbuf &p) { - char text[MAXTRANS]; + static char text[MAXTRANS]; int type; bool mapchanged = false; bool c2si = false, killedbybot=false; diff --git a/source/src/main.cpp b/source/src/main.cpp index 5e29f8e8..fdd9a089 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -4,7 +4,7 @@ void cleanup(char *msg) // single program exit point; { - stop(); + stop(); disconnect(true); cleangl(); cleansound(); @@ -287,6 +287,10 @@ int main(int argc, char **argv) gl_init(scr_w, scr_h, bpp, depth, fsaa); log("basetex"); + crosshair = textureload("packages/misc/crosshairs/default.png"); + if(!crosshair) fatal("could not find core textures (hint: run cube from the parent of the bin directory)"); + +#if 0 int xs, ys; if(!installtex(2, path(newstring("packages/misc/newchars.png")), xs, ys) || !installtex(3, path(newstring("packages/misc/base.png")), xs, ys) || @@ -299,6 +303,7 @@ int main(int argc, char **argv) !installtex(10, path(newstring("packages/misc/scope.png")), xs, ys) || !installtex(11, path(newstring("packages/misc/flag_icons.png")), xs, ys) || !installtex(1, path(newstring("packages/misc/crosshairs/default.png")), xs, ys)) fatal("could not find core textures (hint: run cube from the parent of the bin directory)"); +#endif loadingscreen(); @@ -322,9 +327,8 @@ int main(int argc, char **argv) loadweapons(); log("localconnect"); - extern string clientmap; - s_strcpy(clientmap, "maps/ac_complex"); localconnect(); + changemap("maps/ac_complex"); log("mainloop"); int ignore = 5, grabmouse = 0; @@ -431,10 +435,7 @@ int main(int argc, char **argv) void loadcrosshair(char *c) { s_sprintfd(p)("packages/misc/crosshairs/%s", c); - path(p); - int xs, ys; - installtex(1, p, xs, ys); - + crosshair = textureload(p); }; COMMAND(loadcrosshair, ARG_1STR); diff --git a/source/src/menus.cpp b/source/src/menus.cpp index e2d9d3b4..f4170d57 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -75,7 +75,9 @@ bool rendermenu() int h = (mdisp+2)*step; int y = (VIRTH-h)/2; int x = (VIRTW-w)/2; - blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true, 6); + static Texture *menutex = NULL; + if(!menutex) menutex = textureload("packages/textures/makke/menu.jpg", false, true); + blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true, menutex->id); draw_text(title, x, y); y += FONTH*2; if(vmenu && vmenu!=2) diff --git a/source/src/protos.h b/source/src/protos.h index eed7abd1..dee87c61 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -39,10 +39,17 @@ extern bool resolverwait(const char *name, ENetAddress *address); extern void writeservercfg(); // rendergl +struct Texture +{ + char *name; + int xs, ys; + GLuint id; +}; +extern Texture *crosshair; extern void gl_init(int w, int h, int bpp, int depth, int fsaa); extern void cleangl(); extern void gl_drawframe(int w, int h, float changelod, float curfps); -extern bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp = false, bool highqual=false); +extern Texture *textureload(const char *name, bool clamp = false, bool highqual = false); extern void mipstats(int a, int b, int c); extern void vertf(float v1, float v2, float v3, sqr *ls, float t1, float t2); extern void addstrip(int tex, int start, int n); @@ -150,7 +157,7 @@ extern void draw_textf(const char *fstr, int left, int top, ...); extern int char_width(int c, int x = 0); extern int text_width(const char *str, int limit = -1); extern int text_visible(const char *str, int max); -extern void draw_envbox(int t, int fogdist); +extern void draw_envbox(int fogdist); // editing extern void cursorupdate(); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index a21004fe..912fefe2 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -51,7 +51,7 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex) glBindTexture(GL_TEXTURE_2D, tex); glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); - glColor3d(1.0, 1.0, 1.0); + glColor3f(1, 1, 1); int texw = 512; int texh = texw; @@ -80,7 +80,7 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex) } glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f((float)x1+texw*i, (float)y1+texh*j); + glTexCoord2f(0, 0); glVertex2f((float)x1+texw*i, (float)y1+texh*j); glTexCoord2f(1-xtexcut, 0); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*j); glTexCoord2f(1-xtexcut, 1-ytexcut); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*(j+1)-yboxcut); glTexCoord2f(0, 1-ytexcut); glVertex2f((float)x1+texw*i, y1+texh*(j+1)-yboxcut); @@ -90,8 +90,8 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex) } else { - if(border) glColor3d(0.7, 0.7, 0.7); //glColor3d(0.5, 0.3, 0.4); - else glColor3d(1.0, 1.0, 1.0); + if(border) glColor3f(0.7f, 0.7f, 0.7f); //glColor3d(0.5, 0.3, 0.4); + else glColor3f(1, 1, 1); glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(x1, y1); @@ -151,10 +151,13 @@ void renderspheres(int time) { if(!slist) return; + static Texture *exptex = NULL; + if(!exptex) exptex = textureload("packages/misc/explosion.jpg"); + glDepthMask(GL_FALSE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glBindTexture(GL_TEXTURE_2D, 4); + glBindTexture(GL_TEXTURE_2D, exptex->id); for(sphere *p, **pp = &slist; p = *pp;) { @@ -216,23 +219,6 @@ void renderents() // show sparkly thingies for map entities in edit mode }; }; -void loadsky(char *basename) -{ - static string lastsky = ""; - if(strcmp(lastsky, basename)==0) return; - char *side[] = { "ft", "bk", "lf", "rt", "dn", "up" }; - int texnum = 14; - loopi(6) - { - s_sprintfd(name)("packages/%s_%s.jpg", basename, side[i]); - int xs, ys; - if(!installtex(texnum+i, path(name), xs, ys, true)) conoutf("could not load sky textures"); - }; - s_strcpy(lastsky, basename); -}; - -COMMAND(loadsky, ARG_1STR); - float cursordepth = 0.9f; GLint viewport[4]; GLdouble mm[16], pm[16]; @@ -271,9 +257,15 @@ void readdepth(int w, int h) setorient(r, u); }; -void drawicon(float tx, float ty, int x, int y, int tex = 5, float scaling = 1/3.0f) // EDIT: AH +void drawicon(float tx, float ty, int x, int y, Texture *tex = NULL, float scaling = 1/3.0f) // EDIT: AH { - glBindTexture(GL_TEXTURE_2D, tex); + if(!tex) + { + static Texture *itemstex = NULL; + if(!itemstex) itemstex = textureload("packages/misc/items.png"); + tex = itemstex; + }; + glBindTexture(GL_TEXTURE_2D, tex->id); glBegin(GL_QUADS); tx /= 192; ty /= 192; @@ -374,7 +366,9 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.9f); - glBindTexture(GL_TEXTURE_2D, 10); + static Texture *scopetex = NULL; + if(!scopetex) scopetex = textureload("packages/misc/scope.png"); + glBindTexture(GL_TEXTURE_2D, scopetex->id); glBegin(GL_QUADS); glColor3ub(255,255,255); @@ -390,7 +384,9 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat { glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); bool teammate_in_xhair = player ? (isteam(player->team, player1->team) && player->state!=CS_DEAD) : false; - glBindTexture(GL_TEXTURE_2D, teammate_in_xhair ? 9 : 1); + static Texture *teammatetex = NULL; + if(!teammatetex) teammatetex = textureload("packages/misc/teammate.png"); + glBindTexture(GL_TEXTURE_2D, teammate_in_xhair ? teammatetex->id : crosshair->id); glBegin(GL_QUADS); glColor3ub(255,255,255); if(crosshairfx) @@ -458,11 +454,13 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f(1.0f, 1.0f, 1.0f, 0.2f); if(flaginfos[TEAM_CLA].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); - drawicon(64*ctf_scl, 0, 1940, 1650, 11, 1.0f/4.0f); + static Texture *flagtex = NULL; + if(!flagtex) flagtex = textureload("packages/misc/flag_icons.png"); + drawicon(64*ctf_scl, 0, 1940, 1650, flagtex, 1.0f/4.0f); if(flaginfos[TEAM_RVSF].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); - drawicon(0, 0, 1820, 1650, 11, 1.0f/4.0f); + drawicon(0, 0, 1820, 1650, flagtex, 1.0f/4.0f); glDisable(GL_BLEND); - drawicon((float)(rb_team_int(player1->team)*64*ctf_scl), (float)(64*ctf_scl), VIRTW-128-10, 10, 11, 1.0/4.0); // shows which team you are + drawicon((float)(rb_team_int(player1->team)*64*ctf_scl), (float)(64*ctf_scl), VIRTW-128-10, 10, flagtex, 1.0/4.0); // shows which team you are glPopMatrix(); // big flag icon @@ -474,7 +472,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f(1.0f, 1.0f, 1.0f, (float)(sin(lastmillis / 100.0) + 1) / 2); glEnable(GL_BLEND); - drawicon((float)(rb_opposite(rb_team_int(player1->team))*128*ctf_scl),(float)(128*ctf_scl), 1065, VIRTH/2/3*2, 11, 1.0/2.0); + drawicon((float)(rb_opposite(rb_team_int(player1->team))*128*ctf_scl),(float)(128*ctf_scl), 1065, VIRTH/2/3*2, flagtex, 1.0/2.0); glPopMatrix(); }; }; @@ -671,6 +669,9 @@ void addgib(dynent *d) void loadingscreen() { + static Texture *logo = NULL; + if(!logo) logo = textureload("packages/misc/full_logo.png", false, true); + glPushMatrix(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); @@ -679,7 +680,7 @@ void loadingscreen() glEnable(GL_TEXTURE_2D); glColor3f(1, 1, 1); - glBindTexture(GL_TEXTURE_2D, 8); + glBindTexture(GL_TEXTURE_2D, logo->id); loopi(2) { diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index bc7701d6..4606ac40 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -12,7 +12,6 @@ bool hasoverbright = false; -GLUquadricObj *qsphere = NULL; int glmaxtexsize = 256; void gl_init(int w, int h, int bpp, int depth, int fsaa) @@ -46,29 +45,35 @@ void gl_init(int w, int h, int bpp, int depth, int fsaa) else conoutf("WARNING: cannot use overbright lighting, using old lighting model!"); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize); - - if(!(qsphere = gluNewQuadric())) fatal("glu sphere"); + + GLUquadricObj *qsphere = gluNewQuadric(); + if(!qsphere) fatal("glu sphere"); gluQuadricDrawStyle(qsphere, GLU_FILL); gluQuadricOrientation(qsphere, GLU_INSIDE); gluQuadricTexture(qsphere, GL_TRUE); glNewList(1, GL_COMPILE); gluSphere(qsphere, 1, 12, 6); glEndList(); + gluDeleteQuadric(qsphere); if(fsaa) glEnable(GL_MULTISAMPLE); }; +Texture *crosshair = NULL; +hashtable textures; + void cleangl() { - if(qsphere) gluDeleteQuadric(qsphere); }; -bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp, bool highqual) +GLuint installtex(const char *texname, int &xs, int &ys, bool clamp, bool highqual) { SDL_Surface *s = IMG_Load(texname); - if(!s) { conoutf("couldn't load texture %s", texname); return false; }; - if(s->format->BitsPerPixel!=24 && s->format->BitsPerPixel!=32) { conoutf("texture must be 24bpp or 32bpp: %s", texname); return false; }; + if(!s) { conoutf("couldn't load texture %s", texname); return 0; }; + if(s->format->BitsPerPixel!=24 && s->format->BitsPerPixel!=32) { conoutf("texture must be 24bpp or 32bpp: %s", texname); return 0; }; // loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; }; + GLuint tnum; + glGenTextures(1, &tnum); glBindTexture(GL_TEXTURE_2D, tnum); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT); @@ -85,41 +90,35 @@ bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp, bool high { conoutf("warning: quality loss: scaling %s", texname); // for voodoo cards under linux scaledimg = new uchar[xs*ys*s->format->BitsPerPixel/8]; - gluScaleImage(mode, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, xs, ys, GL_UNSIGNED_BYTE, scaledimg); + if(gluScaleImage(mode, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, xs, ys, GL_UNSIGNED_BYTE, scaledimg)) + { + xs = s->w; + ys = s->h; + }; }; if(gluBuild2DMipmaps(GL_TEXTURE_2D, mode, xs, ys, mode, GL_UNSIGNED_BYTE, scaledimg)) fatal("could not build mipmaps"); if(xs!=s->w) delete[] scaledimg; SDL_FreeSurface(s); - return true; + return tnum; }; // management of texture slots // each texture slot can have multople texture frames, of which currently only the first is used // additional frames can be used for various shaders -const int FIRSTTEX = 160; // opengl id = loaded id + FIRSTTEX -// std 1+, sky 14+, md3's 30+,md2's 40+ - -struct Texture -{ - string name; - int xs, ys; - GLuint id; -}; -vector textures; - -Texture *textureload(const char *name) +Texture *textureload(const char *name, bool clamp, bool highqual) { - loopv(textures) - { - Texture *t = textures[i]; - if(!strcmp(t->name, name)) return t; - }; - int id = FIRSTTEX+textures.length(), xs, ys; - s_sprintfd(pname)("packages%ctextures%c%s", PATHDIV, PATHDIV, name); - if(!installtex(id, pname, xs, ys)) return NULL; - Texture *t = textures.add(new Texture); - s_strcpy(t->name, name); + string pname; + s_strcpy(pname, name); + path(pname); + Texture *t = textures.access(pname); + if(t) return t; + int xs, ys; + GLuint id = installtex(pname, xs, ys, clamp, highqual); + if(!id) return crosshair; + char *key = newstring(pname); + t = &textures[key]; + t->name = key; t->xs = xs; t->ys = ys; t->id = id; @@ -151,27 +150,22 @@ COMMAND(texture, ARG_2STR); int lookuptexture(int tex, int &xs, int &ys) { - if(!slots.inrange(tex)) + Texture *t = crosshair; + if(slots.inrange(tex)) { - xs = ys = 16; - return 1; // crosshair :) + Slot &s = slots[tex]; + if(!s.loaded) + { + s_sprintfd(pname)("packages%ctextures%c%s", PATHDIV, PATHDIV, s.name); + s.tex = textureload(pname); + s.loaded = true; + }; + if(s.tex) t = s.tex; }; - Slot &s = slots[tex]; - if(!s.loaded) - { - s.tex = textureload(s.name); - s.loaded = true; - }; - if(!s.tex) - { - xs = ys = 16; - return 1; // crosshair :) - }; - - xs = s.tex->xs; - ys = s.tex->ys; - return s.tex->id; + xs = t->xs; + ys = t->ys; + return t->id; }; void setupworld() @@ -376,7 +370,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps) glColor3f(1.0f, 1.0f, 1.0f); glDisable(GL_FOG); glDepthFunc(GL_GREATER); - draw_envbox(14, fog*4/3); + draw_envbox(fog*4/3); glDepthFunc(GL_LESS); glEnable(GL_FOG); diff --git a/source/src/rendermd2.cpp b/source/src/rendermd2.cpp index 196e3741..80a5612d 100644 --- a/source/src/rendermd2.cpp +++ b/source/src/rendermd2.cpp @@ -74,14 +74,14 @@ struct md2 mapmodelinfo mmi; char *loadname; - int mdlnum; + Texture *skin; bool loaded; bool load(char* filename); void render(vec &light, int numFrame, int range, float x, float y, float z, float yaw, float pitch, float scale, float speed, int snap, int basetime, dynent *d=NULL); void scale(int frame, float scale, int sn); - md2() : numGlCommands(0), frameSize(0), numFrames(0), displaylist(0), loaded(false) {}; + md2() : numGlCommands(0), frameSize(0), numFrames(0), displaylist(0), skin(NULL), loaded(false) {}; ~md2() { @@ -89,7 +89,7 @@ struct md2 delete [] glCommands; if(frames) delete [] frames; - } + }; }; @@ -272,8 +272,7 @@ void delayedload(md2 *m) s_sprintfd(name1)("packages/models/%s/tris.md2", m->loadname); if(!m->load(path(name1))) fatal("loadmodel: ", name1); s_sprintfd(name2)("packages/models/%s/skin.jpg", m->loadname); - int xs, ys; - installtex(FIRSTMDL+m->mdlnum, path(name2), xs, ys); + m->skin = textureload(name2, true); m->loaded = true; }; }; @@ -287,7 +286,6 @@ md2 *loadmodel(char *name) md2 **mm = mdllookup->access(name); if(mm) return *mm; md2 *m = new md2(); - m->mdlnum = modelnum++; mapmodelinfo mmi = { 2, 2, 0, 0, "" }; m->mmi = mmi; m->loadname = newstring(name); @@ -324,7 +322,7 @@ void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, f delayedload(m); int xs, ys; - glBindTexture(GL_TEXTURE_2D, tex ? lookuptexture(tex, xs, ys) : FIRSTMDL+m->mdlnum); + glBindTexture(GL_TEXTURE_2D, tex ? lookuptexture(tex, xs, ys) : m->skin->id); int ix = (int)x; int iy = (int)z; @@ -363,6 +361,7 @@ void preload_mapmodels() if(!&mmi) continue; md2 *m = loadmodel(mmi.name); delayedload(m); - lookuptexture(e.attr4 ? lookuptexture(e.attr4, xs, ys) : FIRSTMDL+m->mdlnum, xs, ys); - } -} + if(e.attr4) lookuptexture(e.attr4, xs, ys); + }; +}; + diff --git a/source/src/rendermd3.cpp b/source/src/rendermd3.cpp index d4116f88..317f2d80 100644 --- a/source/src/rendermd3.cpp +++ b/source/src/rendermd3.cpp @@ -67,7 +67,7 @@ struct md3mesh vec *vertices; vec2 *uv; int numtriangles, numvertices; // numvertices == numUV - int tex; + Texture *skin; }; struct md3model @@ -249,7 +249,7 @@ void md3model::render() { md3mesh *mesh = &meshes[i]; - glBindTexture(GL_TEXTURE_2D, FIRSTMD3 + mesh->tex); + glBindTexture(GL_TEXTURE_2D, mesh->skin->id); glBegin(GL_TRIANGLES); loopj(mesh->numtriangles) // triangles @@ -325,7 +325,6 @@ void md3setanim(dynent *d, int anim) vector models; vector tmp_animations; int firstweapon = -1; -int numskins = 0; string basedir; // necessary for relative path's void md3skin(char *objname, char *skin) // called by the {lower|upper|head}.cfg (originally .skin in Q3A) @@ -336,12 +335,9 @@ void md3skin(char *objname, char *skin) // called by the {lower|upper|head}.cfg md3mesh *mesh = &mdl->meshes[i]; if(strcmp(mesh->name, objname) == 0) { - int xs, ys; s_sprintfd(path)("%s/%s", basedir, skin); // 'skin' is a relative url bool highqual = strstr(basedir, "weapons") != NULL; - installtex(FIRSTMD3 + numskins, path, xs, ys, true, highqual); - mesh->tex = numskins; - numskins++; + mesh->skin = textureload(path, true, highqual); }; }; }; diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index 71ca51a8..65c94a3a 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -48,7 +48,7 @@ void render_particles(int time) if(demoplayback && demotracking) { vec nom = { 0, 0, 0 }; - newparticle(player1->o, nom, 100000000, 8); + newparticle(player1->o, nom, 100000000, 4); }; if(!parlist) return; @@ -58,17 +58,21 @@ void render_particles(int time) glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); glDisable(GL_FOG); + static Texture *parttex[4] = {NULL, NULL, NULL, NULL}; + if(!parttex[0]) parttex[0] = textureload("packages/misc/base.png"); + if(!parttex[1]) parttex[1] = textureload("packages/misc/smoke.png"); struct parttype { float r, g, b; int gr, tex; float sz; } parttypes[] = { - { 0.2f, 0.2f, 0.2f, 2, 3, 0.06f }, // yellow: sparks - { 0.5f, 0.5f, 0.5f, 20, 7, 0.15f }, // grey: small smoke - { 0.2f, 0.2f, 1.0f, 20, 3, 0.08f }, // blue: edit mode entities - { 1.0f, 0.1f, 0.1f, 1, 7, 0.06f }, // red: blood spats - { 1.0f, 0.8f, 0.8f, 20, 6, 1.2f }, // yellow: fireball1 - { 0.5f, 0.5f, 0.5f, 20, 7, 0.6f }, // grey: big smoke - { 1.0f, 1.0f, 1.0f, 20, 8, 1.2f }, // blue: fireball2 - { 1.0f, 1.0f, 1.0f, 20, 9, 1.2f }, // green: fireball3 - { 1.0f, 0.1f, 0.1f, 0, 7, 0.2f }, // red: demotrack + { 0.2f, 0.2f, 0.2f, 2, 0, 0.06f }, // yellow: sparks + { 0.5f, 0.5f, 0.5f, 20, 1, 0.15f }, // grey: small smoke + { 0.2f, 0.2f, 1.0f, 20, 0, 0.08f }, // blue: edit mode entities + { 1.0f, 0.1f, 0.1f, 1, 1, 0.06f }, // red: blood spats + { 1.0f, 0.1f, 0.1f, 0, 1, 0.2f }, // red: demotrack + +// { 1.0f, 0.8f, 0.8f, 20, 6, 1.2f }, // yellow: fireball1 +// { 0.5f, 0.5f, 0.5f, 20, 1, 0.6f }, // grey: big smoke +// { 1.0f, 1.0f, 1.0f, 20, 8, 1.2f }, // blue: fireball2 +// { 1.0f, 1.0f, 1.0f, 20, 9, 1.2f }, // green: fireball3 // { 1.0f, 1.0f, 1.0f, 2, 3, 0.06f }, // }; @@ -78,22 +82,22 @@ void render_particles(int time) for(particle *p, **pp = &parlist; p = *pp;) { // if(p->type==9 && p->tex!=-1) parttypes[9].tex = p->tex; // hack, AH - parttype *pt = &parttypes[p->type]; + parttype &pt = parttypes[p->type]; - if(pt!=lastpt) + if(&pt!=lastpt) { - if(!lastpt || pt->tex!=lastpt->tex) + if(!lastpt || pt.tex!=lastpt->tex) { if(lastpt) glEnd(); - glBindTexture(GL_TEXTURE_2D, pt->tex); + glBindTexture(GL_TEXTURE_2D, parttex[pt.tex]->id); glBegin(GL_QUADS); }; - if(!lastpt || pt->r!=lastpt->r || pt->g!=lastpt->g || pt->b!=lastpt->b) - glColor3f(pt->r, pt->g, pt->b); - lastpt = pt; + if(!lastpt || pt.r!=lastpt->r || pt.g!=lastpt->g || pt.b!=lastpt->b) + glColor3f(pt.r, pt.g, pt.b); + lastpt = &pt; }; - float sz = pt->sz*particlesize/100.0f; + float sz = pt.sz*particlesize/100.0f; // perf varray? glTexCoord2i(0, 1); glVertex3f(p->o.x+(-right.x+up.x)*sz, p->o.z+(-right.y+up.y)*sz, p->o.y+(-right.z+up.z)*sz); glTexCoord2i(1, 1); glVertex3f(p->o.x+( right.x+up.x)*sz, p->o.z+( right.y+up.y)*sz, p->o.y+( right.z+up.z)*sz); @@ -109,7 +113,7 @@ void render_particles(int time) } else { - if(pt->gr) p->o.z -= ((lastmillis-p->millis)/3.0f)*curtime/(pt->gr*10000); + if(pt.gr) p->o.z -= ((lastmillis-p->millis)/3.0f)*curtime/(pt.gr*10000); vec a = p->d; vmul(a, time); vdiv(a, 20000.0f);