Avoid some unnecessary state changes.

Doesn't make much difference but it doesn't hurt.
This commit is contained in:
Bill Currie 2012-07-03 18:20:32 +09:00
parent ee1cb24e3d
commit ef9e8d05c4
2 changed files with 21 additions and 27 deletions

View file

@ -151,36 +151,30 @@ static void
R_RenderEntities (void) R_RenderEntities (void)
{ {
entity_t *ent; entity_t *ent;
int begun;
if (!r_drawentities->int_val) if (!r_drawentities->int_val)
return; return;
#define RE_LOOP(type_name, Type) \
do { \
begun = 0; \
for (ent = r_ent_queue; ent; ent = ent->next) { \
if (ent->model->type != mod_##type_name) \
continue; \
if (!begun) { \
glsl_R_##Type##Begin (); \
begun = 1; \
} \
currententity = ent; \
glsl_R_Draw##Type (); \
} \
if (begun) \
glsl_R_##Type##End (); \
} while (0)
glsl_R_AliasBegin (); RE_LOOP (alias, Alias);
for (ent = r_ent_queue; ent; ent = ent->next) { RE_LOOP (iqm, IQM);
if (ent->model->type != mod_alias) RE_LOOP (sprite, Sprite);
continue;
currententity = ent;
glsl_R_DrawAlias ();
}
glsl_R_AliasEnd ();
glsl_R_IQMBegin ();
for (ent = r_ent_queue; ent; ent = ent->next) {
if (ent->model->type != mod_iqm)
continue;
currententity = ent;
glsl_R_DrawIQM ();
}
glsl_R_IQMEnd ();
glsl_R_SpriteBegin ();
for (ent = r_ent_queue; ent; ent = ent->next) {
if (ent->model->type != mod_sprite)
continue;
currententity = ent;
glsl_R_DrawSprite ();
}
glsl_R_SpriteEnd ();
} }
static void static void

View file

@ -1763,7 +1763,7 @@ draw_id_particles (void)
void void
glsl_R_DrawParticles (void) glsl_R_DrawParticles (void)
{ {
if (!r_particles->int_val) if (!r_particles->int_val || !numparticles)
return; return;
if (r_particles_style->int_val) { if (r_particles_style->int_val) {
draw_qf_particles (); draw_qf_particles ();