21
Lecture 7 Midterm Review

Lecture 7

Embed Size (px)

DESCRIPTION

Lecture 7. Midterm Review. OpenGL Libraries. gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture mipmaps from a base image, draw quadric surfaces and NURBS. glut: OpenGL Utility Toolkit library. A system independent windowing system. - PowerPoint PPT Presentation

Citation preview

Page 1: Lecture 7

Lecture 7

Midterm Review

Page 2: Lecture 7

OpenGL Libraries

gl: Basic OpenGL library, e.g. primitives.

glu: OpenGL Utility library, a set of functions to create texture mipmaps from a base image, draw quadric surfaces and NURBS.

glut: OpenGL Utility Toolkit library. A system independent windowing system.

Hierarchical view of libraries: http://www.nigels.com/glt/doc/gl_8h.h

tml

Page 3: Lecture 7

Mesa 3D Mesa 3D is a free/open source

implementation of OpenGL.

This is a good source if you plan to see the implementation details of a function.

http://www.mesa3d.org

Page 4: Lecture 7

Rendering Pipeline

Page 5: Lecture 7

Rendering Pipeline

Evaluators Deriving vertices from basis functions Vertices can be used to represent a

surface Per-Vertex Operations

Converts vertices into primitives i.e. line, polygon, etc.

Does mathematical operations, i.e. transformation, rotation, projection, etc.

Page 6: Lecture 7

Rendering Pipeline

Rasterization: Conversion of geometric and pixel data into fragments.

Each fragment corresponds to a pixel in frame buffer.

When creating models, many parameters have to be considered, e.g. shading model, color, point size, etc.

Page 7: Lecture 7

Fragment Operations

Before a fragment be placed in frame buffer, the following can be controlled: Texture Mapping Fog calculations Alpha Test, depth buffer test Blending, masking, etc.

Page 8: Lecture 7

GLUT Window Initialization What is Buffer? Clearing the Window

glClearColor(R, G, B, A)

glClearColor(GL_COLOR_BUFFER_BIT)

glClearDepth()

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

Page 9: Lecture 7

OpenGL Buffers

Page 10: Lecture 7

Event Driven Programming Definition. A programming where the primary activity

is reaction to the receipt of event.

Applications: GUI, HCI

Ingredients: Events: Can be from any source, human input, e.g.

mouse or other sensors. Event Dispatcher: Assigns events to event

handlers. Event Handler

Page 11: Lecture 7

Event Processing in GLUT

Initial Setup: Initializing Display Modes, e.g. Color

mode, Single/Double Buffer, etc.

Entering GLUT event processing loop void glutMainLoop (void)

Page 12: Lecture 7

Display Function

The display function of current window When is it called?

If the normal plane of a window needs to be redisplayed as a result of window damage. GLUT determines this based on redisplay state of a window.

When a user requests. How is it called?

Implicitly: By GLUT, e.g. when the window system reports a region of the window's normal plane is undefined (for example, damaged by another window moving or being initially shown)

Explicitly: Using glutPostRedisplay function.

Page 13: Lecture 7

Double Buffering Using Two buffers

Front Buffer Back Buffer

Is specified in initialization step glutInitDisplayMode (GLUT_DOUBLE)

Replace glFlush() with glSwapBuffers()

Increases the performance It’s NOT free, you have to pay: memory

Page 14: Lecture 7

Rotation and Translation

Page 15: Lecture 7

Camera Rotation

Example: If we want to move a camera along a circular path and about any one of axes, we use rotation matrix corresponding to that axis.

Then, by increasing the angle from [0…360], we calculate the new location of the camera.

Page 16: Lecture 7

ModelView,Projection,Viewport

ModelView: Rotation, Translation, Scale.

Projection: glFrustum, glOrtho, glPerspective

Viewport glViewport

Page 17: Lecture 7

Perspective Projection

Page 18: Lecture 7

Viewport

Defines how a rendered image should be displayed on a window.

Page 19: Lecture 7

Sequence of Matrices

Page 20: Lecture 7

Camera Properties: Position, Direction, UpVector Attention:

Using gluLookAt affects the ModelView Matrix

It is usually placed at the beginning of the display function

It is usually placed after glLoadIdentity(GL_MODELVIEW)

Be careful when placing it in a loop.

Page 21: Lecture 7

Matrix Stack

Pushing matrices into the stack Poping matrices from the stack Example: