diff --git a/engine/client/p_script.c b/engine/client/p_script.c index b73a0ecbd..6a00aba29 100644 --- a/engine/client/p_script.c +++ b/engine/client/p_script.c @@ -67,6 +67,7 @@ typedef struct particle_s vec3_t rgb; float alpha; float scale; + float s1, t1, s2, t2; vec3_t vel; //renderer uses for sparks float angle; @@ -118,7 +119,8 @@ typedef struct skytris_s { struct msurface_s *face; } skytris_t; -//these are the details of each particle which are exposed at render time - things that are static +//these is the required render state for each particle +//dynamic per-particle stuff isn't important. only static state. typedef struct { enum {PT_NORMAL, PT_SPARK, PT_SPARKFAN, PT_TEXTUREDSPARK, PT_BEAM, PT_DECAL} type; @@ -161,7 +163,12 @@ typedef struct part_type_s { float offsetspreadvert; float randomvelvert; float randscale; + + float s1, t1, s2, t2; + float texsstride; //addition for s for each random slot. + int randsmax; //max times the stride can be added + plooks_t *slooks; //shared looks, so state switches don't apply between particles so much plooks_t looks; float spawntime; @@ -276,6 +283,8 @@ trailstate_t *trailstates; int ts_cycle; // current cyclic index of trailstates int r_numtrailstates; +static qboolean r_plooksdirty; //a particle effect was changed, reevaluate shared looks. + extern cvar_t r_bouncysparks; extern cvar_t r_part_rain; extern cvar_t r_bloodstains; @@ -377,6 +386,8 @@ static part_type_t *P_GetParticleType(char *name) ptype->ramp = NULL; ptype->particles = NULL; ptype->beams = NULL; + + r_plooksdirty = true; return ptype; } @@ -471,10 +482,17 @@ static void P_LoadTexture(part_type_t *ptype, qboolean warn) if (!ptype->looks.texturenum) { + //note that this could get messy if you depend upon vid_restart to reload your effect without re-execing it after. + ptype->s1 = 0; + ptype->t1 = 0; + ptype->s2 = 1; + ptype->t2 = 1; + ptype->randsmax = 1; + if (warn) Con_DPrintf("Couldn't load texture %s for particle effect %s\n", ptype->texname, ptype->name); - if (strstr(ptype->texname, "glow") || strstr(ptype->texname, "ball")) + if (strstr(ptype->texname, "glow") || strstr(ptype->texname, "ball") || ptype->looks.type == PT_TEXTUREDSPARK) ptype->looks.texturenum = balltexture; else ptype->looks.texturenum = explosiontexture; @@ -610,6 +628,10 @@ static void P_ParticleEffect_f(void) ptype->rotationstartrand = M_PI-ptype->rotationstartmin; ptype->spawnchance = 1; + ptype->randsmax = 1; + ptype->s2 = 1; + ptype->t2 = 1; + while(1) { buf = Cbuf_GetNext(Cmd_ExecLevel); @@ -632,6 +654,25 @@ static void P_ParticleEffect_f(void) // parse speed if (!strcmp(var, "texture")) Q_strncpyz(ptype->texname, value, sizeof(ptype->texname)); + else if (!strcmp(var, "tcoords")) + { + float tscale; + + tscale = atof(Cmd_Argv(5)); + if (tscale < 0) + tscale = 1; + + ptype->s1 = atof(value)/tscale; + ptype->t1 = atof(Cmd_Argv(2))/tscale; + ptype->s2 = atof(Cmd_Argv(3))/tscale; + ptype->t2 = atof(Cmd_Argv(4))/tscale; + + ptype->randsmax = atoi(Cmd_Argv(6)); + ptype->texsstride = atof(Cmd_Argv(7)); + + if (ptype->randsmax < 1 || ptype->texsstride == 0) + ptype->randsmax = 1; + } else if (!strcmp(var, "rotationstart")) { ptype->rotationstartmin = atof(value)*M_PI/180; @@ -1123,6 +1164,8 @@ static void P_ParticleEffect_f(void) } P_LoadTexture(ptype, true); + + r_plooksdirty = true; } //assosiate a point effect with a model. @@ -2148,6 +2191,16 @@ static int PScript_RunParticleEffectState (vec3_t org, vec3_t dir, float count, p->rotationspeed = ptype->rotationmin + frandom()*ptype->rotationrand; p->angle = ptype->rotationstartmin + frandom()*ptype->rotationstartrand; + p->s1 = ptype->s1; + p->t1 = ptype->t1; + p->s2 = ptype->s2; + p->t2 = ptype->t2; + if (ptype->randsmax!=1) + { + m = ptype->texsstride * (rand()%ptype->randsmax); + p->s1 += m; + p->s2 += m; + } if (ptype->colorindex >= 0) { @@ -2873,6 +2926,17 @@ static void P_ParticleTrailDraw (vec3_t startpos, vec3_t end, part_type_t *ptype p->rotationspeed = ptype->rotationmin + frandom()*ptype->rotationrand; p->angle = ptype->rotationstartmin + frandom()*ptype->rotationstartrand; + p->s1 = ptype->s1; + p->t1 = ptype->t1; + p->s2 = ptype->s2; + p->t2 = ptype->t2; + if (ptype->randsmax!=1) + { + float offs; + offs = ptype->texsstride * (rand()%ptype->randsmax); + p->s1 += offs; + p->s2 += offs; + } if (len < nrfirst || len >= nrlast) { @@ -3161,13 +3225,13 @@ static void GL_DrawTexturedParticle(int count, particle_t **plist, plooks_t *typ x = 0; y = scale; } - qglTexCoord2f(0,0); + qglTexCoord2f(p->s1,p->t1); qglVertex3f (p->org[0] - x*pright[0] - y*pup[0], p->org[1] - x*pright[1] - y*pup[1], p->org[2] - x*pright[2] - y*pup[2]); - qglTexCoord2f(0,1); + qglTexCoord2f(p->s1,p->t2); qglVertex3f (p->org[0] - y*pright[0] + x*pup[0], p->org[1] - y*pright[1] + x*pup[1], p->org[2] - y*pright[2] + x*pup[2]); - qglTexCoord2f(1,1); + qglTexCoord2f(p->s2,p->t2); qglVertex3f (p->org[0] + x*pright[0] + y*pup[0], p->org[1] + x*pright[1] + y*pup[1], p->org[2] + x*pright[2] + y*pup[2]); - qglTexCoord2f(1,0); + qglTexCoord2f(p->s2,p->t1); qglVertex3f (p->org[0] + y*pright[0] - x*pup[0], p->org[1] + y*pright[1] - x*pup[1], p->org[2] + y*pright[2] - x*pup[2]); } qglEnd(); @@ -3183,7 +3247,6 @@ static void GL_DrawSketchParticle(int count, particle_t **plist, plooks_t *type) int quant; qglDisable(GL_TEXTURE_2D); - GL_Bind(type->texturenum); // if (type->blendmode == BM_ADD) //addative // glBlendFunc(GL_SRC_ALPHA, GL_ONE); // else if (type->blendmode == BM_SUBTRACT) //subtractive @@ -3282,7 +3345,6 @@ static void GL_DrawLineSparkParticle(int count, particle_t **plist, plooks_t *ty particle_t *p; qglDisable(GL_TEXTURE_2D); - GL_Bind(type->texturenum); APPLYBLEND(type->blendmode); qglShadeModel(GL_SMOOTH); qglBegin(GL_LINES); @@ -3332,10 +3394,10 @@ static void GL_DrawTexturedSparkParticle(int count, particle_t **plist, plooks_t VectorNormalize(cr); VectorMA(p->org, -p->scale/2, cr, point); - qglTexCoord2f(0, 0); + qglTexCoord2f(p->s1, p->t1); qglVertex3fv(point); VectorMA(p->org, p->scale/2, cr, point); - qglTexCoord2f(0, 1); + qglTexCoord2f(p->s1, p->t2); qglVertex3fv(point); @@ -3346,10 +3408,10 @@ static void GL_DrawTexturedSparkParticle(int count, particle_t **plist, plooks_t VectorNormalize(cr); VectorMA(o2, p->scale/2, cr, point); - qglTexCoord2f(1, 1); + qglTexCoord2f(p->s2, p->t2); qglVertex3fv(point); VectorMA(o2, -p->scale/2, cr, point); - qglTexCoord2f(1, 0); + qglTexCoord2f(p->s2, p->t1); qglVertex3fv(point); } qglEnd(); @@ -3360,7 +3422,6 @@ static void GL_DrawSketchSparkParticle(int count, particle_t **plist, plooks_t * particle_t *p; qglDisable(GL_TEXTURE_2D); - GL_Bind(type->texturenum); APPLYBLEND(type->blendmode); qglShadeModel(GL_SMOOTH); qglBegin(GL_LINES); @@ -3424,10 +3485,10 @@ static void GL_DrawParticleBeam_Textured(int count, beamseg_t **blist, plooks_t ts = c->texture_s*q->angle + particletime*q->rotationspeed; VectorMA(q->org, -q->scale, cr, point); - qglTexCoord2f(ts, 0); + qglTexCoord2f(ts, p->t1); qglVertex3fv(point); VectorMA(q->org, q->scale, cr, point); - qglTexCoord2f(ts, 1); + qglTexCoord2f(ts, p->t2); qglVertex3fv(point); qglColor4f(p->rgb[0], @@ -3441,10 +3502,10 @@ static void GL_DrawParticleBeam_Textured(int count, beamseg_t **blist, plooks_t ts = b->texture_s*p->angle + particletime*p->rotationspeed; VectorMA(p->org, p->scale, cr, point); - qglTexCoord2f(ts, 1); + qglTexCoord2f(ts, p->t2); qglVertex3fv(point); VectorMA(p->org, -p->scale, cr, point); - qglTexCoord2f(ts, 0); + qglTexCoord2f(ts, p->t1); qglVertex3fv(point); } qglEnd(); @@ -3463,7 +3524,6 @@ static void GL_DrawParticleBeam_Untextured(int count, beamseg_t **blist, plooks_ qglDisable(GL_TEXTURE_2D); - GL_Bind(type->texturenum); APPLYBLEND(type->blendmode); qglShadeModel(GL_SMOOTH); qglBegin(GL_QUADS); @@ -3731,6 +3791,25 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t int traces=r_particle_tracelimit.value; int rampind; + if (r_plooksdirty) + { + int i, j; + for (i = 0; i < numparticletypes; i++) + { + //set the fallback + part_type[i].slooks = &part_type[i].looks; + for (j = i-1; j-- > 0;) + { + if (!memcmp(&part_type[i].looks, &part_type[j].looks, sizeof(plooks_t))) + { + part_type[i].slooks = part_type[j].slooks; + break; + } + } + } + r_plooksdirty = false; + } + pframetime = host_frametime; if (cl.paused || r_secondaryview) pframetime = 0; @@ -3881,7 +3960,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t while ((p=type->particles)) { if (pdraw) - RQ_AddDistReorder(pdraw, p, &type->looks, p->org); + RQ_AddDistReorder(pdraw, p, type->slooks, p->org); // make sure emitter runs at least once if (type->emit >= 0 && type->emitstart <= 0) @@ -3935,7 +4014,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t VectorAdd(stop, oldorg, stop); VectorScale(stop, 0.5, stop); - RQ_AddDistReorder(bdraw, b, &type->looks, stop); + RQ_AddDistReorder(bdraw, b, type->slooks, stop); } } @@ -4144,7 +4223,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t } if (pdraw) - RQ_AddDistReorder((void*)pdraw, p, &type->looks, p->org); + RQ_AddDistReorder((void*)pdraw, p, type->slooks, p->org); } // beams are dealt with here @@ -4204,7 +4283,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t VectorAdd(stop, oldorg, stop); VectorScale(stop, 0.5, stop); - RQ_AddDistReorder(bdraw, b, &type->looks, stop); + RQ_AddDistReorder(bdraw, b, type->slooks, stop); } } diff --git a/engine/client/r_partset.c b/engine/client/r_partset.c index bca269324..ac1bd40a1 100644 --- a/engine/client/r_partset.c +++ b/engine/client/r_partset.c @@ -6,9 +6,27 @@ char *particle_set_spikeset = // and some others I probably forgot to mention ///////////////////////////////////////////////// //rocket trails (derived from purplehaze's, with only minor tweeks) + +"r_part rocketsmoke\n" +"{\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" +"step 8\n" +"scale 7.5\n" +"alpha 0.8\n" +"die 2\n" +"randomvel 3\n" +"rgb 10 10 10\n" +"blend modulate\n" +"spawnmode spiral\n" +"scalefactor 1\n" +"spawnvel 5\n" +"}\n" + "r_part rockettrail\n" "{\n" -"texture \"particles/smoke.tga\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "step 4\n" "scale 30\n" "alpha 0.3\n" @@ -20,11 +38,13 @@ char *particle_set_spikeset = "gravity -25\n" "scalefactor 1\n" "assoc rocketsmoke\n" +"spawnvel 10\n" "}\n" "r_part t_rocket\n" "{\n" -"texture \"particles/rfire\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "step 2\n" "scale 10\n" "alpha 0.6\n" @@ -37,24 +57,10 @@ char *particle_set_spikeset = "scaledelta -10\n" "}\n" -"r_part rocketsmoke\n" -"{\n" -"texture \"particles/rtrail\"\n" -"step 8\n" -"scale 7.5\n" -"alpha 0.8\n" -"die 2\n" -"randomvel 3\n" -"rgb 10 10 10\n" -"blend modulate\n" -"spawnmode spiral\n" -"scalefactor 1\n" -"spawnvel 10\n" -"}\n" - "r_part rockettail\n" "{\n" -"texture \"particles/rtrail\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "step 7\n" "scale 10\n" "alpha 0.3\n" @@ -68,7 +74,8 @@ char *particle_set_spikeset = "r_part t_altrocket\n" "{\n" -"texture \"particles/rtrail\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "step 4\n" "scale 10\n" "alpha 0.3\n" @@ -163,7 +170,8 @@ char *particle_set_spikeset = "r_part shortfume\n" "{\n" -"texture \"particles/smoke\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "scale 15\n" "scaledelta 20\n" "alpha 0.5\n" @@ -176,7 +184,8 @@ char *particle_set_spikeset = "r_part t_grenade\n" "{\n" -"texture \"particles/smoke\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "step 24\n" "scale 16\n" "scaledelta 4\n" @@ -194,7 +203,8 @@ char *particle_set_spikeset = //cool's blood trails (cos they're cooler) "r_part t_gib\n" "{\n" -"texture \"particles/blood\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 1 63 63 256 2 64\n" "step 32\n" "scale 64\n" "alpha 0.6\n" @@ -212,7 +222,8 @@ char *particle_set_spikeset = "r_part t_zomgib\n" "{\n" -"texture \"particles/blood\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 1 63 63 256 2 64\n" "step 64\n" "scale 64\n" "alpha 0.6\n" @@ -230,7 +241,8 @@ char *particle_set_spikeset = "r_part t_tracer\n" "{\n" -"texture \"particles/tracer\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "scale 15\n" "step 5\n" "alpha 0.6\n" @@ -244,7 +256,8 @@ char *particle_set_spikeset = "r_part t_tracer2\n" "{\n" -"texture \"particles/tracer\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "scale 15\n" "step 5\n" "alpha 0.6\n" @@ -258,7 +271,8 @@ char *particle_set_spikeset = "r_part t_tracer3\n" "{\n" -"texture \"particles/tracer\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "scale 10\n" "scaledelta -10\n" "step 5\n" @@ -276,7 +290,8 @@ char *particle_set_spikeset = //qw blood "r_part te_lightningblood\n" "{\n" -"texture \"particles/bloodtrail\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 97 255 159 256\n" "count 3\n" "scale 20\n" "alpha 0.4\n" @@ -294,7 +309,8 @@ char *particle_set_spikeset = //qw blood "r_part te_blood\n" "{\n" -"texture \"particles/blood\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 97 255 159 256\n" "count 10\n" "scale 10\n" "alpha 0.3\n" @@ -311,7 +327,8 @@ char *particle_set_spikeset = //nq blood "r_part pe_73\n" "{\n" -"texture \"particles/blood\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 97 255 159 256\n" "count 1\n" "scale 20\n" "alpha 0.3\n" @@ -330,7 +347,8 @@ char *particle_set_spikeset = "r_part ember\n" "{\n" "count 1\n" -"texture \"particles/explosion\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "rgb 255 128 76\n" "alpha 0\n" "scale 15\n" @@ -354,7 +372,8 @@ char *particle_set_spikeset = "r_part expgib\n" "{\n" "cliptype expgib\n" -"texture \"particles/explosion\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "alpha 0\n" "count 16\n" "die 1\n" @@ -369,7 +388,8 @@ char *particle_set_spikeset = //the heart of the explosion "r_part te_explosion\n" "{\n" -"texture \"particles/explosion\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "count 1\n" "scale 200\n" "scalefactor 1\n" @@ -383,7 +403,8 @@ char *particle_set_spikeset = "r_part gunshotsmoke\n" "{\n" -"texture \"particles/smoke\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 65 31 95 256 8 32\n" "count 3\n" "scale 25\n" "scalefactor 1\n" @@ -400,7 +421,8 @@ char *particle_set_spikeset = "r_part te_gunshot\n" "{\n" "type texturedspark\n" -"texture \"ball\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 65 31 95 256 8 32\n" "count 3\n" "scale 2\n" "scalefactor 1\n" @@ -419,7 +441,8 @@ char *particle_set_spikeset = "r_part spikecore\n" "{\n" -"texture \"ball\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "count 1\n" "scale 1\n" "scalefactor 1\n" @@ -449,7 +472,8 @@ char *particle_set_spikeset = "r_part te_lavasplash\n" "{\n" -"texture \"default\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 129 1 191 63 256\n" "count 654\n" "scale 15\n" "alpha 0.7\n" @@ -468,7 +492,8 @@ char *particle_set_spikeset = //two rings moving upwards, costs less "r_part teleportsplashdown\n" "{\n" -"texture \"textures/smoke\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 1 255 63 256\n" "count 32\n" "scale 32\n" "scalefactor 1\n" @@ -482,7 +507,8 @@ char *particle_set_spikeset = "}\n" "r_part te_teleportsplash\n" "{\n" -"texture \"textures/smoke\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 1 255 63 256\n" "count 32\n" "scale 32\n" "scalefactor 1\n" @@ -499,7 +525,8 @@ char *particle_set_spikeset = //flame effect "r_part cu_flame\n" "{\n" -"texture \"particles/flame\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 129 1 191 63 256\n" "count 1024\n" "scale 0.4\n" "scalerand 6\n" @@ -518,7 +545,8 @@ char *particle_set_spikeset = //flame effect "r_part cu_torch\n" "{\n" -"texture \"particles/flame\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 129 1 191 63 256\n" "count 256\n" "scale 3\n" "scalefactor 1\n" @@ -535,7 +563,8 @@ char *particle_set_spikeset = "r_part explodesprite\n" "{\n" -"texture \"particles/flame\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 97 97 191 191 256\n" "count 180\n" "scale 70\n" "scaledelta -140\n" @@ -554,7 +583,8 @@ char *particle_set_spikeset = //you'll probably never see this one "r_part ef_entityparticles\n" "{\n" -"texture \"j\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "count 1\n" "scale 15\n" "alpha 0.2\n" @@ -567,7 +597,8 @@ char *particle_set_spikeset = // emp effect, based off of purplehaze's idea "r_part empshocktrail\n" "{\n" -"texture \"particles/spark\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 1 255 63 256\n" "step 3.2\n" "scale 3\n" "alpha 0.7\n" @@ -580,7 +611,8 @@ char *particle_set_spikeset = "r_part empcore\n" "{\n" -"texture \"particles/flame\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 1 255 63 256\n" "count 90\n" "scale 55\n" "scaledelta -110\n" @@ -599,7 +631,8 @@ char *particle_set_spikeset = "r_part empflash\n" "{\n" "die 0.1\n" -"texture \"particles/flash\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 193 1 255 63 256\n" "alpha 1\n" "count 1\n" "scale 400\n" @@ -613,7 +646,8 @@ char *particle_set_spikeset = "r_part te_tarexplosion\n" "{\n" -"texture \"particles/emp\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "count 120\n" "scale 35\n" "die 0.75\n" @@ -636,7 +670,8 @@ char *particle_set_spikeset = "r_part pe_default\n" "{\n" -"texture \"particles/quake\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "count 1\n" "scale 4\n" "veladd 15\n" @@ -649,7 +684,8 @@ char *particle_set_spikeset = "r_part pe_defaulttrail\n" "{\n" -"texture \"particles/quake\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "step 12\n" "die 1\n" "scale 10\n" @@ -661,7 +697,8 @@ char *particle_set_spikeset = "r_part pe_pointfile\n" "{\n" -"texture \"particles/quake\"\n" +"texture \"particles/fteparticlefont.tga\"\n" +"tcoords 1 97 95 191 256\n" "count 1\n" "scale 50\n" "die 30\n" @@ -676,6 +713,10 @@ char *particle_set_spikeset = "r_effect \"progs/flame.mdl\" cu_torch\n" "r_trail \"progs/e_spike1.mdl\" te_railtrail\n"; + + +/////////////////////////////////////////////////////// + char *particle_set_faithful = // faithful, by TimeServ "r_part t_gib\n" diff --git a/engine/client/renderer.c b/engine/client/renderer.c index ea0f7c857..18529d1b4 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -354,7 +354,7 @@ cvar_t r_shadow_realtime_world_lightmaps = SCVARF ("r_shadow_realtime_world_ligh CVAR_CHEAT); cvar_t r_shadows = SCVARF ("r_shadows", "0", CVAR_ARCHIVE | CVAR_RENDERERLATCH); -cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "1"); +cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "0"); cvar_t vid_preservegamma = SCVAR ("vid_preservegamma", "0"); cvar_t vid_hardwaregamma = SCVARF ("vid_hardwaregamma", "1", @@ -2601,8 +2601,8 @@ void R_MarkLeaves_Q1 (void) else if (r_viewleaf2 && r_viewleaf2 != r_viewleaf) { int c; - Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf2, fatvis); - vis = Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf, NULL); + Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf2, fatvis, sizeof(fatvis)); + vis = Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf, NULL, 0); c = (cl.worldmodel->numleafs+31)/32; for (i=0 ; inumleafs ; i++) { diff --git a/engine/client/textedit.c b/engine/client/textedit.c index 28a153ea0..de264a9c8 100644 --- a/engine/client/textedit.c +++ b/engine/client/textedit.c @@ -35,7 +35,7 @@ typedef struct fileblock_s { } fileblock_t; #define FB_BREAK 1 -fileblock_t *cursorblock, *firstblock, *executionblock, *viewportystartblock; +static fileblock_t *cursorblock, *firstblock, *executionblock, *viewportystartblock; void *E_Malloc(int size) { diff --git a/engine/common/q1bsp.c b/engine/common/q1bsp.c index 10aa43def..069ca6b3d 100644 --- a/engine/common/q1bsp.c +++ b/engine/common/q1bsp.c @@ -1,6 +1,5 @@ #include "quakedef.h" -qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer); /* ============================================================================ @@ -873,7 +872,7 @@ void SV_Q1BSP_AddToFatPVS (model_t *mod, vec3_t org, mnode_t *node, qbyte *buffe { if (node->contents != Q1CONTENTS_SOLID) { - pvs = Q1BSP_LeafPVS (mod, (mleaf_t *)node, NULL); + pvs = Q1BSP_LeafPVS (mod, (mleaf_t *)node, NULL, 0); for (i=0; inumleafs+7)>>3; out = decompressed; + if (buffersize < row) + row = buffersize; + #if 0 memcpy (out, in, row); #else @@ -1041,7 +1043,7 @@ qbyte *Q1BSP_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed) static qbyte mod_novis[MAX_MAP_LEAFS/8]; -qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer) +qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize) { static qbyte decompressed[MAX_MAP_LEAFS/8]; @@ -1050,14 +1052,17 @@ qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer) return mod_novis; if (!buffer) + { buffer = decompressed; + buffersize = sizeof(decompressed); + } - return Q1BSP_DecompressVis (leaf->compressed_vis, model, buffer); + return Q1BSP_DecompressVis (leaf->compressed_vis, model, buffer, buffersize); } -qbyte *Q1BSP_LeafnumPVS (model_t *model, int leafnum, qbyte *buffer) +qbyte *Q1BSP_LeafnumPVS (model_t *model, int leafnum, qbyte *buffer, unsigned int buffersize) { - return Q1BSP_LeafPVS(model, model->leafs + leafnum, buffer); + return Q1BSP_LeafPVS(model, model->leafs + leafnum, buffer, buffersize); } //returns the leaf number, which is used as a bit index into the pvs. diff --git a/engine/dotnet2005/ftequake.vcproj b/engine/dotnet2005/ftequake.vcproj index 44ef220aa..9a8a5cf43 100644 --- a/engine/dotnet2005/ftequake.vcproj +++ b/engine/dotnet2005/ftequake.vcproj @@ -1083,6 +1083,8 @@ WarningLevel="3" SuppressStartupBanner="true" DebugInformationFormat="4" + CallingConvention="1" + CompileAs="1" DisableSpecificWarnings="4996" /> + + + @@ -6785,6 +6808,14 @@ PrecompiledHeaderThrough="qwsvdef.h" /> + + + @@ -6885,6 +6916,14 @@ PrecompiledHeaderThrough="qwsvdef.h" /> + + + @@ -7544,6 +7583,7 @@ Name="VCCLCompilerTool" AdditionalIncludeDirectories="" PreprocessorDefinitions="" + PrecompiledHeaderThrough="qwsvdef.h" /> @@ -40761,7 +40801,7 @@ > @@ -40778,7 +40818,7 @@ > @@ -40797,7 +40837,7 @@ > @@ -40817,7 +40857,7 @@ > @@ -40835,7 +40875,7 @@ > @@ -40853,7 +40893,7 @@ > @@ -40870,7 +40910,7 @@ > @@ -40889,7 +40929,7 @@ > @@ -40909,7 +40949,7 @@ > @@ -40926,7 +40966,7 @@ > @@ -40946,7 +40986,7 @@ > @@ -40968,7 +41008,7 @@ > @@ -40986,7 +41026,7 @@ > @@ -41003,7 +41043,7 @@ > @@ -41022,7 +41062,7 @@ > @@ -41042,7 +41082,7 @@ > @@ -41060,7 +41100,7 @@ > @@ -41078,7 +41118,7 @@ > @@ -41095,7 +41135,7 @@ > @@ -41114,7 +41154,7 @@ > @@ -41134,7 +41174,7 @@ > @@ -41151,7 +41191,7 @@ > @@ -41171,7 +41211,7 @@ > @@ -41193,7 +41233,7 @@ > @@ -41211,7 +41251,7 @@ > @@ -41228,7 +41268,7 @@ > @@ -41247,7 +41287,7 @@ > @@ -41267,7 +41307,7 @@ > @@ -41285,7 +41325,7 @@ > @@ -41303,7 +41343,7 @@ > @@ -41320,7 +41360,7 @@ > @@ -41339,7 +41379,7 @@ > @@ -41359,7 +41399,7 @@ > @@ -41376,7 +41416,7 @@ > @@ -41396,7 +41436,7 @@ > @@ -41418,7 +41458,7 @@ > @@ -41436,7 +41476,7 @@ > @@ -41453,7 +41493,7 @@ > @@ -41472,7 +41512,7 @@ > @@ -41492,7 +41532,7 @@ > @@ -41510,7 +41550,7 @@ > @@ -41528,7 +41568,7 @@ > @@ -41545,7 +41585,7 @@ > @@ -41564,7 +41604,7 @@ > @@ -41584,7 +41624,7 @@ > @@ -41601,7 +41641,7 @@ > @@ -41621,7 +41661,7 @@ > @@ -41643,7 +41683,7 @@ > @@ -41661,7 +41701,7 @@ > @@ -41678,7 +41718,7 @@ > @@ -41697,7 +41737,7 @@ > @@ -41717,7 +41757,7 @@ > @@ -41735,7 +41775,7 @@ > @@ -41753,7 +41793,7 @@ > @@ -41770,7 +41810,7 @@ > @@ -41789,7 +41829,7 @@ > @@ -41809,7 +41849,7 @@ > @@ -41826,7 +41866,7 @@ > @@ -41846,7 +41886,7 @@ > @@ -41868,7 +41908,7 @@ > @@ -41886,7 +41926,7 @@ > @@ -41903,7 +41943,7 @@ > @@ -41922,7 +41962,7 @@ > @@ -41942,7 +41982,7 @@ > @@ -41960,7 +42000,7 @@ > @@ -41978,7 +42018,7 @@ > @@ -41995,7 +42035,7 @@ > @@ -42014,7 +42054,7 @@ > @@ -42034,7 +42074,7 @@ > @@ -42051,7 +42091,7 @@ > @@ -42071,7 +42111,7 @@ > @@ -42093,7 +42133,7 @@ > @@ -42111,7 +42151,7 @@ > @@ -42128,7 +42168,7 @@ > @@ -42147,7 +42187,7 @@ > @@ -42167,7 +42207,7 @@ > @@ -42185,7 +42225,7 @@ > @@ -42203,7 +42243,7 @@ > @@ -42220,7 +42260,7 @@ > @@ -42239,7 +42279,7 @@ > @@ -42259,7 +42299,7 @@ > @@ -42276,7 +42316,7 @@ > @@ -42296,7 +42336,7 @@ > @@ -42317,7 +42357,7 @@ > @@ -42336,7 +42376,7 @@ > @@ -42355,7 +42395,7 @@ > @@ -42374,7 +42414,7 @@ > @@ -42393,7 +42433,7 @@ > @@ -42412,7 +42452,7 @@ > @@ -42431,7 +42471,7 @@ > @@ -42450,7 +42490,7 @@ > @@ -42469,7 +42509,7 @@ > @@ -42488,7 +42528,7 @@ > @@ -42507,7 +42547,7 @@ > @@ -42526,7 +42566,7 @@ > @@ -42550,7 +42590,7 @@ > @@ -42568,7 +42608,7 @@ > @@ -42585,7 +42625,7 @@ > @@ -42604,7 +42644,7 @@ > @@ -42624,7 +42664,7 @@ > @@ -42642,7 +42682,7 @@ > @@ -42660,7 +42700,7 @@ > @@ -42677,7 +42717,7 @@ > @@ -42696,7 +42736,7 @@ > @@ -42716,7 +42756,7 @@ > @@ -42733,7 +42773,7 @@ > @@ -42753,7 +42793,7 @@ > @@ -42775,7 +42815,7 @@ > @@ -42793,7 +42833,7 @@ > @@ -42810,7 +42850,7 @@ > @@ -42829,7 +42869,7 @@ > @@ -42849,7 +42889,7 @@ > @@ -42867,7 +42907,7 @@ > @@ -42885,7 +42925,7 @@ > @@ -42902,7 +42942,7 @@ > @@ -42921,7 +42961,7 @@ > @@ -42941,7 +42981,7 @@ > @@ -42958,7 +42998,7 @@ > @@ -42978,7 +43018,7 @@ > @@ -43000,7 +43040,7 @@ > @@ -43018,7 +43058,7 @@ > @@ -43035,7 +43075,7 @@ > @@ -43054,7 +43094,7 @@ > @@ -43074,7 +43114,7 @@ > @@ -43092,7 +43132,7 @@ > @@ -43110,7 +43150,7 @@ > @@ -43127,7 +43167,7 @@ > @@ -43146,7 +43186,7 @@ > @@ -43166,7 +43206,7 @@ > @@ -43183,7 +43223,7 @@ > @@ -43203,7 +43243,7 @@ > @@ -43225,7 +43265,7 @@ > @@ -43243,7 +43283,7 @@ > @@ -43260,7 +43300,7 @@ > @@ -43279,7 +43319,7 @@ > @@ -43299,7 +43339,7 @@ > @@ -43317,7 +43357,7 @@ > @@ -43335,7 +43375,7 @@ > @@ -43352,7 +43392,7 @@ > @@ -43371,7 +43411,7 @@ > @@ -43391,7 +43431,7 @@ > @@ -43408,7 +43448,7 @@ > @@ -43428,7 +43468,7 @@ > @@ -43450,7 +43490,7 @@ > @@ -43468,7 +43508,7 @@ > @@ -43485,7 +43525,7 @@ > @@ -43504,7 +43544,7 @@ > @@ -43524,7 +43564,7 @@ > @@ -43542,7 +43582,7 @@ > @@ -43560,7 +43600,7 @@ > @@ -43577,7 +43617,7 @@ > @@ -43596,7 +43636,7 @@ > @@ -43616,7 +43656,7 @@ > @@ -43633,7 +43673,7 @@ > @@ -43653,7 +43693,7 @@ > @@ -43674,7 +43714,7 @@ > @@ -43693,7 +43733,7 @@ > @@ -43712,7 +43752,7 @@ > @@ -43731,7 +43771,7 @@ > @@ -43750,7 +43790,7 @@ > @@ -43769,7 +43809,7 @@ > @@ -43789,7 +43829,7 @@ > @@ -43806,7 +43846,7 @@ > @@ -43825,7 +43865,7 @@ > @@ -43845,7 +43885,7 @@ > @@ -43862,7 +43902,7 @@ > @@ -43881,7 +43921,7 @@ > @@ -43905,7 +43945,7 @@ > @@ -43923,7 +43963,7 @@ > @@ -43940,7 +43980,7 @@ > @@ -43959,7 +43999,7 @@ > @@ -43979,7 +44019,7 @@ > @@ -43997,7 +44037,7 @@ > @@ -44015,7 +44055,7 @@ > @@ -44032,7 +44072,7 @@ > @@ -44051,7 +44091,7 @@ > @@ -44071,7 +44111,7 @@ > @@ -44088,7 +44128,7 @@ > @@ -44108,7 +44148,7 @@ > @@ -44130,7 +44170,7 @@ > @@ -44148,7 +44188,7 @@ > @@ -44165,7 +44205,7 @@ > @@ -44184,7 +44224,7 @@ > @@ -44204,7 +44244,7 @@ > @@ -44222,7 +44262,7 @@ > @@ -44240,7 +44280,7 @@ > @@ -44257,7 +44297,7 @@ > @@ -44276,7 +44316,7 @@ > @@ -44296,7 +44336,7 @@ > @@ -44313,7 +44353,7 @@ > @@ -44333,7 +44373,7 @@ > @@ -44354,7 +44394,7 @@ > @@ -44373,7 +44413,7 @@ > @@ -44392,7 +44432,7 @@ > @@ -44411,7 +44451,7 @@ > @@ -44430,7 +44470,7 @@ > @@ -44449,7 +44489,7 @@ > @@ -44469,7 +44509,7 @@ > @@ -44486,7 +44526,7 @@ > @@ -44505,7 +44545,7 @@ > @@ -44525,7 +44565,7 @@ > @@ -44542,7 +44582,7 @@ > @@ -44561,7 +44601,7 @@ > @@ -44584,7 +44624,7 @@ > @@ -44603,7 +44643,7 @@ > @@ -44622,7 +44662,7 @@ > @@ -44641,7 +44681,7 @@ > @@ -44660,7 +44700,7 @@ > @@ -44679,7 +44719,7 @@ > @@ -44698,7 +44738,7 @@ > @@ -44717,7 +44757,7 @@ > @@ -44736,7 +44776,7 @@ > @@ -44755,7 +44795,7 @@ > @@ -44774,7 +44814,7 @@ > @@ -44793,7 +44833,7 @@ > diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index 433f1d41b..3735e3cc3 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -212,6 +212,7 @@ typedef struct texture_s vbo_t vbo; struct msurface_s *texturechain; // for gl_texsort drawing + struct msurface_s **texturechain_tail; //so we can link them in depth order int anim_total; // total tenths in sequence ( 0 = no) int anim_min, anim_max; // time for this frame min <=time< max struct texture_s *anim_next; // in the animation sequence @@ -448,7 +449,7 @@ qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, unsigned int Q1BSP_FatPVS (struct model_s *mod, vec3_t org, qbyte *pvsbuffer, unsigned int buffersize, qboolean add); qboolean Q1BSP_EdictInFatPVS(struct model_s *mod, struct edict_s *ent, qbyte *pvs); void Q1BSP_FindTouchedLeafs(struct model_s *mod, struct edict_s *ent, float *mins, float *maxs); -qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer); +qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize); /* ============================================================================== diff --git a/engine/gl/gl_ppl.c b/engine/gl/gl_ppl.c index c333ba8ef..5ac6bdc6f 100644 --- a/engine/gl/gl_ppl.c +++ b/engine/gl/gl_ppl.c @@ -379,6 +379,7 @@ static void PPL_BaseChain_NoBump_1TMU(msurface_t *first, texture_t *tex) qglDisableClientState(GL_TEXTURE_COORD_ARRAY); }*/ +#if 0 static void PPL_BaseChain_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex) { //doesn't merge surfaces, but tells gl to do each vertex arrayed surface individually, which means no vertex copying. int vi; @@ -489,19 +490,20 @@ static void PPL_BaseChain_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex) if (tex->alphaed) qglDisable(GL_ALPHA_TEST); } +#endif -static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex) +static void PPL_BaseChain_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex, vbo_t *vbo) { //doesn't merge surfaces, but tells gl to do each vertex arrayed surface individually, which means no vertex copying. int vi; glRect_t *theRect; +// int first = 0, last = 0; - varrayactive = false; qglDisableClientState(GL_COLOR_ARRAY); qglEnableClientState(GL_VERTEX_ARRAY); - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tex->vbo.vboe); + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo->vboe); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbocoord); - qglVertexPointer(3, GL_FLOAT, 0, tex->vbo.coord); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vbocoord); + qglVertexPointer(3, GL_FLOAT, 0, vbo->coord); if (tex->alphaed || currententity->shaderRGBAf[3]<1) { @@ -526,13 +528,13 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t GL_MBind(GL_TEXTURE0_ARB, tex->tn.base); qglEnableClientState(GL_TEXTURE_COORD_ARRAY); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbotexcoord); - qglTexCoordPointer(2, GL_FLOAT, 0, tex->vbo.texcoord); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vbotexcoord); + qglTexCoordPointer(2, GL_FLOAT, 0, vbo->texcoord); GL_SelectTexture(GL_TEXTURE1_ARB); qglEnableClientState(GL_TEXTURE_COORD_ARRAY); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbolmcoord); - qglTexCoordPointer(2, GL_FLOAT, 0, tex->vbo.lmcoord); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vbolmcoord); + qglTexCoordPointer(2, GL_FLOAT, 0, vbo->lmcoord); GL_TexEnv(GL_MODULATE); @@ -562,6 +564,10 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t continue; if (vi != s->lightmaptexturenum) { +// if (last != first) +// qglDrawElements(GL_TRIANGLES, last - first, GL_INDEX_TYPE, (index_t*)(first*sizeof(index_t))); +// last = first; + if (vi<0) qglEnable(GL_TEXTURE_2D); vi = s->lightmaptexturenum; @@ -585,11 +591,22 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t else qglDisable(GL_TEXTURE_2D); } - qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->vbofirstvert+s->mesh->numvertexes-1, s->mesh->numindexes, GL_INDEX_TYPE, (index_t*)(s->mesh->vbofirstelement*sizeof(index_t))); + qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->vbofirstvert+s->mesh->numvertexes-1, s->mesh->numindexes, GL_INDEX_TYPE, vbo->indicies + s->mesh->vbofirstelement); +// if (s->mesh->vbofirstelement != last) +// { +// if (last != first) +// qglDrawElements(GL_TRIANGLES, last - first, GL_INDEX_TYPE, (index_t*)(first*sizeof(index_t))); +// first = s->mesh->vbofirstelement; +// last = first; +// } +// last += s->mesh->numindexes; } +// if (last != first) +// qglDrawElements(GL_TRIANGLES, last - first, GL_INDEX_TYPE, (index_t*)(first*sizeof(index_t))); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + //rebinding vbos is meant to be cheap, thankfully qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); if (overbright != 1) { @@ -605,6 +622,7 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t qglDisableClientState(GL_TEXTURE_COORD_ARRAY); qglDisable(GL_TEXTURE_2D); + if (tex->alphaed) qglDisable(GL_ALPHA_TEST); } @@ -1656,6 +1674,7 @@ static void PPL_BaseChain_NPR_Sketch(msurface_t *first) static void PPL_BaseTextureChain(msurface_t *first) { + texture_t *ot = first->texinfo->texture; texture_t *t; #ifdef Q3SHADERS shader_t *shader; @@ -1681,7 +1700,7 @@ static void PPL_BaseTextureChain(msurface_t *first) } } - t = R_TextureAnimation (first->texinfo->texture); + t = R_TextureAnimation (ot); #ifdef Q3SHADERS shader = t->shader; @@ -1852,10 +1871,8 @@ static void PPL_BaseTextureChain(msurface_t *first) { // PPL_BaseChain_NoBump_2TMU_TEST(first, t); // PPL_BaseChain_NoBump_2TMU(first, t); - if (t->vbo.vbocoord) - PPL_BaseChain_VBO_NoBump_2TMU_Overbright(first, t); - else - PPL_BaseChain_NoBump_2TMU_Overbright(first, t); + PPL_BaseChain_NoBump_2TMU_Overbright(first, t, &ot->vbo); + } } } @@ -1863,10 +1880,11 @@ static void PPL_BaseTextureChain(msurface_t *first) static void PPL_FullBrightTextureChain(msurface_t *first) { + texture_t *ot = first->texinfo->texture; texture_t *t; msurface_t *s; - t = R_TextureAnimation (first->texinfo->texture); + t = R_TextureAnimation (ot); if (detailtexture && gl_detail.value) { @@ -1890,14 +1908,23 @@ static void PPL_FullBrightTextureChain(msurface_t *first) if (gl_mylumassuck.value) qglEnable(GL_ALPHA_TEST); - PPL_EnableVertexArrays(); + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ot->vbo.vboe); + + qglEnableClientState(GL_VERTEX_ARRAY); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, ot->vbo.vbocoord); + qglVertexPointer(3, GL_FLOAT, 0, ot->vbo.coord); + qglEnableClientState(GL_TEXTURE_COORD_ARRAY); - qglTexCoordPointer(2, GL_FLOAT, sizeof(surfvertexarray_t), varray_v->stw); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, ot->vbo.vbotexcoord); + qglTexCoordPointer(2, GL_FLOAT, 0, ot->vbo.texcoord); + for (s = first; s ; s=s->texturechain) { - PPL_GenerateArrays(s); + qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->vbofirstvert+s->mesh->numvertexes-1, s->mesh->numindexes, GL_INDEX_TYPE, ot->vbo.indicies + s->mesh->vbofirstelement); } - PPL_FlushArrays(); + + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); if (gl_mylumassuck.value) qglDisable(GL_ALPHA_TEST); @@ -3355,8 +3382,6 @@ void PPL_FullBrights(model_t *model) continue; // draw translucent water later PPL_FullBrightTextureChain(s); - - t->texturechain=NULL; } GL_TexEnv(GL_REPLACE); @@ -3411,7 +3436,7 @@ void PPL_DrawEntFullBrights(void) int i; currententity = &r_worldentity; -// if (gl_detail.value || (r_fb_bmodels.value && cls.allow_luma)) + if (gl_detail.value || (r_fb_bmodels.value && cls.allow_luma)) PPL_FullBrights(cl.worldmodel); if (!r_drawentities.value) @@ -3450,6 +3475,8 @@ void PPL_DrawEntFullBrights(void) case mod_brush: PPL_FullBrightBModelTextures (currententity); + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); break; default: diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index 01a770f5a..82660b759 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -2336,8 +2336,9 @@ start: } else */ { - surf->texturechain = surf->texinfo->texture->texturechain; - surf->texinfo->texture->texturechain = surf; + *surf->texinfo->texture->texturechain_tail = surf; + surf->texinfo->texture->texturechain_tail = &surf->texturechain; + surf->texturechain = NULL; } } } @@ -2528,6 +2529,17 @@ static void GLR_LeafWorldNode (void) } #endif +static void GLR_ClearChains(void) +{ + int i; + for (i = 0; i < cl.worldmodel->numtextures; i++) + { + if (!cl.worldmodel->textures[i]) + continue; + cl.worldmodel->textures[i]->texturechain = NULL; + cl.worldmodel->textures[i]->texturechain_tail = &cl.worldmodel->textures[i]->texturechain; + } +} /* ============= R_DrawWorld @@ -2552,6 +2564,7 @@ void R_DrawWorld (void) else #endif { + GLR_ClearChains(); qglColor3f (1,1,1); //#ifdef QUAKE2 R_ClearSkyBox (); @@ -2612,8 +2625,6 @@ qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } -qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer); - /* @@ -2847,7 +2858,7 @@ void GL_BuildSurfaceDisplayList (msurface_t *fa) VectorNegate(fa->plane->normal, mesh->normals_array[i]); else VectorCopy(fa->plane->normal, mesh->normals_array[i]); - VectorCopy(fa->texinfo->vecs[0], mesh->snormals_array[i]); + VectorNegate(fa->texinfo->vecs[0], mesh->snormals_array[i]); VectorCopy(fa->texinfo->vecs[1], mesh->tnormals_array[i]); mesh->colors_array[i][0] = 255; @@ -2957,7 +2968,7 @@ qboolean GL_BuildVBO(vbo_t *vbo, void *vdata, int vsize, void *edata, int elemen { unsigned int vbos[2]; -// if (!qglGenBuffersARB) + if (!qglGenBuffersARB) return false; qglGenBuffersARB(2, vbos);