WHAT IS OPENGL - PowerPoint PPT Presentation

1 / 74
About This Presentation
Title:

WHAT IS OPENGL

Description:

3D is just like taking a photograph (lots of photographs!) camera. tripod. model. viewing ... glNormal3f( x, y, z ) Current normal is used to compute vertex's color ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 75
Provided by: ey894
Category:

less

Transcript and Presenter's Notes

Title: WHAT IS OPENGL


1
WHAT IS OPENGL
2
What 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.

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

4
What can be done with OpenGL
  • Games

5
What can be done with OpenGL
  • Simulators

6
What can be done with OpenGL
  • Medical Applications

7
What can be done with OpenGL
  • CAD Programs

8
What can be done with OpenGL
  • Animated Movies

9
What can be done with OpenGL
  • OS GUIs

10
How 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.

11
Start Constructing 3D World
12
Drawing In Space
  • Every object in space constructed from geometric
    primitives that are specified by vertices

13
Points
14
Lines
15
Line Loop
16
Line Strip
17
Triangles
18
Triangle Fan
19
Triangle Strip
20
Quads
21
Quad Strip
22
Polygon
23
What can be done with these primitives?
  • Terrain for simulators

24
What can be done with these primitives?
  • Objects,scenes

25
What can be done with these primitives?
  • Animated Objects

26
Object Modes
  • Point
  • Line (wireframe)
  • Fill (solid)

27
Viewing
  • 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

28
Camera Analogy
  • 3D is just like taking a photograph (lots of
    photographs!)

viewing volume
camera
model
tripod
29
Projections
  • 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

30
Moving Camera (Use gluLookAT)
31
Moving Camera (Use gluLookAT)
32
Moving Model (Use glTranslatef, glRotatef,
glScalef)
33
Moving Model (Use glTranslatef, glRotatef,
glScalef)
34
Perspective Projection
  • Better for human vieving system.

35
Orthogonal Projection
  • Useful for CAD applications.(Blueprints)

36
Color
  • 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

37
Light
  • Light is a magic in CG world. It makes the
    objects look real.

38
Lighting 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

39
How OpenGL Simulates Lights
  • Phong lighting model
  • Computed at vertices
  • Lighting contributors
  • Surface material properties
  • Light properties
  • Lighting model properties

40
SurfaceNormals
  • 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 )

41
Material Properties
  • Define the surface properties of a primitive
  • glMaterialfv( face, property, value )
  • separate materials for front and back

42
Light Sources (cont.)
  • Light color properties
  • GL_AMBIENT
  • GL_DIFFUSE
  • GL_SPECULAR

43
Material Properties
44
LightMaterial
Light position changed, ambient and diffuse
components changed
45
LightMaterial
Light position changed, ambient and diffuse
components changed, Material properties changed
46
Effect of Light
47
Texture 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.

48
Texture 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

49
Texture Mapping
1000 Polygons with texture
3000 Polygons without texture
50
Texture Mapping
screen
geometry
image
51
Texture Mapping
52
Texture Mapping
53
Texture Mapping
54
Texture Mapping
55
Fog
  • 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

56
Linear Fog
57
Exponential Fog
58
Exponential 2 Fog
59
Beyond 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.
60
Beyond 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

61
Buffers
  • 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.

62
Buffers
  • Color Buffer
  • Double Buffering
  • Stereo Buffering
  • Depth Buffer
  • Stencil Buffer
  • Accumulation Buffer

63
Color 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.

64
Depth Buffer
  • Holds distance values for each pixel.
  • Usually use for performing hidden surface
    removal.

65
Stencil Buffer
  • Block out certain areas on screen.(Usefull for
    drawing instruments on flight sims).

66
Accumulation Buffer
  • Motion blur
  • Full-screen anti-aliasing

67
Extensions
  • 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.

68
Extensions
69
Display 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)

70
Hints 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.

71
Direct 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)

72
Directx vs OpenGL
73
Directx vs OpenGL
74
Thanks for listening.
  • Questions and Answers.
Write a Comment
User Comments (0)
About PowerShow.com