Tiny tweaks to eliminate pointless transforms.
authorrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 30 Mar 2011 22:32:38 +0000 (22:32 +0000)
committerrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 30 Mar 2011 22:32:38 +0000 (22:32 +0000)
git-svn-id: https://s.snth.net/svn/neverball/branches/gles@3541 78b8d119-cf0a-0410-b17c-f493084dd1d7

share/gui.c
share/solid_draw.c

index 22b00b0..acca477 100644 (file)
@@ -1307,9 +1307,12 @@ static void gui_paint_array(int id)
         GLfloat cy = widget[id].y + widget[id].h / 2.0f;
         GLfloat ck = widget[id].scale;
 
-        glTranslatef(+cx, +cy, 0.0f);
-        glScalef(ck, ck, ck);
-        glTranslatef(-cx, -cy, 0.0f);
+        if (1.0 < ck || ck < 1.0)
+        {
+            glTranslatef(+cx, +cy, 0.0f);
+            glScalef(ck, ck, ck);
+            glTranslatef(-cx, -cy, 0.0f);
+        }
 
         /* Recursively paint all subwidgets. */
 
index 871c47f..1b4d6c2 100644 (file)
@@ -54,24 +54,23 @@ static void sol_transform(const struct s_vary *vary,
 
     /* Compute the shadow texture transform */
 
-    glActiveTexture_(GL_TEXTURE1);
-    glMatrixMode(GL_TEXTURE);
+    if (vary->uc && vary->uv->r > 0.0)
     {
-        glLoadIdentity();
-
-        if (vary->uc)
+        glActiveTexture_(GL_TEXTURE1);
+        glMatrixMode(GL_TEXTURE);
         {
             float k = 0.25f / vary->uv->r;
 
             v_sub(d, vary->uv->p, p);
 
+            glLoadIdentity();
             glTranslatef(0.5f - k * d[0],
                          0.5f - k * d[2], 0.0f);
             glScalef(k, k, 0.0f);
         }
+        glMatrixMode(GL_MODELVIEW);
+        glActiveTexture_(GL_TEXTURE0);
     }
-    glMatrixMode(GL_MODELVIEW);
-    glActiveTexture_(GL_TEXTURE0);
 }
 
 /*---------------------------------------------------------------------------*/
@@ -648,6 +647,8 @@ static const struct d_mtrl *sol_draw_all(const struct s_draw *draw,
 
     for (bi = 0; bi < draw->bc; ++bi)
     {
+        /* TODO: Cache the count for each set of flags and skip this on 0. */
+
         glPushMatrix();
         {
             sol_transform(draw->vary, draw->vary->bv + bi);
@@ -718,6 +719,8 @@ void sol_draw(const struct s_draw *draw, int mask, int test)
 
 void sol_refl(const struct s_draw *draw)
 {
+    /* TODO: Cache the count for each set of flags and skip this on 0. */
+
     sol_draw_enable();
     {
         const struct d_mtrl *mq = &default_draw_mtrl;