[ Previous | Next | Contents | Glossary | Home | Search ]
OpenGL 1.1 for AIX: Reference Manual

glRect Subroutine

Purpose

Draws a rectangle.

Library

OpenGL C bindings library: libGL.a

C Syntax

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)
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

X1, Y1 Specify one vertex of a rectangle.
X2, Y2 Specify the opposite vertex of the rectangle.
V1 Specifies a pointer to one vertex of a rectangle.
V2 Specifies a pointer to the opposite vertex of the rectangle.

Description

The glRect subroutine supports efficient specification of rectangles as two corner points. Each rectangle command takes four arguments, organized either as two consecutive pairs of (x,y) coordinates, or as two pointers to arrays, each containing an (x,y) pair. The resulting rectangle is defined in the z=0 plane.

glRect( X1 , Y1 , X2 , Y2 ) is equivalent to the following sequence:

glBegin(GL_POLYGON);
glVertex2(X1, Y1);
glVertex2(X2, Y1);
glVertex2(X2, Y2);
glVertex2(X1, Y2);
glEnd();
Note: If the second vertex is above and to the right of the first vertex, the rectangle is constructed with a counterclockwise winding.

Errors

GL_INVALID_OPERATION The glRect subroutine is called between a call to glBegin and the corresponding call to glEnd.

Files

/usr/include/GL/gl.h Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL.

Related Information

The glBegin or glEnd subroutine, glVertex subroutine.

OpenGL Overview.


[ Previous | Next | Contents | Glossary | Home | Search ]