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:
Neil Roberts 2008-11-12 13:03:09 +00:00
parent ba1cab0a62
commit a55b588b30
2 changed files with 46 additions and 64 deletions

View File

@ -1967,6 +1967,29 @@ _cogl_texture_quad_sw (CoglTexture *tex,
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 */
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
@ -2168,7 +2191,6 @@ cogl_texture_rectangle (CoglHandle handle,
CoglFixed ty2)
{
CoglTexture *tex;
CoglFixed tempx;
/* Check if valid texture */
if (!cogl_is_texture (handle))
@ -2186,38 +2208,6 @@ cogl_texture_rectangle (CoglHandle handle,
if (tx1 == tx2 || ty1 == ty2)
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 */
if (cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
&& tex->slice_gl_handles->len == 1)

View File

@ -1931,6 +1931,29 @@ _cogl_texture_quad_sw (CoglTexture *tex,
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_glVertexPointer (2, GL_FIXED, 0, quad_coords) );
@ -2123,7 +2146,6 @@ cogl_texture_rectangle (CoglHandle handle,
CoglFixed ty2)
{
CoglTexture *tex;
CoglFixed tempx;
/* Check if valid texture */
if (!cogl_is_texture (handle))
@ -2141,36 +2163,6 @@ cogl_texture_rectangle (CoglHandle handle,
if (tx1 == tx2 || ty1 == ty2)
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 */
if (tex->slice_gl_handles->len == 1 &&
tx1 >= -COGL_FIXED_1 && tx2 <= COGL_FIXED_1 &&