GLRECT(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’– 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 your glRect outside of glBegin/glEnd pairs, 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