Home > Preview
The flashcards below were created by user
thecoolio1
on FreezingBlue Flashcards.

Vector Display
 CRT beam moved randomly over the screen to draw the lines.
 Usually line drawing, no texture, no filled in areas.
 Exact  CRT beam can be positioned exactly where you want it on the screen (within the limits of the technology of the day).
 Objectbased  each edge in each object in the picture is drawn.
 The more complex the image, the longer it takes to draw.
 If it takes over about 1/20 second, human eye begins to see "flicker".
 May draw same point twice, so it will appear brighter.
 The cube vertices are each shared by 3 edges.

Raster Display
 Approximation  Points along a line can be specified to the nearest pixel.
 Causes "jaggies" (aliasing problems).
 Image based  what's drawn is not based on the (3D) objects, but on the image in the framebuffer.
 Lines, shaded areas, etc.
 Store EVERY pixel in framebuffer.
 This was made feasible by dropping memory prices in the early 1980s.
 Draw every point once.
 Generalpurpose.
 Allows filled areas, not just line drawings.
 Constant refresh rate (no flicker on complex images).
 Inexpensive "TVlike" hardware.

OpenGL Primative GL_POINTS
Treats each vertex as a single point. Vertex n defines point n. N points are drawn.

OpenGL Primative 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.

OpenGL Primative 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.

OpenGL Primative 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.

OpenGL Primative GL_TRIANGLES
Treats each triplet of vertices as an independent triangle. Vertices 3n  2 , 3n  1 , and 3n define triangle n. N 3 triangles are drawn.

OpenGL Primative 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.

OpenGL Primative 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.

OpenGL Primative GL_QUADS
Treats each group of four vertices as an independent quadrilateral. Vertices 4n  3 , 4n  2 , 4n  1 , and 4n define quadrilateral n. N 4 quadrilaterals are drawn.

OpenGL Primative GL_QUAD_STRIP
Draws a connected group of quadrilaterals. One quadrilateral is defined for each pair of vertices presented after the first pair. Vertices 2n  1 , 2n , 2n +2 , and 2n + 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.

OpenGL Primative GL_POLYGON
Draws a single, convex polygon. Vertices 1 through N define this polygon.

glutDisplayFunc
Whenever the system determines that a screen window should be redrawn it issues a redraw event. This occurs when the window is first opened, and when the window is exposed by moving another window off of it.

glutReshapeFunc
Screen windows can be reshaped by the user, usually by dragging a corner of the window to a new position with the mouse. (Simply moving the window does not produce a reshape event.) The reshape function is automatically passed arguments that report the new width and height of the reshaped window.

glutKeyboardFunc
This registers the keyboard function with the event of pressing and releasing some key on the keyboard. The keyboard function is automatically passed arguments that tell which key was pressed. Conveniently, this function also makes available to the system the x and ycoordinates (relative to the screen window) of the mouse at the time a key was pressed.

glutIdleFunc
When nothing is occuring this function is used to determine how much time has passed since the previous idle function call. Typically an action is performed after a given time has elapsed.

glutMouseFunc
When one of the mouse buttons is pressed and released, a mouse event is issued. The mouse function is registered as the callback function a mouse event occurs. The mouse function is automatically passed arguments that describe the mouse location and the nature of the button action.

glutMotionFunc
This function generates an event when the mouse is moved with one or more mouse buttons pressed. Notice that the mouse button need not be released for the event to be generated. The motion function is automatically passed arguments that describe the mouse location.

glutPassiveMotionFunc
This function generates an event when the mouse moves into the window with "no" buttons pressed. The passive motion function is automatically passed arguments that describe the mouse location.

glColor
 The GL stores both a current singlevalued color index and a current fourvalued RGBA color. glColor sets a new fourvalued RGBA color. glColor has two major variants: glColor3 and glColor4. glColor3 variants specify new red, green, and blue values explicitly and set the current alpha value to 1.0 (full intensity) implicitly.glColor4 variants specify all four color components explicitly.
 glColor3b, glColor4b, glColor3s, glColor4s, glColor3i, and glColor4i take three or four signed byte, short, or long integers as arguments. When v is appended to the name, the color commands can take a pointer to an array of such values.
 Current color values are stored in floatingpoint format, with unspecified mantissa and exponent sizes. Unsigned integer color components, when specified, are linearly mapped to floatingpoint values such that the largest representable value maps to 1.0 (full intensity), and 0 maps to 0.0 (zero intensity). Signed integer color components, when specified, are linearly mapped to floatingpoint values such that the most positive representable value maps to 1.0, and the most negative representable value maps to 1.0 . (Note that this mapping does not convert 0 precisely to 0.0.) Floatingpoint values are mapped directly.
 Neither floatingpoint nor signed integer values are clamped to the range 0 1 before the current color is updated. However, color components are clamped to this range before they are interpolated or written into a color buffer.

