SlideShare uma empresa Scribd logo
1 de 24
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

Mais conteúdo relacionado

Mais procurados

Opengl presentation
Opengl presentationOpengl presentation
Opengl presentationelnaqah
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadTristan Lorach
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGLGary Yeh
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmrajivagarwal23dei
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithmKKARUNKARTHIK
 
3D Transformation
3D Transformation3D Transformation
3D TransformationSwatiHans10
 
Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Iftikhar Ahmad
 
[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization Guides[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization GuidesOwen Wu
 
SIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGLSIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGLMark Kilgard
 
introduction to Digital Image Processing
introduction to Digital Image Processingintroduction to Digital Image Processing
introduction to Digital Image Processingnikesh gadare
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overheadCass Everitt
 
Graphics hardware and introduction to Raster display system
Graphics hardware and introduction to Raster display systemGraphics hardware and introduction to Raster display system
Graphics hardware and introduction to Raster display systemmahamiqbalrajput
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)Philip Hammer
 
Introduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLABIntroduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLABRay Phan
 
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...rohitjasudkar
 

Mais procurados (20)

Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
Open gl
Open glOpen gl
Open gl
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2
 
[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization Guides[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization Guides
 
SIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGLSIGGRAPH Asia 2008 Modern OpenGL
SIGGRAPH Asia 2008 Modern OpenGL
 
introduction to Digital Image Processing
introduction to Digital Image Processingintroduction to Digital Image Processing
introduction to Digital Image Processing
 
OpenGL ES 3 Reference Card
OpenGL ES 3 Reference CardOpenGL ES 3 Reference Card
OpenGL ES 3 Reference Card
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
ANIMATION SEQUENCE
ANIMATION SEQUENCEANIMATION SEQUENCE
ANIMATION SEQUENCE
 
Graphics hardware and introduction to Raster display system
Graphics hardware and introduction to Raster display systemGraphics hardware and introduction to Raster display system
Graphics hardware and introduction to Raster display system
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
 
Introduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLABIntroduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLAB
 
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
Computer Graphics (Hidden surfaces and line removal, Curves and surfaces, Sur...
 
Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
 

Destaque

OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL IntroductionYi-Lung Tsai
 
NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityMark Kilgard
 
SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012SIGGRAPH 2012: NVIDIA OpenGL for 2012
SIGGRAPH 2012: NVIDIA OpenGL for 2012Mark Kilgard
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL TransformationSandip Jadhav
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianMohammad Shaker
 
3 d projections
3 d projections3 d projections
3 d projectionsMohd Arif
 
Illumination model
Illumination modelIllumination model
Illumination modelAnkur Kumar
 
Instancing
InstancingInstancing
Instancingacbess
 
What is direct X ?
What is direct X ?What is direct X ?
What is direct X ?Mukul Kumar
 
Protein structure by Pauling & corey
Protein structure by Pauling & coreyProtein structure by Pauling & corey
Protein structure by Pauling & coreyCIMAP
 
Opengl lec 3
Opengl lec 3Opengl lec 3
Opengl lec 3elnaqah
 
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 2Sardar Alam
 

Destaque (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
 

Semelhante a 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).pptHIMANKMISHRA2
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.pptHIMANKMISHRA2
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programmingMohammed Romi
 
1 introduction computer graphics
1 introduction computer graphics1 introduction computer graphics
1 introduction computer graphicscairo university
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Prabindh Sundareson
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark 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 GraphicsRup 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 PlatformsPrabindh 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.pptxssuser255bf1
 
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
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGLJungsoo 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
 

Semelhante a 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
 
Introduction to 2D/3D Graphics
Introduction to 2D/3D GraphicsIntroduction to 2D/3D Graphics
Introduction to 2D/3D Graphics
 
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 "
 

Último

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Último (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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

Notas do Editor

  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).