Changes cogl_rectangle to take x1, y1, x2, y2 args not x1, y1, width, height

This makes it consistent with cogl_rectangle_with_{multi,}texture_coords.
Notably the reason cogl_rectangle_with_{multi,}texture_coords wasn't changed
instead is that the former approach lets you describe back facing rectangles.
(though technically you could pass negative width/height values to achieve
 this; it doesn't seem as neat.)
This commit is contained in:
Robert Bragg 2009-01-28 14:47:03 +00:00
parent 1d86b04e06
commit c4b4500059
5 changed files with 31 additions and 26 deletions

View File

@ -52,17 +52,17 @@ G_BEGIN_DECLS
/** /**
* cogl_rectangle: * cogl_rectangle:
* @x: X coordinate of the top-left corner * @x1: X coordinate of the top-left corner
* @y: Y coordinate of the top-left corner * @y1: Y coordinate of the top-left corner
* @width: Width of the rectangle * @x2: X coordinate of the bottom-right corner
* @height: Height of the rectangle * @y2: Y coordinate of the bottom-right corner
* *
* Fills a rectangle at the given coordinates with the current source material * Fills a rectangle at the given coordinates with the current source material
**/ **/
void cogl_rectangle (float x, void cogl_rectangle (float x1,
float y, float y1,
float width, float x2,
float height); float y2);
/** /**
* cogl_path_fill: * cogl_path_fill:

View File

@ -45,14 +45,13 @@ void _cogl_path_fill_nodes ();
void _cogl_path_stroke_nodes (); void _cogl_path_stroke_nodes ();
void void
cogl_rectangle (float x, cogl_rectangle (float x1,
float y, float y1,
float width, float x2,
float height) float y2)
{ {
cogl_rectangle_with_multitexture_coords (x, y, cogl_rectangle_with_multitexture_coords (x1, y1,
x+width, x2, y2,
y+height,
NULL, NULL,
0); 0);
} }

View File

@ -174,7 +174,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
significant bit */ significant bit */
GE( glStencilMask (merge ? 6 : 3) ); GE( glStencilMask (merge ? 6 : 3) );
GE( glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE) ); GE( glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE) );
cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); cogl_rectangle (bounds_x, bounds_y,
bounds_x + bounds_w, bounds_y + bounds_h);
GE( glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT) ); GE( glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT) );
} }
@ -200,8 +201,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
GE( glMatrixMode (GL_PROJECTION) ); GE( glMatrixMode (GL_PROJECTION) );
GE( glPushMatrix () ); GE( glPushMatrix () );
GE( glLoadIdentity () ); GE( glLoadIdentity () );
cogl_rectangle (-1.0, -1.0, 2, 2); cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
cogl_rectangle (-1.0, -1.0, 2, 2); cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
GE( glPopMatrix () ); GE( glPopMatrix () );
GE( glMatrixMode (GL_MODELVIEW) ); GE( glMatrixMode (GL_MODELVIEW) );
GE( glPopMatrix () ); GE( glPopMatrix () );
@ -235,7 +236,8 @@ _cogl_path_fill_nodes ()
CoglPathNode, 0), CoglPathNode, 0),
ctx->clip.stencil_used); ctx->clip.stencil_used);
cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); cogl_rectangle (bounds_x, bounds_y,
bounds_x + bounds_w, bounds_y + bounds_h);
/* The stencil buffer now contains garbage so the clip area needs to /* The stencil buffer now contains garbage so the clip area needs to
be rebuilt */ be rebuilt */

View File

@ -180,7 +180,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
significant bit */ significant bit */
GE( glStencilMask (merge ? 6 : 3) ); GE( glStencilMask (merge ? 6 : 3) );
GE( glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE) ); GE( glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE) );
cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); cogl_rectangle (bounds_x, bounds_y,
bounds_x + bounds_w, bounds_y + bounds_h);
GE( glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT) ); GE( glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT) );
} }
@ -206,8 +207,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
GE( glMatrixMode (GL_PROJECTION) ); GE( glMatrixMode (GL_PROJECTION) );
GE( glPushMatrix () ); GE( glPushMatrix () );
GE( glLoadIdentity () ); GE( glLoadIdentity () );
cogl_rectangle (-1.0, -1.0, 2, 2); cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
cogl_rectangle (-1.0, -1.0, 2, 2); cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
GE( glPopMatrix () ); GE( glPopMatrix () );
GE( glMatrixMode (GL_MODELVIEW) ); GE( glMatrixMode (GL_MODELVIEW) );
GE( glPopMatrix () ); GE( glPopMatrix () );
@ -412,7 +413,8 @@ _cogl_path_fill_nodes ()
CoglPathNode, 0), CoglPathNode, 0),
ctx->clip.stencil_used); ctx->clip.stencil_used);
cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); cogl_rectangle (bounds_x, bounds_y,
bounds_x + bounds_w, bounds_y + bounds_h);
/* The stencil buffer now contains garbage so the clip area needs to /* The stencil buffer now contains garbage so the clip area needs to
be rebuilt */ be rebuilt */

View File

@ -404,7 +404,8 @@ _cogl_add_stencil_clip (float x_offset,
GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); GE( glStencilFunc (GL_NEVER, 0x1, 0x1) );
GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) );
cogl_rectangle (x_offset, y_offset, width, height); cogl_rectangle (x_offset, y_offset,
x_offset + width, y_offset + height);
} }
else else
{ {
@ -412,7 +413,8 @@ _cogl_add_stencil_clip (float x_offset,
rectangle */ rectangle */
GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); GE( glStencilFunc (GL_NEVER, 0x1, 0x3) );
GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) );
cogl_rectangle (x_offset, y_offset, width, height); cogl_rectangle (x_offset, y_offset,
x_offset + width, y_offset + height);
/* Subtract one from all pixels in the stencil buffer so that /* Subtract one from all pixels in the stencil buffer so that
only pixels where both the original stencil buffer and the only pixels where both the original stencil buffer and the
@ -423,7 +425,7 @@ _cogl_add_stencil_clip (float x_offset,
GE( glMatrixMode (GL_PROJECTION) ); GE( glMatrixMode (GL_PROJECTION) );
GE( glPushMatrix () ); GE( glPushMatrix () );
GE( glLoadIdentity () ); GE( glLoadIdentity () );
cogl_rectangle (-1.0, -1.0, 2, 2); cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
GE( glPopMatrix () ); GE( glPopMatrix () );
GE( glMatrixMode (GL_MODELVIEW) ); GE( glMatrixMode (GL_MODELVIEW) );
GE( glPopMatrix () ); GE( glPopMatrix () );