glBegin and glEnd
glBegin and delimit the vertices that define a primitive or a group of like primitives. glBegin accepts a single argument that specifies in which of ten ways (primatives) the vertices are interpreted. glEnd completes the drawing of the primative.

glVertex
 glVertex commands are used within glBegin/glEnd pairs to specify point, line, and polygon vertices. The current color, normal, texture coordinates, and fog coordinate are associated with the vertex when glVertex is called.
 When only x and y are specified, z defaults to 0 and w defaults to 1. When x, y, and z are specified, w defaults to 1.

glutSwapBuffers
 Performs a buffer swap on the layer in use for the current window. Specifically, glutSwapBuffers promotes the contents of the back buffer of the layer in use of the current window to become the contents of the front buffer. The contents of the back buffer then become undefined. The update typically takes place during the vertical retrace of the monitor, rather than immediately after glutSwapBuffers is called.
 An implicit glFlush is done by glutSwapBuffers before it returns. Subsequent OpenGL commands can be issued immediately after calling glutSwapBuffers, but are not executed until the buffer exchange is completed.
 If the layer in use is not double buffered, glutSwapBuffers has no effect.

glutPostRedisplay
 Mark the normal plane of current window as needing to be redisplayed. The next iteration through glutMainLoop, the window's display callback will be called to redisplay the window's normal plane. Multiple calls to glutPostRedisplay before the next display callback opportunity generates only a single redisplay callback. glutPostRedisplay may be called within a window's display or overlay display callback to remark that window for redisplay.
 Logically, normal plane damage notification for a window is treated as a glutPostRedisplay on the damaged window. Unlike damage reported by the window system,glutPostRedisplay will not set to true the normal plane's damaged status (returned by glutLayerGet(GLUT_NORMAL_DAMAGED).

glutInit
 Initializes the GLUT library and negotiates a session with the window system. During this process, glutInit may cause the termination of the GLUT program with an error message to the user if GLUT cannot be properly initialized. Examples of this situation include the failure to connect to the window system, the lack of window system support for OpenGL, and invalid command line options.
 glutInit also processes command line options, but the specific options parse are window system dependent.

glutInitDisplayMode
 The initial display mode is used when creating toplevel windows, subwindows, and overlays to determine the OpenGL display mode for the tobecreated window or overlay.
 Note that GLUT_RGBA selects the RGBA color model, but it does not request any bits of alpha (sometimes called an alpha buffer or destination alpha) be allocated. To request alpha, specify GLUT_ALPHA. The same applies to GLUT_LUMINANCE.

glutInitWindowSize and glutInitWindowPosition
 Windows created by glutCreateWindow will be requested to be created with the current initial window position and size.
 The initial value of the initial window position GLUT state is 1 and 1. If either the X or Y component to the initial window position is negative, the actual window position is left to the window system to determine. The initial value of the initial window size GLUT state is 300 by 300. The initial window size components must be greater than zero.
 The intent of the initial window position and size values is to provide a suggestion to the window system for a window's initial size and position. The window system is not obligated to use this information. Therefore, GLUT programs should not assume the window was created at the specified size or position. A GLUT program should use the window's reshape callback to determine the true size of the window.

glutCreateWindow
 Creates a toplevel window. The name will be provided to the window system as the window's name. The intent is that the window system will label the window with the name.
 Implicitly, the current window is set to the newly created window.
 Each created window has a unique associated OpenGL context. State changes to a window's associated OpenGL context can be done immediately after the window is created.
 The display state of a window is initially for the window to be shown. But the window's display state is not actually acted upon until glutMainLoop is entered. This means untilglutMainLoop is called, rendering to a created window is ineffective because the window can not yet be displayed.
 The value returned is a unique small integer identifier for the window. The range of allocated identifiers starts at one. This window identifier can be used when calling glutSetWindow.

glOrtho(left, right, bottom, top, nearVal, farVal)
 Describes a transformation that produces a parallel projection.
 Typically, the matrix mode is GL_PROJECTION, and left bottom  nearVal and right top  nearVal specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively, assuming that the eye is located at (0, 0, 0).  farVal specifies the location of the far clipping plane. Both nearVal and farVal can be either positive or negative.

glViewport
 Specifies the affine transformation of x and y from normalized device coordinates to window coordinates.
 Viewport width and height are silently clamped to a range that depends on the implementation.

