📄 opengl redbook samples.htm
字号:
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates using mipmaps for texture maps. To overtly
show the effect of mipmaps, each mipmap reduction level has a solidly
colored, contrasting texture image. Thus, the quadrilateral which is drawn
is drawn with several different colors.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/model.c">model.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/movelight.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates when to issue lighting and transformation
commands to render a model with a light which is moved by a modeling
transformation (rotate or translate). The light position is reset after
the modeling transformation is called. The eye position does not change. A
sphere is drawn using a grey material characteristic. A single light
source illuminates the object. Interaction: pressing the left mouse button
alters the modeling transformation (x rotation) by 30 degrees. The scene
is then redrawn with the light in a new position.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/movelight.c">movelight.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/pickdepth.jpg"
width=256></TD>
<TD vAlign=center>
<P>Picking is demonstrated in this program. In rendering mode, three
overlapping rectangles are drawn. When the left mouse button is pressed,
selection mode is entered with the picking matrix. Rectangles which are
drawn under the cursor position are "picked." Pay special attention to the
depth value range, which is returned.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/pickdepth.c">pickdepth.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/picksquare.jpg"
width=256></TD>
<TD vAlign=center>
<P>Use of multiple names and picking are demonstrated. A 3x3 grid of
squares is drawn. When the left mouse button is pressed, all squares under
the cursor position have their color changed.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/picksquare.c">picksquare.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/planet.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program shows how to composite modeling transformations to draw
translated and rotated models. Interaction: pressing the d and y keys (day
and year) alters the rotation of the planet around the sun.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/planet.c">planet.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/polyoff.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates polygon offset to draw a shaded polygon and
its wireframe counterpart without ugly visual artifacts ("stitching").</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/polyoff.c">polyoff.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/polys.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates polygon stippling.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/polys.c">polys.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/quadric.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates the use of some of the gluQuadric* routines.
Quadric objects are created with some quadric properties and the callback
routine to handle errors. Note that the cylinder has no top or bottom and
the circle has a hole in it.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/quadric.c">quadric.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/robot.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program shows how to composite modeling transformations to draw
translated and rotated hierarchical models. Interaction: pressing the s
and e keys (shoulder and elbow) alters the rotation of the robot arm.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/robot.c">robot.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/scene.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates the use of the GL lighting model. Objects are
drawn using a grey material characteristic. A single light source
illuminates the objects.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/scene.c">scene.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/select.jpg"
width=256></TD>
<TD vAlign=center>
<P>This is an illustration of the selection mode and name stack, which
detects whether objects which collide with a viewing volume. First, four
triangles and a rectangular box representing a viewing volume are drawn
(drawScene routine). The green triangle and yellow triangles appear to lie
within the viewing volume, but the red triangle appears to lie outside it.
Then the selection mode is entered (selectObjects routine). Drawing to the
screen ceases. To see if any collisions occur, the four triangles are
called. In this example, the green triangle causes one hit with the name
1, and the yellow triangles cause one hit with the name 3.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/select.c">select.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/smooth.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates smooth shading. A smooth shaded polygon is
drawn in a 2-D projection.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/smooth.c">smooth.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/stencil.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program draws two rotated tori in a window. A diamond in the
center of the window masks out part of the scene. Within this mask, a
different model (a sphere) is drawn in a different color.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/stencil.c">stencil.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/stroke.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates some characters of a stroke (vector) font.
The characters are represented by display lists, which are given numbers
which correspond to the ASCII values of the characters. Use of
glCallLists() is demonstrated.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/stroke.c">stroke.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/surface.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program draws a NURBS surface in the shape of a symmetrical
hill.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/surface.c">surface.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/teapots.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates lots of material properties. A single light
source illuminates the objects.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/teapots.c">teapots.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/tess.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates polygon tessellation. Two tesselated objects
are drawn. The first is a rectangle with a triangular hole. The second is
a smooth shaded, self-intersecting star. Note the exterior rectangle is
drawn with its vertices in counter-clockwise order, but its interior
clockwise. Note the combineCallback is needed for the self-intersecting
star. Also note that removing the TessProperty for the star will make the
interior unshaded (WINDING_ODD).</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/tess.c">tess.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/tesswind.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates the winding rule polygon tessellation
property. Four tessellated objects are drawn, each with very different
contours. When the w key is pressed, the objects are drawn with a
different winding rule.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/tesswind.c">tesswind.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/texbind.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates using glBindTexture() by creating and
managing two textures.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/texbind.c">texbind.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/texgen.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program draws a texture mapped teapot with automatically generated
texture coordinates. The texture is rendered as stripes on the teapot.
Initially, the object is drawn with texture coordinates based upon the
object coordinates of the vertex and distance from the plane x = 0.
Pressing the 'e' key changes the coordinate generation to eye coordinates
of the vertex. Pressing the 'o' key switches it back to the object
coordinates. Pressing the 's' key changes the plane to a slanted one (x +
y + z = 0). Pressing the 'x' key switches it back to x = 0.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/texgen.c">texgen.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/texsub.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program texture maps a checkerboard image onto two rectangles.
This program clamps the texture, if the texture coordinates fall outside
0.0 and 1.0. If the s key is pressed, a texture subimage is used to alter
the original texture. If the r key is pressed, the original texture is
restored.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/texsub.c">texsub.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/texturesurf.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program uses evaluators to generate a curved surface and
automatically generated texture coordinates.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/texturesurf.c">texturesurf.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/torus.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates the creation of a display list.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/torus.c">torus.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/trim.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program draws a NURBS surface in the shape of a symmetrical hill,
using both a NURBS curve and pwl (piecewise linear) curve to trim part of
the surface.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/trim.c">trim.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/varray.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program demonstrates vertex arrays.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/varray.c">varray.c</A>.</P></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=6 border=0>
<TBODY>
<TR>
<TD><IMG height=256 src="OpenGL Redbook Samples.files/wrap.jpg"
width=256></TD>
<TD vAlign=center>
<P>This program texture maps a checkerboard image onto two rectangles.
This program demonstrates the wrapping modes, if the texture coordinates
fall outside 0.0 and 1.0. Interaction: Pressing the 's' and 'S' keys
switch the wrapping between clamping and repeating for the s parameter.
The 't' and 'T' keys control the wrapping for the t parameter. If running
this program on OpenGL 1.0, texture objects are not used.</P>
<P>Source code: <A
href="http://www.opengl.org/resources/code/samples/redbook/wrap.c">wrap.c</A>.</P></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -