Bug 1057 - cogl_texture_rectangle doesn't support backward
coordinates * clutter/cogl/gl/cogl-texture.c: Instead of sorting the vertex and texture coordinates passed to cogl_texture_rectangle, just swap both sets whenever the texture coordinates are backward.
This commit is contained in:
parent
3fdb6e5ca7
commit
0ff710d37b
@ -1,3 +1,12 @@
|
|||||||
|
2008-11-12 Neil Roberts <neil@linux.intel.com>
|
||||||
|
|
||||||
|
Bug 1057 - cogl_texture_rectangle doesn't support backward
|
||||||
|
coordinates
|
||||||
|
|
||||||
|
* clutter/cogl/gl/cogl-texture.c: Instead of sorting the vertex
|
||||||
|
and texture coordinates passed to cogl_texture_rectangle, just
|
||||||
|
swap both sets whenever the texture coordinates are backward.
|
||||||
|
|
||||||
2008-11-12 Neil Roberts <neil@linux.intel.com>
|
2008-11-12 Neil Roberts <neil@linux.intel.com>
|
||||||
|
|
||||||
* clutter/clutter-rectangle.c (clutter_rectangle_paint): Fixed so
|
* clutter/clutter-rectangle.c (clutter_rectangle_paint): Fixed so
|
||||||
|
@ -1967,6 +1967,29 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
|
|
||||||
cogl_enable (enable_flags);
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
|
/* If the texture coordinates are backwards then swap both the
|
||||||
|
geometry and texture coordinates so that the texture will be
|
||||||
|
flipped but we can still use the same algorithm to iterate the
|
||||||
|
slices */
|
||||||
|
if (tx2 < tx1)
|
||||||
|
{
|
||||||
|
CoglFixed temp = x1;
|
||||||
|
x1 = x2;
|
||||||
|
x2 = temp;
|
||||||
|
temp = tx1;
|
||||||
|
tx1 = tx2;
|
||||||
|
tx2 = temp;
|
||||||
|
}
|
||||||
|
if (ty2 < ty1)
|
||||||
|
{
|
||||||
|
CoglFixed temp = y1;
|
||||||
|
y1 = y2;
|
||||||
|
y2 = temp;
|
||||||
|
temp = ty1;
|
||||||
|
ty1 = ty2;
|
||||||
|
ty2 = temp;
|
||||||
|
}
|
||||||
|
|
||||||
/* Scale ratio from texture to quad widths */
|
/* Scale ratio from texture to quad widths */
|
||||||
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
||||||
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
||||||
@ -2168,7 +2191,6 @@ cogl_texture_rectangle (CoglHandle handle,
|
|||||||
CoglFixed ty2)
|
CoglFixed ty2)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
CoglFixed tempx;
|
|
||||||
|
|
||||||
/* Check if valid texture */
|
/* Check if valid texture */
|
||||||
if (!cogl_is_texture (handle))
|
if (!cogl_is_texture (handle))
|
||||||
@ -2186,38 +2208,6 @@ cogl_texture_rectangle (CoglHandle handle,
|
|||||||
if (tx1 == tx2 || ty1 == ty2)
|
if (tx1 == tx2 || ty1 == ty2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Fix quad coord ordering
|
|
||||||
(atm this is required for sw tiling to iterate
|
|
||||||
over slices properly) */
|
|
||||||
if (x1 > x2)
|
|
||||||
{
|
|
||||||
tempx = x1;
|
|
||||||
x1 = x2;
|
|
||||||
x2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y1 > y2)
|
|
||||||
{
|
|
||||||
tempx = y1;
|
|
||||||
y1 = y2;
|
|
||||||
y2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fix texture coord ordering */
|
|
||||||
if (tx1 > tx2)
|
|
||||||
{
|
|
||||||
tempx = tx1;
|
|
||||||
tx1 = tx2;
|
|
||||||
tx2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ty1 > ty2)
|
|
||||||
{
|
|
||||||
tempx = ty1;
|
|
||||||
ty1 = ty2;
|
|
||||||
ty2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pick tiling mode according to hw support */
|
/* Pick tiling mode according to hw support */
|
||||||
if (cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
|
if (cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
|
||||||
&& tex->slice_gl_handles->len == 1)
|
&& tex->slice_gl_handles->len == 1)
|
||||||
|
@ -1931,6 +1931,29 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
|
|
||||||
cogl_enable (enable_flags);
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
|
/* If the texture coordinates are backwards then swap both the
|
||||||
|
geometry and texture coordinates so that the texture will be
|
||||||
|
flipped but we can still use the same algorithm to iterate the
|
||||||
|
slices */
|
||||||
|
if (tx2 < tx1)
|
||||||
|
{
|
||||||
|
CoglFixed temp = x1;
|
||||||
|
x1 = x2;
|
||||||
|
x2 = temp;
|
||||||
|
temp = tx1;
|
||||||
|
tx1 = tx2;
|
||||||
|
tx2 = temp;
|
||||||
|
}
|
||||||
|
if (ty2 < ty1)
|
||||||
|
{
|
||||||
|
CoglFixed temp = y1;
|
||||||
|
y1 = y2;
|
||||||
|
y2 = temp;
|
||||||
|
temp = ty1;
|
||||||
|
ty1 = ty2;
|
||||||
|
ty2 = temp;
|
||||||
|
}
|
||||||
|
|
||||||
GE( cogl_wrap_glTexCoordPointer (2, GL_FIXED, 0, tex_coords) );
|
GE( cogl_wrap_glTexCoordPointer (2, GL_FIXED, 0, tex_coords) );
|
||||||
GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, quad_coords) );
|
GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, quad_coords) );
|
||||||
|
|
||||||
@ -2123,7 +2146,6 @@ cogl_texture_rectangle (CoglHandle handle,
|
|||||||
CoglFixed ty2)
|
CoglFixed ty2)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
CoglFixed tempx;
|
|
||||||
|
|
||||||
/* Check if valid texture */
|
/* Check if valid texture */
|
||||||
if (!cogl_is_texture (handle))
|
if (!cogl_is_texture (handle))
|
||||||
@ -2141,36 +2163,6 @@ cogl_texture_rectangle (CoglHandle handle,
|
|||||||
if (tx1 == tx2 || ty1 == ty2)
|
if (tx1 == tx2 || ty1 == ty2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Fix quad coord ordering */
|
|
||||||
if (x1 > x2)
|
|
||||||
{
|
|
||||||
tempx = x1;
|
|
||||||
x1 = x2;
|
|
||||||
x2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y1 > y2)
|
|
||||||
{
|
|
||||||
tempx = y1;
|
|
||||||
y1 = y2;
|
|
||||||
y2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fix texture coord ordering */
|
|
||||||
if (tx1 > tx2)
|
|
||||||
{
|
|
||||||
tempx = tx1;
|
|
||||||
tx1 = tx2;
|
|
||||||
tx2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ty1 > ty2)
|
|
||||||
{
|
|
||||||
tempx = ty1;
|
|
||||||
ty1 = ty2;
|
|
||||||
ty2 = tempx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tile textured quads */
|
/* Tile textured quads */
|
||||||
if (tex->slice_gl_handles->len == 1 &&
|
if (tex->slice_gl_handles->len == 1 &&
|
||||||
tx1 >= -COGL_FIXED_1 && tx2 <= COGL_FIXED_1 &&
|
tx1 >= -COGL_FIXED_1 && tx2 <= COGL_FIXED_1 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user