KEMBAR78
Introduction to OpenGL.ppt
CSE 4208
Introduction to OpenGL
Conducted By:
Sk. Md. Masudul Ahsan
and
Kazi Saeed Alam
Objective of graphics programming
 To create synthetic image such a way that
it is close to reality.
 To create artificial animation that emulates
virtual reality.
 But why? We have already tools like
camera to create image of natural scene
and video camera for creating natural
movies!
2
OpenGL – Open Graphics Library
 What it is ?
 a software interface to graphics hardware
 a graphics programming library
 Dominant industry "standard" for 3D graphics
 Consists of about 150 basic commands
 Platform independent
 What it is not ?
 a windowing system (no window creation)
 a UI system (no keyboard and mouse routines)
 a 3D modeling system (Open Inventor, VRML,
Java3D)
3
OpenGL Related Libraries
 GL – gl.h – Opengl32.lib
 Provides basic commands for graphics drawing
 GLU (OpenGL Utility Library) – glu.h – glu32.lib
 Uses GL commands for performing compound
graphics like
 viewing orientation and projection specification
 polygon tessellations, surface rendering etc.
 GLUT (OpenGL Utility Toolkit) – glut.h – glut.lib
 is a window system-independent toolkit for user
interaction
4
OpenGL Library Organization
GLU
GL
Generic
Graphics API
GLUT
User
Interface
DirectDraw
WGL
Xlib / Xt
GLX
OpenGL
Application
Program
Frame
Buffer
Host OS
Either will
Exist in any
system
5
Object space and world space
Object space
World Space
Instantiate &
Modeling
Transform
6
Eye space
 A model can be viewed from different angles.
 Viewing Transform specify following
information about the viewer:
 eye position
 head up
 Look at direction
 View volume
7
Pipelined architecture
a
c
b
a *

* +
b
c
Arithmetic pipeline for c
b
a *

8
Geometric pipeline
Transformer Clipper Projector Rasterizer
Pixels
vertices
9
OpenGL graphics Pipeline
Graphics
Primitives
Object
Space
transform
matrix
Modeling
Transform
World
Space
Eye, lookat,
headup
Viewing
Transform
Eye
Space
Parallel or
Perspectiv
e
volume
Normalize
& Clip
Clipping
Space
material,
lights, color
Shading &
Texture
viewport
location
Image on
Screen
Viewport
Transform
Device
Space
Image
Space
Projection
projection
matrix
Image in
Internal Buffer
Rasteri-
zation
Screen
Space
Scan
conversio
n
10
Convention of function naming
glColor3f(...)
Gl library Root
Command
Number of
Arguments
Type of
Arguments
11
OpenGL APIs
 Primitive functions
glBegin(type);
glVertex(…);
glVertex(…);
…
glVertex(…);
glEnd();
 Attribute functions
glColor3f(…);
12
OpenGL APIs
 Transformation functions
glRotate(…); glTranslate(…);
 Viewing functions
gluLookAt(…);
 Input functions
glutKeyboardFunc(…);
 Control functions
 Inquiry functions
13
Primitives
 Primitives: Points, Lines & Polygons
 Each object is specified by a set of
Vertices
• Grouped together by glBegin & glEnd
glBegin(type)
glVertex*( )
glVertex*( )
…
glEnd( );
• type can have 10
possible values
To specify attributes of last Vertex drawn:
glColor*()/ glIndex*() current vertex color
glNormal*() current vertex normal (lighting)
glMaterial*() current material property
(lighting)
glTexCoord*() current texture coordinate
glEdgeFlag*() edge status (surface primitives)
14
Primitive Types
GL_POINTS
V0
V1
V2
V3
V5
V4
GL_LINE_LOOP
V0
V1
V2
V3
V5
V4
GL_LINES
V0
V1
V2
V3
V5
V4
GL_LINE_STRIP
V0
V1
V2
V3
V5
V4
GL_POLYGON
V0
V1
V2
V3
V4
Polygon must be:
•Simple
•No-holes inside
•Convex Simple
Non-convex
Complex
Convex
P1
P2
15
Primitive Types
GL_TRIANGLES
V0
V1
V2
V3
V4
V5
V6
V7
V8
GL_QUADS
V0
V1
V2
V3
V4
V5
V6
V7
GL_TRIANGLE_STRIP
V0
V1
V2
V3
V4
V5
Order of Vertex rendering
GL_TRIANGLE_STRIP
012, 213, 234, 435
GL_QUAD_STRIP
V0
V1
V2
V3
V4
V5
V6
V7
GL_QUAD_STRIP
0132, 2354, 4576
GL_TRIANGLE_FAN
V0
V1
V2
V3
V4
V5
GL_TRIANGLE_FAN
012, 023 , 034, 04516
Finally
 Making your programming environment
