Functions
Initialization
glutInit()
glutInit(&argc, argv);
Initialize the GLUT library.
argc
: A pointer to the program’s unmodifiedargc
variable frommain
. Upon return, the value pointed to byargc
will be updated, becauseglutInit
extracts any command line options intended for theGLUT
library.argv
: The program’s unmodifiedargv
variable from main. Likeargc
, the data for argv will be updated becauseglutInit
extracts any command line options understood by theGLUT
library.
glutInitDisplayMode()
void glutInitDisplayMode(MODE);
sets the initial display mode.
MODE
- GLUT_RGBA / GLUT_RGB
Bit mask to select an RGBA mode window. This is the default if neither GLUT_RGBA
nor GLUT_INDEX
are specified.
- GLUT_INDEX
Bit mask to select a color index mode window. This overrides GLUT_RGBA
if it is also specified.
- GLUT_SINGLE
Bit mask to select a single buffered window. This is the default if neither GLUT_DOUBLE
or GLUT_SINGLE
are specified.
- GLUT_DOUBLE
Bit mask to select a double buffered window. This overrides GLUT_SINGLE
if it is also specified.
- GLUT_ACCUM
Bit mask to select a window with an accumulation buffer.
- GLUT_ALPHA
Bit mask to select a window with an alpha component to the color buffer(s).
- GLUT_DEPTH
Bit mask to select a window with a depth buffer.
- GLUT_STENCIL
Bit mask to select a window with a stencil buffer.
- GLUT_MULTISAMPLE
Bit mask to select a window with multisampling support. If multisampling is not available, a non-multisampling window will automatically be chosen. Note: both the OpenGL client-side and server-side implementations must support the GLX_SAMPLE_SGIS
extension for multisampling to be available.
- GLUT_STEREO
Bit mask to select a stereo window.
- GLUT_LUMINANCE
Bit mask to select a window with a “luminance’’ color model. This model provides the functionality of OpenGL’s RGBA color model, but the green and blue components are not maintained in the frame buffer. Instead each pixel’s red component is converted to an index between zero and glutGet(GLUT_WINDOW_COLORMAP_SIZE)-1
and looked up in a per-window color map to determine the color of pixels within the window. The initial colormap of GLUT_LUMINANCE
windows is initialized to be a linear gray ramp, but can be modified with GLUT’s colormap routines.
glutInitWindowSize(), glutInitWindowPosition()
glutInitWindowSize(int width, int height);
glutInitWindowPosition(int x, int y);
glutCreateWindow()
glutCreateWindow(string window_name);
DIsplay
glclear(), glClearColor()
void glclear(GLbitfield mask);
GL_COLOR_BUFFER_BIT
Indicates the buffers currently enabled for color writing.
GL_DEPTH_BUFFER_BIT
Indicates the depth buffer.
GL_ACCUM_BUFFER_BIT
Indicates the accumulation buffer.
GL_STENCIL_BUFFER_BIT
Indicates the stencil buffer.
The value to which each buffer is cleared depends on the setting of the clear value for that buffer.
void glClearColor(red, green, blue, (alpha))
glClearColor(, , ,)
specifies the red, green, blue, and alpha values used by glClear(, , , )
to clear the color buffers. Values specified by glClearColor(, , ,)
are clamped to the range 0 1 .
glColor(red, green, blue, (alpha))
set the current color.
void glColor3b(byte, byte, byte); |
glBegin(), glEnd(), glFlush()
description
void glBegin(GLenum mode); |
Specifies the primitive or primitives that will be created from vertices presented between glBegin and the subsequent glEnd.
mode
GL_POINTS
, GL_LINES
, GL_LINE_STRIP
, GL_LINE_LOOP
, GL_TRIANGLES
, GL_TRIANGLE_STRIP
, GL_TRIANGLE_FAN
, GL_QUADS
, GL_QUAD_STRIP
, and GL_POLYGON
.
GL_POINTS
Treats each vertex as a single point. Vertex $n$ defines point $n$. $N$ points are drawn.
GL_LINES
Treats each pair of vertices as an independent line segment. Vertices $2n - 1$ and $2n$ define line $n$. $N/2$ lines are drawn.
GL_LINE_STRIP
Draws a connected group of line segments from the first vertex to the last. Vertices $n$ and $n + 1$ define line $n$. $N - 1$ lines are drawn.
GL_LINE_LOOP
Draws a connected group of line segments from the first vertex to the last, then back to the first. Vertices $n$ and $n + 1$ define line $n$. The last line, however, is defined by vertices $N$ and $1$ . $N$ lines are drawn.
GL_TRIANGLES
Treats each triplet of vertices as an independent triangle. Vertices $3n - 2$ , $3 n - 1$ , and $3n$ define triangle $n$. $N /3$ triangles are drawn.
GL_TRIANGLE_STRIP
Draws a connected group of triangles. One triangle is defined for each vertex presented after the first two vertices. For odd $n$, vertices $n$, $n + 1$ , and $n + 2$ define triangle $n$. For even $n$, vertices $n + 1$ , $n$, and $n + 2$ define triangle $n$. $N - 2$ triangles are drawn.
GL_TRIANGLE_FAN
Draws a connected group of triangles. One triangle is defined for each vertex presented after the first two vertices. Vertices $1$ , $n + 1$ , and $n + 2$ define triangle $n$. $N - 2$ triangles are drawn.
GL_QUADS
Treats each group of four vertices as an independent quadrilateral. Vertices $4 n - 3$ , $4 n - 2$ , $4 n - 1$ , and $4 n $ define quadrilateral $n$. $N/4$ quadrilaterals are drawn.
GL_QUAD_STRIP
Draws a connected group of quadrilaterals. One quadrilateral is defined for each pair of vertices presented after the first pair. Vertices $2 n - 1$ , $2 n$ , $2 n + 2$ , and $2 n + 1$ define quadrilateral $n$. $N/2 - 1$ quadrilaterals are drawn. Note that the order in which vertices are used to construct a quadrilateral from strip data is different from that used with independent data.
GL_POLYGON
Draws a single, convex polygon. Vertices $1$ through $N$ define this polygon.
glFlush()
Force execution of GL commands in finite time.
glVertex(x, y, z, w, …)
Specify a vertex.
void glVertex2s(short, short); |
glPointSize()
Specify the diameter of rasterized points.
void glPointSize(float size)
. The initial value is 1.
glMatrixMode()
Specify which matrix is the current matrix.
void glMatrixMode(Glenum mode);
GL_MODELVIEW
Applies subsequent matrix operations to the modelview matrix stack.
GL_PROJECTION
Applies subsequent matrix operations to the projection matrix stack.
GL_TEXTURE
Applies subsequent matrix operations to the texture matrix stack.
GL_COLOR
Applies subsequent matrix operations to the color matrix stack.
To find out which matrix stack is currently the target of all matrix operations, call glGet()
with argument GL_MATRIX_MODE
. The initial value is GL_MODELVIEW
.
gluOrtho2D()
Define a 2D orthographic projection matrix.
void gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
glutMouseFunc()
void glutMouseFunc(void (*func)(int button, int state, int x, int y));
sets the mouse callback for the current window.
The button
parameter is one of GLUT_LEFT_BUTTON
, GLUT_MIDDLE_BUTTON
, or GLUT_RIGHT_BUTTON
.
The state
parameter is either GLUT_UP
or GLUT_DOWN
indicating whether the callback was due to a release or press respectively.
Passing NULL
to glutMouseFunc
disables the generation of mouse callbacks.