Title: WHAT IS OPENGL
1WHAT IS OPENGL
2What is OpenGL
- OpenGL provides the programmer with an interface
to graphics hardware. It is a powerful, low level
rendering and modelling software library,
available on all major platforms, with wide
hardware support.
3OpenGL History
- Developed by Slicon Graphics, Inc (SGI) in 1992.
- Development still has been overseen by the OpenGL
Architecture Review Board (ARB), made up of ATI,
Compaq, EvansSutherland, HP, IBM, Intel,
Intergraph, nVidia, Microsoft and SG.
4What can be done with OpenGL
5What can be done with OpenGL
6What can be done with OpenGL
7What can be done with OpenGL
8What can be done with OpenGL
9What can be done with OpenGL
10How Can I use OpenGL?
- You can use OpenGL in all main OSs.
- You have to know Ansi C, C, Pascal, Visual
Basic or Java. - Good knowledge of mathematics, physics.
- Think 3D.
11Start Constructing 3D World
12Drawing In Space
- Every object in space constructed from geometric
primitives that are specified by vertices
13Points
14Lines
15Line Loop
16Line Strip
17Triangles
18Triangle Fan
19Triangle Strip
20Quads
21Quad Strip
22Polygon
23What can be done with these primitives?
24What can be done with these primitives?
25What can be done with these primitives?
26Object Modes
- Point
- Line (wireframe)
- Fill (solid)
27Viewing
- Users eye can be considered as camera. Camera
considered as view and 3D world and objects are
considered as model. They together considered
as modelview. Moving camera is equivalent to
moving every object in the world towards a
stationary camera
28Camera Analogy
- 3D is just like taking a photograph (lots of
photographs!)
viewing volume
camera
model
tripod
29Projections
- Every point in 3D world projected on 2D scene.
Thats how we see 3D world on computer screen or
on paper. OpenGL uses two projection type. - Perspective Projection
- Ortographic Projection
30Moving Camera (Use gluLookAT)
31Moving Camera (Use gluLookAT)
32Moving Model (Use glTranslatef, glRotatef,
glScalef)
33Moving Model (Use glTranslatef, glRotatef,
glScalef)
34Perspective Projection
- Better for human vieving system.
35Orthogonal Projection
- Useful for CAD applications.(Blueprints)
36Color
- Color has 3 or 4 components. Namely red value,
green value, blue value and alpha (transperency)
value. - glColor3f(1,0,0)red colored object
- glColor3f(1,1,1)white color
- glColor3b(0,255,0)green color
- glColor4f(0,0,1,0.3) Transperent object in green
color
37Light
- Light is a magic in CG world. It makes the
objects look real.
38Lighting Principles
- Lighting simulates how objects reflect light
- material composition of object
- lights color and position
- global lighting parameters
- ambient light
- two sided lighting
- available in both color indexand RGBA mode
39How OpenGL Simulates Lights
- Phong lighting model
- Computed at vertices
- Lighting contributors
- Surface material properties
- Light properties
- Lighting model properties
40SurfaceNormals
- Normals define how a surface reflects light
- glNormal3f( x, y, z )
- Current normal is used to compute vertexs color
- Use unit normals for proper lighting
- scaling affects a normals length
- glEnable( GL_NORMALIZE ) orglEnable(
GL_RESCALE_NORMAL )
41Material Properties
- Define the surface properties of a primitive
- glMaterialfv( face, property, value )
- separate materials for front and back
42Light Sources (cont.)
- Light color properties
- GL_AMBIENT
- GL_DIFFUSE
- GL_SPECULAR
43Material Properties
44LightMaterial
Light position changed, ambient and diffuse
components changed
45LightMaterial
Light position changed, ambient and diffuse
components changed, Material properties changed
46Effect of Light
47Texture Mapping
- Texture mapping is probably the most significant
advance in computer graphics in the last 10
years. OpenGL provides texture image mapping
functions that fit images onto polygons in your
scene. How those images are put onto the polygons
is up to you.
48Texture Mapping
- Realistic images
- Anti-aliased text
- Simulating reflective surfaces like mirrors or
polished floors - Simulating materials like wood, bricks or granite
- Reducing the complexity ( number of polygons ) of
a geometric object - Image processing techniques like image warping
and rectification, rotation and scaling
49Texture Mapping
1000 Polygons with texture
3000 Polygons without texture
50Texture Mapping
screen
geometry
image
51Texture Mapping
52Texture Mapping
53Texture Mapping
54Texture Mapping
55Fog
- Fog works in two modes
- Linear fog mode is used for depth cueing affects.
In this mode, you provide OpenGL with a starting
and ending distance from the eye, and between
those distances, the fog color is blended into
the primitive in a linear manner based on
distance from the eye. - Exponential fog mode is used for more natural
environmental affects like fog, smog and smoke.
In this mode, the fogs density increases
exponentially with the distance from the eye. For
these modes, the coefficient is computed as
56Linear Fog
57Exponential Fog
58Exponential 2 Fog
59Beyond Lines and Points
GLU32 Library provides some preformed objects
that are not included in OpenGL. They are
sphere, dodacahedron, tetrahedron, cube, cone,
octahedron, teapot and torus.
60Beyond Lines and Points
- GLU32 library also provides some functions to
draw curves and surfaces without dividing them
into smaller triangles. Bezier and NURBs
(Non-uniform b-splines) are used for this
61Buffers
- A buffer in OpenGL is essentially a
two-dimensional array of values that correspond
to pixels in a window or offscreen image. Each
buffer has the same number of columns and
rows(width and height) as the current client area
of a window but holds a different range and type
of values.
62Buffers
- Color Buffer
- Double Buffering
- Stereo Buffering
- Depth Buffer
- Stencil Buffer
- Accumulation Buffer
63Color Buffer
- The color buffer holds pixel color information.
Each pixel can contain a red/green/blue/alpha
values that describe the appearance of that
pixel. - Double Bufferingprovides an additional offscreen
color buffer that is often used for animation. It
eliminates the annoying flicker - Stereo Bufferingprovides an additional color
buffer in single-buffered mode and two additional
color buffers in double-buffered mode to generate
a left- and right-eye screen image. You can
create true three-dimensional images by choosing
the correct viewing positions for each eye.
64Depth Buffer
- Holds distance values for each pixel.
- Usually use for performing hidden surface
removal.
65Stencil Buffer
- Block out certain areas on screen.(Usefull for
drawing instruments on flight sims).
66Accumulation Buffer
- Motion blur
- Full-screen anti-aliasing
67Extensions
- OpenGL extensions allow vendors to provide
product-specific features within OpenGL without
breaking compatibility with applications or other
vendor hardware. - In general, only use extensions when you have to,
and then, use a generalized (ARB or EXT type)
extensions and not a vendor-specific one. - Do not forget to check any extension before you
start your application.
68Extensions
69Display Lists vs Immediate Mode
- Mainly used for performance issues.
- Display list is precompiled list of OpenGL
commands. - Create an object using display list call it any
time you need. - glcalllist(bolt)
70Hints For Using OpenGL
- FPS (frame per second) should not be less than
25. - Always use double-buffering.
- Always use triangles not polygons.
- Do not use convex polygons.
- Use LOD (Level of detail).
- Do not render images that are not in viewing
volume.
71Direct X
- DirectX is Microsofts attempt at a set of APIs
that provide direct access to hardware in
Windows OS. - DirectDraw
- Direct3D
- DirectInput (handle game devices)
- DirectSound
- DirectMusic
- DirectPlay (comm, network, internet)
- DirectShow (Avi, mpeg support)
72Directx vs OpenGL
73Directx vs OpenGL
74Thanks for listening.