SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphicssabbirantor
 
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLahiru Danushka
 
Parallel projection
Parallel projectionParallel projection
Parallel projectionPrince Shahu
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentationRamyaRavi26
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer GraphicsSanu Philip
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overheadCass Everitt
 
3D Transformation
3D Transformation3D Transformation
3D TransformationSwatiHans10
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clippingMani Kanth
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithmKKARUNKARTHIK
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standardsMani Kanth
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"Ankit Surti
 
Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Mani Kanth
 
Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)RohitK71
 
Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniquesMani Kanth
 

La actualidad más candente (20)

Shading methods
Shading methodsShading methods
Shading methods
 
Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
 
Open gl
Open glOpen gl
Open gl
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
 
Parallel projection
Parallel projectionParallel projection
Parallel projection
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentation
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - Shading
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
fractals
fractalsfractals
fractals
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"
 
Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...
 
Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
 
Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniques
 

Destacado

Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGLGary Yeh
 
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
 

Destacado (20)

Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
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
 

Similar 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
 

Similar 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
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
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
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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