GLRECT(3G)
π GLRECT π
okay bestie, welcome to the 3G corner of the manual β yes that's the manual name, we're in the OpenGL gang now π«Ά this page is literally about drawing rectangles and it's giving art class but make it code β¨
π NAME π
glRectd, glRectf, glRecti, glRects, glRectdv, glRectfv, glRectiv, glRectsv β draw a rectangle π
β¨ C SPECIFICATION β¨
void glRectd( GLdouble x1,
GLdouble y1,
GLdouble x2,
GLdouble y2 )
void glRectf( GLfloat x1,
GLfloat y1,
GLfloat x2,
GLfloat y2 )
void glRecti( GLint x1,
GLint y1,
GLint x2,
GLint y2 )
void glRects( GLshort x1,
GLshort y1,
GLshort x2,
GLshort y2 )
πΈ PARAMETERS πΈ
x1,y1β one vertex of a rectangle, no cap. that's your corner πx2,y2β the opposite vertex of the rectangle. the diagonal bestie of the first one π¦
β¨ C SPECIFICATION β¨ (yes, again β it's the pointer edition π )
void glRectdv( const GLdouble *v1,
const GLdouble *v2 )
void glRectfv( const GLfloat *v1,
const GLfloat *v2 )
void glRectiv( const GLint *v1,
const GLint *v2 )
void glRectsv( const GLshort *v1,
const GLshort *v2 )
πΈ PARAMETERS πΈ
v1β specifies a pointer to one vertex of a rectangle. pointer era fr fr π«Άv2β specifies a pointer to the opposite vertex of the rectangle. the opposite corner, slay π¦
π DESCRIPTION π
glRect is the efficient way to specify rectangles, and it does it with just two corner points. iconic behavior honestly π
Every rectangle command takes four arguments, and they come organized one of two ways:
- as two consecutive pairs of
(x,y)coordinates, or - as two pointers to arrays, each one holding an
(x,y)pair.
And the resulting rectangle? It's defined in the z = 0 plane. flat. two-dimensional. living its best life β¨
now the part that's lowkey the whole personality of this function:
glRect(x1, y1, x2, y2) is exactly equivalent to the following sequence:
glBegin(GL_POLYGON);
glVertex2(x1, y1);
glVertex2(x2, y1);
glVertex2(x2, y2);
glVertex2(x1, y2);
glEnd();
okay so notice something π«Ά if the second vertex is above and to the right of the first vertex, the rectangle gets constructed with a counterclockwise winding. that's just how it is, no notes π
π ERRORS π
GL_INVALID_OPERATION gets generated if glRect is executed between the execution of glBegin and the corresponding execution of glEnd.
bestie. do NOT do that. that's the forbidden zone, the rectangle does not get to exist in there π it's giving "nested and unwell" β keep yourglRectoutside ofglBegin/glEndpairs, periodt β
π SEE ALSO π
glBegin(3G)glVertex(3G)
that's the whole page bestie!! every flag, every parameter, every vibe preserved, nothing skipped, we ate and left no crumbs ππ
and for the little sign-off at the bottom β it's GLRECT(3G), that's the source/version tag and it's stamped on the page like a cute lil sticker πβ¨ go draw some rectangles, main character π¦π
π¦ where this page comes from
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms