SlideShare a Scribd company logo
OpenGL Training/Tutorial

                 Jayant Mukherjee



1                     February 13, 2013
Part01: Introduction

    Introduction of OpenGL with code samples.



2                  Part 01 - Introduction   February 13, 2013
Part01 : Topics
       About OpenGL
       OpenGL Versions
       OpenGL Overview
       OpenGL Philosophy
       OpenGL Functionality
       OpenGL Usage
       OpenGL Convention
       OpenGL Basic Concepts
       OpenGL Rendering Pipeline
       Primitives (Points, Lines, Polygon)
       Environment Setup
       Code Samples (Win32/glut)
    3                                Part 01 - Introduction   February 13, 2013
Part01 : About OpenGL
       History
           OpenGL is relatively new (1992) GL from Silicon Graphics
           IrisGL - a 3D API for high-end IRIS graphics workstations
           OpenGL attempts to be more portable
           OpenGL Architecture Review Board (ARB) decides on all
            enhancements
       What it is…
           Software interface to graphics hardware
           About 120 C-callable routines for 3D graphics
           Platform (OS/Hardware) independent graphics library
       What it is not…
           Not a windowing system (no window creation)
           Not a UI system (no keyboard and mouse routines)
           Not a 3D modeling system (Open Inventor, VRML, Java3D)
                                     http://en.wikipedia.org/wiki/OpenGL

    4                                      Part 01 - Introduction   February 13, 2013
Part01 : OpenGL Versions
Version            Release Year
OpenGL 1.0         January, 1992
OpenGL 1.1         January, 1997
OpenGL 1.2         March 16, 1998
OpenGL 1.2.1       October 14, 1998
OpenGL 1.3         August 14, 2001
OpenGL 1.4         July 24, 2002
OpenGL 1.5         July 29, 2003
OpenGL 2.0         September 7, 2004
OpenGL 2.1         July 2, 2006
OpenGL 3.0         July 11, 2008
OpenGL 3.1         March 24, 2009 and updated May 28, 2009
OpenGL 3.2         August 3, 2009 and updated December 7, 2009
OpenGL 3.3         March 11, 2010
OpenGL 4.0         March 11, 2010
OpenGL 4.1         July 26, 2010

5                 Part 01 - Introduction   February 13, 2013
Part01 : Overview
       OpenGL is a procedural graphics language
       programmer describes the steps involved to achieve a
        certain display
       “steps” involve C style function calls to a highly portable
        API
       fairly direct control over fundamental operations of two
        and three dimensional graphics
       an API not a language
       What it can do?
           Display primitives
           Coordinate transformations (transformation matrix
            manipulation)
           Lighting calculations
           Antialiasing
           Pixel Update Operations
           Display-List Mode
    6                                    Part 01 - Introduction   February 13, 2013
Part01 : Philosophy
       Platform independent
       Window system independent
       Rendering only
       Aims to be real-time
       Takes advantage of graphics hardware where it
        exists
       State system
       Client-server system
       Standard supported by major companies


    7                           Part 01 - Introduction   February 13, 2013
Part01 : Functionality
       Simple geometric objects
        (e.g. lines, polygons, rectangles, etc.)
       Transformations, viewing, clipping
       Hidden line & hidden surface removal
       Color, lighting, texture
       Bitmaps, fonts, and images
       Immediate- & Retained- mode graphics
           An immediate-mode API is procedural. Each time a new
            frame is drawn, the application directly issues the drawing
            commands.
           A retained-mode API is declarative. The application
            constructs a scene from graphics primitives, such as
    8       shapes and lines.           Part 01 - Introduction February 13, 2013
Part01 : Usage
       Scientific Visualization
       Information
        Visualization
       Medical Visualization
       CAD
       Games
       Movies
       Virtual Reality
       Architectural
        Walkthrough

    9                              Part 01 - Introduction   February 13, 2013