glutCreateMenu
 Creates a new popup menu and returns a unique small integer identifier. The range of allocated identifiers starts at one. The menu identifier range is separate from the window identifier range. Implicitly, the current menu is set to the newly created menu. This menu identifier can be used when calling glutSetMenu.
 When the menu callback is called because a menu entry is selected for the menu, the current menu will be implicitly set to the menu with the selected entry before the callback is made.

glutAddMenuEntry
Adds a menu entry to the bottom of the current menu. The string name will be displayed for the newly added menu entry. If the menu entry is selected by the user, the menu's callback will be called passing value as the callback's parameter.

glutAttachMenu and glutDetachMenu
 glutAttachMenu attaches a mouse button for the current window to the identifier of the current menu.
 glutDetachMenu detaches an attached mouse button from the current window.
 By attaching a menu identifier to a button, the named menu will be popped up when the user presses the specified button.
 button should be one of GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, and GLUT_RIGHT_BUTTON.
 Note that the menu is attached to the button by identifier, not by reference.

glutAddSubMenu
Adds a submenu trigger to the bottom of the current menu. The string name will be displayed for the newly added submenu trigger. If the submenu trigger is entered, the submenu numbered menu will be cascaded, allowing submenu menu items to be selected.

Drawing Parametric Curves
Recall from analytic geometry the PARAMETRIC equations for an ellipse:
 x=W*cos(θ)
 y=H*sin(θ)
 θ (theta) is the angle, measured in radians, between the xaxis and any point (x,y) on the ellipse.
Recall there are 2*π radians in a circle (2*π=6.2832).
θ is the PARAMETER.
To obtain many points around the ellipse we plugin to the equations many values of θ between 0 and 2*π and calculate the (x,y) coordinates of successive points on the ellipse.
If we set θ to various values between 0 and 2*π we can use the parametric equations to calculate the (x,y) coordinates of points on the ellipse.
Our "display" function looks like this:
 const float PI=3.14159;
 const float W=5.;
 const float H=3.;
 float theta.; // angle between x axis and a point on ellipse
 float dt=2*PI/36.; // how much to change theta for each line segment.
 float x, y; // a point on ellipse.
 glBegin(GL_LINE_LOOP);
 for (theta=0.; theta<2.*PI; theta=theta+dt) { // loop thru 36 vertices
 x=W*cos(theta); // calc x,y coordinates of this vertex
 y=H*sin(theta);
 glVertex3f(x,y,0.); // tell OpenGL this vertex
 }
 glEnd(); // cause OpenGL to draw the LINE_LOOP with 36 vertices
By convention we like the PARAMETER to vary between 0. and 1. (instead of 0. and 2*π).
We can easily "scale" the parameter so as to arrange this. In the above example we make the following changes:
Change parametric equations to:
 x=W*cos(θ*2π)
 y=H*sin(θ*2π)
Change the code loop to:
 float dt=1./36.;
 for (theta=0.; theta<1.; theta=theta+dt) {
 x=W*cos(2*PI*theta);
 y=H*sin(2*PI*theta);
 glVertex3f(x,y,0.); // tell OpenGL this vertex
 }
 glEnd();

Vector Addition
Place vectors to be added "head to tail" one after the other. Sum is vector from head of 1st to tail of last.
[x1,y1,z1] + [x2,y2,z2] = [x1+x2,y1+y2,z1+z2]

Vector Subtraction
ac is equivalent to adding a and (1)c

Vector Multiplication
s[x,y,z]=[sx,sy,sz]. Where 's' is a scalar. Produces a vector in the same direction, but 's' times as long. If 's' is negative, the resulting vector is in the opposite direction.

Dot Product of 2 Vectors
A scalar proportional to the cosine of the angle, α, between the 2 vectors, and their magnitudes:
 V1=(x1,y1,z1)
 V2=(x2,y2,z2)
 V1.V2 = x1x2 + y1y2 + z1z2 = V1V2cos(α)
 where α is the angle between the 2 vectors.

Cross Product of 2 3D Vectors
A vector that is orthogonal (perpendicular) to both vectors.
V1xV2 = [z1y2+y1z2, z1x2x1z2, y1x2+x1y2]
Right hand rule.

Normal to a Plane
A vector perpendicular to the plane. The normal vector is the cross product of any 2 vectors lying on the plane.
EXAMPLE: If P1,P2 and P3 are noncollinear points in a plane, the normal vector, n, is:
 let vector a = P2  P1
 let vector b = P3  P1
 let vector n = a x b
n is the normal on the other side of the plane.

