* clutter/cogl/gl/cogl-texture.c (cogl_texture_polygon): Fix the
authorNeil Roberts <neil@openedhand.com>
Mon, 24 Nov 2008 12:27:48 +0000 (12:27 +0000)
committerNeil Roberts <neil@openedhand.com>
Mon, 24 Nov 2008 12:27:48 +0000 (12:27 +0000)
equation for calculating texture coordinates when using sliced
textures. This became broken in revision 3520.

ChangeLog
clutter/cogl/gl/cogl-texture.c

index d95fe11..04ca566 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-24  Neil Roberts  <neil@linux.intel.com>
+
+       * clutter/cogl/gl/cogl-texture.c (cogl_texture_polygon): Fix the
+       equation for calculating texture coordinates when using sliced
+       textures. This became broken in revision 3520.
+
 2008-11-21  Neil Roberts  <neil@linux.intel.com>
 
        Bug 1270 - Update to mingw-cross-compile.sh
index b2970fc..1af5d88 100644 (file)
@@ -2224,7 +2224,7 @@ cogl_texture_polygon (CoglHandle         handle,
                      gboolean           use_color)
 {
   CoglTexture      *tex;
-  int               i, x, y;
+  int               i, x, y, tex_num;
   GLuint            gl_handle;
   CoglTexSliceSpan *y_span, *x_span;
   gulong            enable_flags;
@@ -2314,7 +2314,7 @@ cogl_texture_polygon (CoglHandle         handle,
                           GL_CLAMP_TO_BORDER) );
     }
 
-  i = 0;
+  tex_num = 0;
 
   /* Render all of the slices with the full geometry but use a
      transparent border color so that any part of the texture not
@@ -2327,7 +2327,7 @@ cogl_texture_polygon (CoglHandle         handle,
        {
          x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x);
 
-         gl_handle = g_array_index (tex->slice_gl_handles, GLuint, i++);
+         gl_handle = g_array_index (tex->slice_gl_handles, GLuint, tex_num++);
 
          /* Convert the vertices into an array of GLfloats ready to pass to
             OpenGL */
@@ -2338,10 +2338,14 @@ cogl_texture_polygon (CoglHandle         handle,
              p->v[0] = CFX_F(vertices[i].x);
              p->v[1] = CFX_F(vertices[i].y);
              p->v[2] = CFX_F(vertices[i].z);
-             p->t[0] = CFX_F(vertices[i].tx
-                             * (x_span->size - x_span->waste) / x_span->size);
-             p->t[1] = CFX_F(vertices[i].ty
-                             * (y_span->size - y_span->waste) / y_span->size);
+             p->t[0] = CFX_F((vertices[i].tx
+                               - (COGL_FIXED_FROM_INT (x_span->start)
+                                  / tex->bitmap.width))
+                              * tex->bitmap.width / x_span->size);
+             p->t[1] = CFX_F((vertices[i].ty
+                               - (COGL_FIXED_FROM_INT (y_span->start)
+                                  / tex->bitmap.height))
+                             * tex->bitmap.height / y_span->size);
              p->c[0] = cogl_color_get_red_byte(&vertices[i].color);
              p->c[1] = cogl_color_get_green_byte(&vertices[i].color);
              p->c[2] = cogl_color_get_blue_byte(&vertices[i].color);