Part01 : Convention
    Constants:
        prefix GL + all capitals (e.g. GL_COLOR_BUFER_BIT)
    Functions:
        prefix gl + capital first letter (e.g. glClearColor)
            returnType glCommand[234][sifd] (type value, ...);
            returnType glCommand[234][sifd]v (type *value);
    Many variations of the same functions
        glColor[2,3,4][b,s,i,f,d,ub,us,ui](v)
            [2,3,4]: dimension
            [b,s,i,f,d,ub,us,ui]: data type
            (v): optional pointer (vector) representation

                                                 Example:
                                                 glColor3i(1, 0, 0)
                                                 or
                                                 glColor3f(1.0, 1.0, 1.0)
                                                 or
                                                 GLfloat color_array[] = {1.0, 1.0, 1.0};
                                                 glColor3fv(color_array)
    10                                           Part 01 - Introduction   February 13, 2013
Part01 : Basic Concepts
    OpenGL as a state machine (Once the value of a
     property is set, the value persists until a new value is
     given).
    Graphics primitives going through a “pipeline” of
     rendering operations
    OpenGL controls the state of the pipeline with many state
     variables (fg & bg colors, line thickness, texture
     pattern, eyes, lights, surface material, etc.)
    Binary state: glEnable & glDisable
    Query: glGet[Boolean,Integer,Float,Double]
    Coordinates :
     XYZ axis follow Cartesian system.
    11                           Part 01 - Introduction   February 13, 2013
Part01 : Rendering Pipeline
            Primitives               Transformation            Clipping                 Shading           Projection          Rasterisation




        Primitives                 Transformation              Clipping             Shading/Texturing           Projection          Rasterisation




• Lines, Polygons, Triangles   • Modeling Transform   • Parallel/Orthographic     • Material, Lights    • Viewport location    • Images in buffer
• Vertices                       (Transform Matrix)   • Perspective               • Color               • Transformation       • Viewport Transformation
                               • Viewing Transform                                                                             • Images on screen
                                 (Eye, Lookat)




    12                                                                          Part 01 - Introduction         February 13, 2013
Part01 : Primitives (Points, Lines…) - I
    All geometric objects in OpenGL are created from a set of basic
     primitives.
    Certain primitives are provided to allow optimization of geometry for
     improved rendering speed.
    Primitives specified by vertex calls (glVertex*) bracketed by
     glBegin(type) and glEnd()
    Specified by a set of vertices
        glVertex[2,3,4][s,i,f,d](v) (TYPE coords)
 Grouped together by glBegin() & glEnd()
                                                       glBegin(GLenum mode)
glBegin(GL_POLYGON)                                        mode includes
                                                               GL_POINTS
   glVertex3f(…)                                               GL_LINES, GL_LINE_STRIP, GL_LINE_
                                                                LOOP
    glVertex3f(…)                                              GL_POLYGON
   glVertex3f(…)                                               GL_TRIANGLES, GL_TRIANGLE_STRI
                                                                P
glEnd                                                          GL_QUADS, GL_QUAD_STRIP

    13                                       Part 01 - Introduction   February 13, 2013
Part01 : Primitives (Points, Lines…) - II
    Point Type
        GL_POINTS

    Line Type
        GL_LINES
        GL_LINE_STRIP
        GL_LINE_LOOP

    Triangle Type
        GL_TRIANGLES
        GL_TRIANGLE_STRI
         P
        GL_TRIANGLE_FAN

    Quad Type
        GL_QUADS
        GL_QUAD_STRIP

    Polygon Type
        GL_POLYGON


Ref : Drawing Primitives in OpenGL


    14                               Part 01 - Introduction   February 13, 2013
Part01 : Environment Setup
    Using Windows SDK
        OpenGL and OpenGL Utility (GLU) ships with Microsoft SDK.
         Add SDK Path to IDE Project Directories.
        Add Headers: gl.h, glu.h
         Found @ <SDKDIR>Windowsv6.0Aincludegl
        Add Libs for linking: opengl32.lib, glu32.lib
         Found @ <SDKDIR>Windowsv6.0Alib
        Required DLLs: opengl32.dll, glu32.dll
         Found @ <WINDIR> System32
    Using GLUT (www.xmission.com/~nate/glut.html or http://freeglut.sourceforge.net)
        Store the Binaries at appropriate location and reference it properly
        Add Header: glut.h
         Found @ <GLUTPATH>include
        Add Lib for linking: glut32.lib
         Found @ <GLUTPATH>lib
        Required DLL: glut32.dll
         Found @ <GLUTPATH>bin


    15                                         Part 01 - Introduction   February 13, 2013
Part01 : Code Samples
    Using Windows SDK
        Create Basic Window from the Windows Base Code.
        Add Headers & Libs.
        Modify the Windows Class Registration.
        Modify the Window Creation Code.
            Setup PixelFormat.
            Create Rendering Context and set it current.
        Add Cleanup code where remove rendering context.
        Add Event Handlers
            Add Display function handler for rendering OpenGL stuff.
            Add Resize function handler for window resizing.
    Using GLUT
        Add Headers and Libs.
        Initialize the GLUT system and create basic window.
        Add Event Handlers
            Add Display, Resize, Idle, Keyboard, Mouse handlers.

    16                                         Part 01 - Introduction   February 13, 2013
Part02: Basics

     Introduction of OpenGL with code samples.



17                     Part 02 - Basics   February 13, 2013
Part02 : Topics
    Transformations
        Modeling
            Concept of Matrices.
            Scaling, Rotation, Translation
        Viewing
            Camera
            Projection: Ortho/Perspective
    Code Samples (Win32/glut)




    18                                        Part 02 - Basics   February 13, 2013
Part02 : Transformations-Modeling I
    Concept of Matrices.
        All affine operations are matrix multiplications.
        A 3D vertex is represented by a 4-tuple (column) vector.
        A vertex is transformed by 4 x 4 matrices.
        All matrices are stored column-major in OpenGL
        Matrices are always post-multiplied. product of matrix and
         vector is Mv. OpenGL only multiplies a matrix on the
         right, the programmer must remember that the last matrix
         specified is the first applied.
                                             x
                                                             m0    m4     m8     m12
                                             y
                                      v            M
                                                             m1    m5     m9     m13
                                             z               m2    m6     m10    m14
                                             w               m3    m7     m11    m15
    19                                    Part 02 - Basics   February 13, 2013
Part02 : Transformations-Modeling II
 OpenGL uses stacks to maintain transformation matrices
  (MODELVIEW stack is the most important)
 You can load, push and pop the stack
 The current transform is applied to all graphics primitive until it is
  changed
2 ways of specifying Transformation Matrices.
    Using crude Matrices.                 Using built-in routines.
        Specify current Matrix                glTranslate[f,d](x,y,z)
         glMatrixMode(GLenum mode)             glRotate[f,d](angle,x,y,z)
        Initialize current Matrix             glScale[f,d](x,y,z)
         glLoadIdentity(void)                  Order is important
         glLoadMatrix[f,d](const TYPE
         *m)
        Concatenate current Matrix
         glMultMatrix(const TYPE *m)



    20                                      Part 02 - Basics   February 13, 2013
Part02 : Transformations-Viewing I
    Camera.
        Default: eyes at origin, looking along -Z
        Important parameters:
            Where is the observer (camera)? Origin.
            What is the look-at direction? -z direction.
            What is the head-up direction? y direction.
        gluLookAt(
         eyex, eyey, eyez, aimx, aimy, aimz, upx, upy, upz )
            gluLookAt() multiplies itself onto the current matrix, so it usually
             comes after glMatrixMode(GL_MODELVIEW) and
             glLoadIdentity().




    21                                          Part 02 - Basics   February 13, 2013
Part02 : Transformations-Viewing II
    Projection
        Perspective projection
            gluPerspective( fovy, aspect, zNear, zFar )
            glFrustum( left, right, bottom, top, zNear, zFar )
        Orthographic parallel projection
            glOrtho( left, right, bottom, top, zNear, zFar )
            gluOrtho2D( left, right, bottom, top )
    Projection transformations
     (gluPerspective, glOrtho) are left handed
        Everything else is right handed, including the                          y
         vertexes to be rendered               y     z+

                                                                                          x
                                                                    x
                                                         left handed        z    right
                                                                            +    handed
    22                                          Part 02 - Basics   February 13, 2013
Part02 : Transformations-Viewing III
    glFrustum(left, right, bottom, top, zNear, zFar)




    gluPerspective(fovy, aspect, zNear, zFar)




    glOrtho(left, right, bottom, top, zNear, zFar)




    23                                           Part 02 - Basics   February 13, 2013
Part02 : Code Samples

Ortho              Perspective




24                   Part 02 - Basics   February 13, 2013

More Related Content

What's hot

OpenGL basics
OpenGL basicsOpenGL basics
OpenGL basics
Mohammad Hosein Nemati
 
Introduction to 2D/3D Graphics
Introduction to 2D/3D GraphicsIntroduction to 2D/3D Graphics
Introduction to 2D/3D Graphics
Prabindh Sundareson
 
Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
elnaqah
 
Open gl
Open glOpen gl
Open gl
ch samaram
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICS
nehrurevathy
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
Mani Kanth
 
Computer animation
Computer animationComputer animation
Computer animation
shusrusha
 
Shading
ShadingShading
Shading
Amit Kapoor
 
OpenGL Texture Mapping
OpenGL Texture MappingOpenGL Texture Mapping
OpenGL Texture Mapping
Syed Zaid Irshad
 
Open Graphics Library
Open Graphics  Library Open Graphics  Library
Open Graphics Library
Azmeen Gadit
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
Arvind Kumar
 
UNIT-IV
UNIT-IVUNIT-IV
3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals
Muhammed Afsal Villan
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
KKARUNKARTHIK
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
Sanu Philip
 
Computer Graphics
Computer GraphicsComputer Graphics
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphics
Aaina Katyal
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine Architecture
Attila Jenei
 
Parallel projection
Parallel projectionParallel projection
Parallel projection
Prince Shahu
 
Lighting and shading
Lighting and shadingLighting and shading
Lighting and shading
Sri Harsha Vemuri
 

What's hot (20)

OpenGL basics
OpenGL basicsOpenGL basics
OpenGL basics
 
Introduction to 2D/3D Graphics
Introduction to 2D/3D GraphicsIntroduction to 2D/3D Graphics
Introduction to 2D/3D Graphics
 
Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
 
Open gl
Open glOpen gl
Open gl
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICS
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
 
Computer animation
Computer animationComputer animation
Computer animation
 
Shading
ShadingShading
Shading
 
OpenGL Texture Mapping
OpenGL Texture MappingOpenGL Texture Mapping
OpenGL Texture Mapping
 
Open Graphics Library
Open Graphics  Library Open Graphics  Library
Open Graphics Library
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
 
UNIT-IV
UNIT-IVUNIT-IV
UNIT-IV
 
3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphics
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine Architecture
 
Parallel projection
Parallel projectionParallel projection
Parallel projection
 
Lighting and shading
Lighting and shadingLighting and shading
Lighting and shading
 

Viewers also liked

OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
Yi-Lung Tsai
 
OpenGL L01-Primitives
OpenGL L01-PrimitivesOpenGL L01-Primitives
OpenGL L01-Primitives
Mohammad Shaker
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
Mark Kilgard
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012
Mark Kilgard
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
Sandip Jadhav
 
OpenGL Starter L01
OpenGL Starter L01OpenGL Starter L01
OpenGL Starter L01
Mohammad Shaker
 
Web Introduction
Web IntroductionWeb Introduction
Web Introduction
Jayant Mukherjee
 
Animation basics
Animation basicsAnimation basics
Animation basics
sheshi kumar
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and Terrian
Mohammad Shaker
 
3 d projections
3 d projections3 d projections
3 d projections
Mohd Arif
 
Illumination model
Illumination modelIllumination model
Illumination model
Ankur Kumar
 
Cs559 11
Cs559 11Cs559 11
Cs559 11
Arun Kandukuri
 
Instancing
InstancingInstancing
Instancing
acbess
 
What is direct X ?
What is direct X ?What is direct X ?
What is direct X ?
Mukul Kumar
 
Introduction to DirectX 11
Introduction to DirectX 11Introduction to DirectX 11
Introduction to DirectX 11
Krzysztof Marciniak
 
Protein structure by Pauling & corey
Protein structure by Pauling & coreyProtein structure by Pauling & corey
Protein structure by Pauling & corey
CIMAP
 
Direct X
Direct XDirect X
Direct X
Yash Mittal
 
Opengl lec 3
Opengl lec 3Opengl lec 3
Opengl lec 3
elnaqah
 
3 d graphics with opengl part 2
3 d graphics with opengl  part 23 d graphics with opengl  part 2
3 d graphics with opengl part 2
Sardar Alam
 

Viewers also liked (20)

OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
OpenGL L01-Primitives
OpenGL L01-PrimitivesOpenGL L01-Primitives
OpenGL L01-Primitives
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
 
OpenGL Starter L01
OpenGL Starter L01OpenGL Starter L01
OpenGL Starter L01
 
Web Introduction
Web IntroductionWeb Introduction
Web Introduction
 
Animation basics
Animation basicsAnimation basics
Animation basics
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and Terrian
 
3 d projections
3 d projections3 d projections
3 d projections
 
Illumination model
Illumination modelIllumination model
Illumination model
 
Cs559 11
Cs559 11Cs559 11
Cs559 11
 
Instancing
InstancingInstancing
Instancing
 
Presentatie Lucas Hulsebos DWWA 2008
Presentatie Lucas Hulsebos DWWA 2008Presentatie Lucas Hulsebos DWWA 2008
Presentatie Lucas Hulsebos DWWA 2008
 
What is direct X ?
What is direct X ?What is direct X ?
What is direct X ?
 
Introduction to DirectX 11
Introduction to DirectX 11Introduction to DirectX 11
Introduction to DirectX 11
 
Protein structure by Pauling & corey
Protein structure by Pauling & coreyProtein structure by Pauling & corey
Protein structure by Pauling & corey
 
Direct X
Direct XDirect X
Direct X
 
Opengl lec 3
Opengl lec 3Opengl lec 3
Opengl lec 3
 
3 d graphics with opengl part 2
3 d graphics with opengl  part 23 d graphics with opengl  part 2
3 d graphics with opengl part 2
 

Similar to OpenGL Introduction

openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).ppt
HIMANKMISHRA2
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
HIMANKMISHRA2
 