ready
 Let’s see some projects
 Your first program
 Now try with some more stuffs
17

Introduction to OpenGL.ppt

  • 1.
    CSE 4208 Introduction toOpenGL Conducted By: Sk. Md. Masudul Ahsan and Kazi Saeed Alam
  • 2.
    Objective of graphicsprogramming  To create synthetic image such a way that it is close to reality.  To create artificial animation that emulates virtual reality.  But why? We have already tools like camera to create image of natural scene and video camera for creating natural movies! 2
  • 3.
    OpenGL – OpenGraphics Library  What it is ?  a software interface to graphics hardware  a graphics programming library  Dominant industry "standard" for 3D graphics  Consists of about 150 basic commands  Platform independent  What it is not ?  a windowing system (no window creation)  a UI system (no keyboard and mouse routines)  a 3D modeling system (Open Inventor, VRML, Java3D) 3
  • 4.
    OpenGL Related Libraries GL – gl.h – Opengl32.lib  Provides basic commands for graphics drawing  GLU (OpenGL Utility Library) – glu.h – glu32.lib  Uses GL commands for performing compound graphics like  viewing orientation and projection specification  polygon tessellations, surface rendering etc.  GLUT (OpenGL Utility Toolkit) – glut.h – glut.lib  is a window system-independent toolkit for user interaction 4
  • 5.
    OpenGL Library Organization GLU GL Generic GraphicsAPI GLUT User Interface DirectDraw WGL Xlib / Xt GLX OpenGL Application Program Frame Buffer Host OS Either will Exist in any system 5
  • 6.
    Object space andworld space Object space World Space Instantiate & Modeling Transform 6
  • 7.
    Eye space  Amodel can be viewed from different angles.  Viewing Transform specify following information about the viewer:  eye position  head up  Look at direction  View volume 7
  • 8.
    Pipelined architecture a c b a *  *+ b c Arithmetic pipeline for c b a *  8
  • 9.
    Geometric pipeline Transformer ClipperProjector Rasterizer Pixels vertices 9
  • 10.
    OpenGL graphics Pipeline Graphics Primitives Object Space transform matrix Modeling Transform World Space Eye,lookat, headup Viewing Transform Eye Space Parallel or Perspectiv e volume Normalize & Clip Clipping Space material, lights, color Shading & Texture viewport location Image on Screen Viewport Transform Device Space Image Space Projection projection matrix Image in Internal Buffer Rasteri- zation Screen Space Scan conversio n 10
  • 11.
    Convention of functionnaming glColor3f(...) Gl library Root Command Number of Arguments Type of Arguments 11
  • 12.
    OpenGL APIs  Primitivefunctions glBegin(type); glVertex(…); glVertex(…); … glVertex(…); glEnd();  Attribute functions glColor3f(…); 12
  • 13.
    OpenGL APIs  Transformationfunctions glRotate(…); glTranslate(…);  Viewing functions gluLookAt(…);  Input functions glutKeyboardFunc(…);  Control functions  Inquiry functions 13
  • 14.
    Primitives  Primitives: Points,Lines & Polygons  Each object is specified by a set of Vertices • Grouped together by glBegin & glEnd glBegin(type) glVertex*( ) glVertex*( ) … glEnd( ); • type can have 10 possible values To specify attributes of last Vertex drawn: glColor*()/ glIndex*() current vertex color glNormal*() current vertex normal (lighting) glMaterial*() current material property (lighting) glTexCoord*() current texture coordinate glEdgeFlag*() edge status (surface primitives) 14
  • 15.
  • 16.
    Primitive Types GL_TRIANGLES V0 V1 V2 V3 V4 V5 V6 V7 V8 GL_QUADS V0 V1 V2 V3 V4 V5 V6 V7 GL_TRIANGLE_STRIP V0 V1 V2 V3 V4 V5 Order ofVertex rendering GL_TRIANGLE_STRIP 012, 213, 234, 435 GL_QUAD_STRIP V0 V1 V2 V3 V4 V5 V6 V7 GL_QUAD_STRIP 0132, 2354, 4576 GL_TRIANGLE_FAN V0 V1 V2 V3 V4 V5 GL_TRIANGLE_FAN 012, 023 , 034, 04516
  • 17.
    Finally  Making yourprogramming environment ready  Let’s see some projects  Your first program  Now try with some more stuffs 17