This document provides an overview of OpenGL and graphics programming concepts:
- OpenGL is a graphics API that makes graphics programming hardware independent, and GLUT is a toolkit library that makes it easier to use OpenGL.
- Graphics rendering represents 3D models as 2D images through applying transformations, projection, lighting and textures.
- Key concepts include representing objects as geometric primitives, applying transformations, adding realism through lighting and textures, and customizing rendering through shaders.
Introduction to OpenGL as a graphics API and GLUT as a toolkit library that facilitates graphics programming.
Overview of high-level graphics programming principles like primitives, transformations, light, and textures.
Explanation of various transformations in graphics rendering, including modeling, viewing, and projection transformations.
Discussion of hands-on tutorials focused on transformations and projection concepts in OpenGL.
Description of camera analogy in graphics rendering and how transformations relate to viewing transformations.
Insight into buffer management techniques in OpenGL, including double buffering and depth buffering.Various lighting models and principles in OpenGL, detailing Phong lighting model and surface normals.
Detailed exploration of texture mapping concepts, including application and its effects on improving realism.
Examination of OpenGL's state machine, highlighting how rendering information is stored and manipulated.Focus on shaders in OpenGL that allow user-defined transformations and programmable graphics operations.
Insight into buffer management techniques in OpenGL, including double buffering and depth buffering.
Advanced concepts in OpenGLES, including buffer object management and memory handling for graphics.
Practical exercises designed to reinforce learned concepts such as animation, blending, and texturing.
Arvind Devaraj2
OpenGL andGLUT Overview
�� OpenGL is graphics API.OpenGL is graphics API.
�� Makes graphics programmingMakes graphics programming h/wh/w
independentindependent
�� GLUT is a toolkitGLUT is a toolkit
library of utilities using OpenGLlibrary of utilities using OpenGL
makes easier to use OpenGLmakes easier to use OpenGL
Arvind Devaraj
High Level
�Represent Objects as Primitives
� Apply Transformations on objects
� Projection : Visible portions are rendered
� Add realism by adding Light and
Texture
� Remember using State information
� Customize using Shaders
� Framebuffer operations
Arvind Devaraj8
Camera Analogy
��Graphics Rendering is like taking aGraphics Rendering is like taking a
photographphotograph
�� 3D model3D model �� 2D image2D image
camera
tripod model
viewing
volume
9.
Arvind Devaraj9
Transformations
�� Stepsin Forming an ImageSteps in Forming an Image
� specify geometry (world coordinates)
� specify camera (camera coordinates)
� project (window coordinates)
� map to viewport (screen coordinates)
�� Each step uses transformationsEach step uses transformations
�� Transformation = change in coordinateTransformation = change in coordinate
systemssystems
10.
Arvind Devaraj1
0
Camera Analogyof
Transformations
�� Projection transformationsProjection transformations
� adjust the lens of the camera
�� Viewing transformationsViewing transformations
� tripod–define position and orientation of
the viewing volume in the world
�� Modeling transformationsModeling transformations
� moving the model
�� ViewportViewport transformationstransformations
� enlarge or reduce the physical photograph
Arvind Devaraj1
4
3D Transformations
��A vertex is transformed by 4 x 4 matricesA vertex is transformed by 4 x 4 matrices
� all affine operations are matrix multiplications
� all matrices are stored column-major in
OpenGL
� matrices are always post-multiplied
� product of matrix and vector is
v
�
M
�
�
�
�
�
�
�
�
�
�
�
�
�
151173
141062
13951
12840
mmmm
mmmm
mmmm
mmmm
M
15.
Arvind Devaraj1
5
Programming
Transformations
�� Priorto rendering, view, locate, andPrior to rendering, view, locate, and
orient:orient:
� eye/camera position
� 3D geometry
�� Manage the matricesManage the matrices
� including matrix stack
�� Combine (composite) transformationsCombine (composite) transformations
Arvind Devaraj1
7
Viewing Transformations
��Position the camera/eye in the scenePosition the camera/eye in the scene
� place the tripod down; aim camera
�� ToTo ““fly throughfly through”” a scenea scene
� change viewing transformation and
redraw scene
�� gluLookAtgluLookAt(( eyeeyexx,, eyeeyeyy,, eyeeyezz,,
aimaimxx,, aimaimyy,, aimaimzz,,
upupxx,, upupyy,, upupzz ))
� up vector determines unique orientation
tripod
Arvind Devaraj2
3
Connection: Viewingand
Modeling
�� Moving camera is equivalent to movingMoving camera is equivalent to moving
every object in the world towards aevery object in the world towards a
stationary camerastationary camera
�� Viewing transformations are equivalentViewing transformations are equivalent
to several modeling transformationsto several modeling transformations
Arvind Devaraj2
7
Phong Principles
��Lighting simulates how objects reflectLighting simulates how objects reflect
lightlight
� material composition of object
� light’s color and position
Arvind Devaraj3
0
Simulating Lights
��PhongPhong lighting modellighting model
� Computed at vertices
�� Lighting contributorsLighting contributors
� Surface material properties
� Light properties
� Lighting model properties
31.
Arvind Devaraj3
1
Surface
Normals
�� NormalsNormalsdefine how a surface reflectsdefine how a surface reflects
lightlight
glNormal3f(glNormal3f( x, y, zx, y, z ))
� Current normal is used to compute vertex’s
color
Arvind Devaraj3
9
Texture Example
��The texture (below) is aThe texture (below) is a
256 x 256 image that has been256 x 256 image that has been
mapped to a rectangularmapped to a rectangular
polygonpolygon
Arvind Devaraj4
1
OpenGL’s StateMachine
All Rendering info are remembered as state
info
State Information
Lighting
Shading
Texturing
Blending
42.
Arvind Devaraj4
2
OpenGL’s StateMachineAll Rendering info are remembered as state
info
Manipulating vertex attribute changes state
info
glColor()
glNormal()
glTexCoord()
Arvind Devaraj4
7
Getting tothe Framebuffer
BlendingBlendingDepth
Test
Depth
Test DitheringDithering Logical
Operations
Logical
Operations
Scissor
Test
Scissor
Test
Stencil
Test
Stencil
Test
Alpha
Test
Alpha
Test
Fragment
Framebuffer
Arvind Devaraj
OpenGLES
� Thereis no support for glBegin or
glEnd. Use vertex arrays and vertex
buffer objects instead.
� The only supported rasterization
primitives are points, lines and
triangles. Quads are not supported
� There is no support for display lists.
59.
Arvind Devaraj
OpenGLES
� Thereis no support for the fixed-function
graphics pipeline. You must use your own
vertex and fragment shader programs.
� There is no support for viewing transforms
such as glFrustumf. You must compute your
own transformation matrix, pass it to the
vertex shader as a uniform variable, and
perform the matrix multiplication in the
shader.
� There is no support for specialized functions
such as glVertexPointer and glNormalPointer.
Use glVertexAttribPointer instead.
60.
Arvind Devaraj
OpenGLES- BufferObjects
� OpenGL cannot directly see any of your
memory
� Therefore, the first step is to allocate
some memory that OpenGL can see .
This is done with something called a
buffer object.
Think of a buffer object as an array of
GPU memory.
61.
Arvind Devaraj
OpenGLES- BufferObjects
� Pass arrays of vertices, colors, etc. to OpenGL
in a large chunk
glVertexPointer( 3, GL_FLOAT, 0, coords )
glColorPointer( 4, GL_FLOAT, 0, colors )
glEnableClientState( GL_VERTEX_ARRAY )
glEnableClientState( GL_COLOR_ARRAY )
glDrawArrays( GL_TRIANGLE_STRIP, 0,
numVerts );