18csl67 vtu lab manual
18csl67 vtu lab manual18csl67 vtu lab manual
18csl67 vtu lab manual
NatsuDragoneel5
 
Bai 1
Bai 1Bai 1
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
ch samaram
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
Mohammed Romi
 
1 introduction computer graphics
1 introduction computer graphics1 introduction computer graphics
1 introduction computer graphics
cairo university
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
Prabindh Sundareson
 
Open gl introduction
Open gl introduction Open gl introduction
Open gl introduction
abigail Dayrit
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
Mark Kilgard
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
Rup Chowdhury
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI Platforms
Prabindh Sundareson
 
3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx
ssuser255bf1
 
Android native gl
Android native glAndroid native gl
Android native gl
Miguel Angel Alcalde Velado
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
ICS
 
CGLabLec6.pptx
CGLabLec6.pptxCGLabLec6.pptx
CGLabLec6.pptx
Mohammad7Abudosh7
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
Jungsoo Nam
 
Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL
Sharath Raj
 
Mini Project final report on " LEAKY BUCKET ALGORITHM "
Mini Project final report on " LEAKY BUCKET ALGORITHM "Mini Project final report on " LEAKY BUCKET ALGORITHM "
Mini Project final report on " LEAKY BUCKET ALGORITHM "
Nikhil Jain
 
Data structures graphics library in computer graphics.
Data structures  graphics library in computer graphics.Data structures  graphics library in computer graphics.
Data structures graphics library in computer graphics.
Daroko blog(www.professionalbloggertricks.com)
 

Similar to OpenGL Introduction (20)

openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).ppt
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
 
18csl67 vtu lab manual
18csl67 vtu lab manual18csl67 vtu lab manual
18csl67 vtu lab manual
 
Bai 1
Bai 1Bai 1
Bai 1
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
 
1 introduction computer graphics
1 introduction computer graphics1 introduction computer graphics
1 introduction computer graphics
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
Open gl introduction
Open gl introduction Open gl introduction
Open gl introduction
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
 
OpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI PlatformsOpenGL ES based UI Development on TI Platforms
OpenGL ES based UI Development on TI Platforms
 
3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx
 
Android native gl
Android native glAndroid native gl
Android native gl
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
CGLabLec6.pptx
CGLabLec6.pptxCGLabLec6.pptx
CGLabLec6.pptx
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL
 
Mini Project final report on " LEAKY BUCKET ALGORITHM "
Mini Project final report on " LEAKY BUCKET ALGORITHM "Mini Project final report on " LEAKY BUCKET ALGORITHM "
Mini Project final report on " LEAKY BUCKET ALGORITHM "
 
Data structures graphics library in computer graphics.
Data structures  graphics library in computer graphics.Data structures  graphics library in computer graphics.
Data structures graphics library in computer graphics.
 

Recently uploaded

Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 

Recently uploaded (20)

Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 

OpenGL Introduction

  • 1. OpenGL Training/Tutorial Jayant Mukherjee 1 February 13, 2013
  • 2. Part01: Introduction Introduction of OpenGL with code samples. 2 Part 01 - Introduction February 13, 2013
  • 3. Part01 : Topics  About OpenGL  OpenGL Versions  OpenGL Overview  OpenGL Philosophy  OpenGL Functionality  OpenGL Usage  OpenGL Convention  OpenGL Basic Concepts  OpenGL Rendering Pipeline  Primitives (Points, Lines, Polygon)  Environment Setup  Code Samples (Win32/glut) 3 Part 01 - Introduction February 13, 2013
  • 4. Part01 : About OpenGL  History  OpenGL is relatively new (1992) GL from Silicon Graphics  IrisGL - a 3D API for high-end IRIS graphics workstations  OpenGL attempts to be more portable  OpenGL Architecture Review Board (ARB) decides on all enhancements  What it is…  Software interface to graphics hardware  About 120 C-callable routines for 3D graphics  Platform (OS/Hardware) independent graphics library  What it is not…  Not a windowing system (no window creation)  Not a UI system (no keyboard and mouse routines)  Not a 3D modeling system (Open Inventor, VRML, Java3D) http://en.wikipedia.org/wiki/OpenGL 4 Part 01 - Introduction February 13, 2013
  • 5. Part01 : OpenGL Versions Version Release Year OpenGL 1.0 January, 1992 OpenGL 1.1 January, 1997 OpenGL 1.2 March 16, 1998 OpenGL 1.2.1 October 14, 1998 OpenGL 1.3 August 14, 2001 OpenGL 1.4 July 24, 2002 OpenGL 1.5 July 29, 2003 OpenGL 2.0 September 7, 2004 OpenGL 2.1 July 2, 2006 OpenGL 3.0 July 11, 2008 OpenGL 3.1 March 24, 2009 and updated May 28, 2009 OpenGL 3.2 August 3, 2009 and updated December 7, 2009 OpenGL 3.3 March 11, 2010 OpenGL 4.0 March 11, 2010 OpenGL 4.1 July 26, 2010 5 Part 01 - Introduction February 13, 2013
  • 6. Part01 : Overview  OpenGL is a procedural graphics language  programmer describes the steps involved to achieve a certain display  “steps” involve C style function calls to a highly portable API  fairly direct control over fundamental operations of two and three dimensional graphics  an API not a language  What it can do?  Display primitives  Coordinate transformations (transformation matrix manipulation)  Lighting calculations  Antialiasing  Pixel Update Operations  Display-List Mode 6 Part 01 - Introduction February 13, 2013
  • 7. Part01 : Philosophy  Platform independent  Window system independent  Rendering only  Aims to be real-time  Takes advantage of graphics hardware where it exists  State system  Client-server system  Standard supported by major companies 7 Part 01 - Introduction February 13, 2013
  • 8. Part01 : Functionality  Simple geometric objects (e.g. lines, polygons, rectangles, etc.)  Transformations, viewing, clipping  Hidden line & hidden surface removal  Color, lighting, texture  Bitmaps, fonts, and images  Immediate- & Retained- mode graphics  An immediate-mode API is procedural. Each time a new frame is drawn, the application directly issues the drawing commands.  A retained-mode API is declarative. The application constructs a scene from graphics primitives, such as 8 shapes and lines. Part 01 - Introduction February 13, 2013
  • 9. Part01 : Usage  Scientific Visualization  Information Visualization  Medical Visualization  CAD  Games  Movies  Virtual Reality  Architectural Walkthrough 9 Part 01 - Introduction February 13, 2013
  • 10. Part01 : Convention  Constants:  prefix GL + all capitals (e.g. GL_COLOR_BUFER_BIT)  Functions:  prefix gl + capital first letter (e.g. glClearColor)  returnType glCommand[234][sifd] (type value, ...);  returnType glCommand[234][sifd]v (type *value);  Many variations of the same functions  glColor[2,3,4][b,s,i,f,d,ub,us,ui](v)  [2,3,4]: dimension  [b,s,i,f,d,ub,us,ui]: data type  (v): optional pointer (vector) representation Example: glColor3i(1, 0, 0) or glColor3f(1.0, 1.0, 1.0) or GLfloat color_array[] = {1.0, 1.0, 1.0}; glColor3fv(color_array) 10 Part 01 - Introduction February 13, 2013
  • 11. Part01 : Basic Concepts  OpenGL as a state machine (Once the value of a property is set, the value persists until a new value is given).  Graphics primitives going through a “pipeline” of rendering operations  OpenGL controls the state of the pipeline with many state variables (fg & bg colors, line thickness, texture pattern, eyes, lights, surface material, etc.)  Binary state: glEnable & glDisable  Query: glGet[Boolean,Integer,Float,Double]  Coordinates : XYZ axis follow Cartesian system. 11 Part 01 - Introduction February 13, 2013
  • 12. Part01 : Rendering Pipeline Primitives Transformation Clipping Shading Projection Rasterisation Primitives Transformation Clipping Shading/Texturing Projection Rasterisation • Lines, Polygons, Triangles • Modeling Transform • Parallel/Orthographic • Material, Lights • Viewport location • Images in buffer • Vertices (Transform Matrix) • Perspective • Color • Transformation • Viewport Transformation • Viewing Transform • Images on screen (Eye, Lookat) 12 Part 01 - Introduction February 13, 2013
  • 13. Part01 : Primitives (Points, Lines…) - I  All geometric objects in OpenGL are created from a set of basic primitives.  Certain primitives are provided to allow optimization of geometry for improved rendering speed.  Primitives specified by vertex calls (glVertex*) bracketed by glBegin(type) and glEnd()  Specified by a set of vertices  glVertex[2,3,4][s,i,f,d](v) (TYPE coords)  Grouped together by glBegin() & glEnd()  glBegin(GLenum mode) glBegin(GL_POLYGON)  mode includes  GL_POINTS glVertex3f(…)  GL_LINES, GL_LINE_STRIP, GL_LINE_ LOOP glVertex3f(…)  GL_POLYGON glVertex3f(…)  GL_TRIANGLES, GL_TRIANGLE_STRI P glEnd  GL_QUADS, GL_QUAD_STRIP 13 Part 01 - Introduction February 13, 2013
  • 14. Part01 : Primitives (Points, Lines…) - II  Point Type  GL_POINTS  Line Type  GL_LINES  GL_LINE_STRIP  GL_LINE_LOOP  Triangle Type  GL_TRIANGLES  GL_TRIANGLE_STRI P  GL_TRIANGLE_FAN  Quad Type  GL_QUADS  GL_QUAD_STRIP  Polygon Type  GL_POLYGON Ref : Drawing Primitives in OpenGL 14 Part 01 - Introduction February 13, 2013
  • 15. Part01 : Environment Setup  Using Windows SDK  OpenGL and OpenGL Utility (GLU) ships with Microsoft SDK. Add SDK Path to IDE Project Directories.  Add Headers: gl.h, glu.h Found @ <SDKDIR>Windowsv6.0Aincludegl  Add Libs for linking: opengl32.lib, glu32.lib Found @ <SDKDIR>Windowsv6.0Alib  Required DLLs: opengl32.dll, glu32.dll Found @ <WINDIR> System32  Using GLUT (www.xmission.com/~nate/glut.html or http://freeglut.sourceforge.net)  Store the Binaries at appropriate location and reference it properly  Add Header: glut.h Found @ <GLUTPATH>include  Add Lib for linking: glut32.lib Found @ <GLUTPATH>lib  Required DLL: glut32.dll Found @ <GLUTPATH>bin 15 Part 01 - Introduction February 13, 2013
  • 16. Part01 : Code Samples  Using Windows SDK  Create Basic Window from the Windows Base Code.  Add Headers & Libs.  Modify the Windows Class Registration.  Modify the Window Creation Code.  Setup PixelFormat.  Create Rendering Context and set it current.  Add Cleanup code where remove rendering context.  Add Event Handlers  Add Display function handler for rendering OpenGL stuff.  Add Resize function handler for window resizing.  Using GLUT  Add Headers and Libs.  Initialize the GLUT system and create basic window.  Add Event Handlers  Add Display, Resize, Idle, Keyboard, Mouse handlers. 16 Part 01 - Introduction February 13, 2013
  • 17. Part02: Basics Introduction of OpenGL with code samples. 17 Part 02 - Basics February 13, 2013
  • 18. Part02 : Topics  Transformations  Modeling  Concept of Matrices.  Scaling, Rotation, Translation  Viewing  Camera  Projection: Ortho/Perspective  Code Samples (Win32/glut) 18 Part 02 - Basics February 13, 2013
  • 19. Part02 : Transformations-Modeling I  Concept of Matrices.  All affine operations are matrix multiplications.  A 3D vertex is represented by a 4-tuple (column) vector.  A vertex is transformed by 4 x 4 matrices.  All matrices are stored column-major in OpenGL  Matrices are always post-multiplied. product of matrix and vector is Mv. OpenGL only multiplies a matrix on the right, the programmer must remember that the last matrix specified is the first applied. x m0 m4 m8 m12  y v M m1 m5 m9 m13 z m2 m6 m10 m14 w m3 m7 m11 m15 19 Part 02 - Basics February 13, 2013
  • 20. Part02 : Transformations-Modeling II  OpenGL uses stacks to maintain transformation matrices (MODELVIEW stack is the most important)  You can load, push and pop the stack  The current transform is applied to all graphics primitive until it is changed 2 ways of specifying Transformation Matrices.  Using crude Matrices.  Using built-in routines.  Specify current Matrix  glTranslate[f,d](x,y,z) glMatrixMode(GLenum mode)  glRotate[f,d](angle,x,y,z)  Initialize current Matrix  glScale[f,d](x,y,z) glLoadIdentity(void)  Order is important glLoadMatrix[f,d](const TYPE *m)  Concatenate current Matrix glMultMatrix(const TYPE *m) 20 Part 02 - Basics February 13, 2013
  • 21. Part02 : Transformations-Viewing I  Camera.  Default: eyes at origin, looking along -Z  Important parameters:  Where is the observer (camera)? Origin.  What is the look-at direction? -z direction.  What is the head-up direction? y direction.  gluLookAt( eyex, eyey, eyez, aimx, aimy, aimz, upx, upy, upz )  gluLookAt() multiplies itself onto the current matrix, so it usually comes after glMatrixMode(GL_MODELVIEW) and glLoadIdentity(). 21 Part 02 - Basics February 13, 2013
  • 22. Part02 : Transformations-Viewing II  Projection  Perspective projection  gluPerspective( fovy, aspect, zNear, zFar )  glFrustum( left, right, bottom, top, zNear, zFar )  Orthographic parallel projection  glOrtho( left, right, bottom, top, zNear, zFar )  gluOrtho2D( left, right, bottom, top )  Projection transformations (gluPerspective, glOrtho) are left handed  Everything else is right handed, including the y vertexes to be rendered y z+ x x left handed z right + handed 22 Part 02 - Basics February 13, 2013
  • 23. Part02 : Transformations-Viewing III  glFrustum(left, right, bottom, top, zNear, zFar)  gluPerspective(fovy, aspect, zNear, zFar)  glOrtho(left, right, bottom, top, zNear, zFar) 23 Part 02 - Basics February 13, 2013
  • 24. Part02 : Code Samples Ortho Perspective 24 Part 02 - Basics February 13, 2013

Editor's Notes

  1. Why is a 4-tuple vector used for a 3D (x, y, z) vertex? To ensure that all matrix operations are multiplications. w is usually 1.0If w is changed from 1.0, we can recover x, y and z by division by w. Generally, only perspective transformations change w and require this perspective division in the pipeline.
  2. For perspective projections, the viewing volume is shaped like a truncated pyramid (frustum). There is a distinct camera (eye) position, and vertexes of objects are “projected” to camera. Objects which are further from the camera appear smaller. The default camera position at (0, 0, 0), looks down the z-axis, although the camera can be moved by other transformations.ForgluPerspective(), fovyis the angle of field of view (in degrees) in the y direction. fovymust be between 0.0 and 180.0, exclusive. aspect is x/y and should be same as the viewport to avoid distortion. zNearand zFardefine the distance to the near and far clipping planes.glFrustum() is rarely used. Warning: for gluPerspective() or glFrustum(), don’t use zero for zNear!For glOrtho(), the viewing volume is shaped like a rectangular parallelepiped (a box). Vertexes of an object are “projected” towards infinity. Distance does not change the apparent size of an object. Orthographic projection is used for drafting and design (such as blueprints).