SlideShare ist ein Scribd-Unternehmen logo
1 von 75
OpenGL &
            Computer Graphics Basic




                          http://www.learncax.com/



                                        Centre for Computational Technologies
CCTech Recruitment Brochure                             Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                    Centre for Computational Technologies
      OpenGL                                        Simulation is The Future!
Textbook




OpenGL Programming
Guide, Fourth Edition: The
Official Guide to Learning
OpenGL, Version 1.5, by Woo
et al., Addison Wesley, ISBN:
0201604582.




                                Centre for Computational Technologies
OpenGL                                          Simulation is The Future!
Basic goal
• Teach you the fundamentals for writing your own
  graphics applications




                               Centre for Computational Technologies
    OpenGL                                     Simulation is The Future!
Evolution




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
PC Architecture




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
Programming Graphics Applications
• The application is programmed to the 3D graphics API and
  links with the driver at runtime




                                 Centre for Computational Technologies
     OpenGL                                      Simulation is The Future!
The Graphics Pipeline




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
The Graphics Pipeline




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
The Graphics Pipeline
          SolidWorks:
          define software behavior
          user input events
          Software logic
          CAD operations




                Centre for Computational Technologies
OpenGL                           Simulation is The Future!
The Graphics Pipeline

          SolidWorks:
          send OpenGL commands

          OpenGL driver:
          process GL command stream
          talk to GPU




               Centre for Computational Technologies
OpenGL                         Simulation is The Future!
The Graphics Pipeline




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
The Graphics Pipeline




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
The Graphics Pipeline




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
The Graphics Pipeline




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
Rasterization vs. Ray Tracing




               Centre for Computational Technologies
OpenGL                         Simulation is The Future!
Rasterization vs. Ray Tracing
• Rasterization:
• for each object ...
   – for each pixel ...


• Ray tracing:
• for each pixel ...
   – for each object ...




                                 Centre for Computational Technologies
     OpenGL                                      Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                     Centre for Computational Technologies
      OpenGL                                         Simulation is The Future!
Computer Graphics Applications
•   Computer Aided Design
•   Computer Aided Manufacturing
•   Architecture
•   Simulation
•   Virtual Reality
•   Visualization
•   Games
•   Movies 
•   Medical Imaging



                                   Centre for Computational Technologies
      OpenGL                                       Simulation is The Future!
Computer Aided Design (CAD)




               Centre for Computational Technologies
OpenGL                         Simulation is The Future!
Movies




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
Games




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
Visualization




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
Virtual and Augmented Reality




                Centre for Computational Technologies
OpenGL                          Simulation is The Future!
Mobile Media




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!
New Information Spaces




          Centre for Computational Technologies
OpenGL                    Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                     Centre for Computational Technologies
      OpenGL                                         Simulation is The Future!
Programming a Pipeline




•   Specify the operation of each box
•   Replace or accumulate
•   State and lack of modularity
•   Immediate mode graphics
    – On-line (OpenGL)
• Modeling-rendering pipeline
    – Off-line (Pixar’s Renderman)



                                      Centre for Computational Technologies
      OpenGL                                          Simulation is The Future!
Vertex




• Vertices in world coordinates
• void glVertex3f(GLfloat x, GLfloat y, GLfloat z)
   – Vertex (x, y, z) sent down the pipeline
   – Function call returns
• Use GLtype for portability and consistency
   – glVertex{234}{sfid}[v](TYPE coords)




                                         Centre for Computational Technologies
     OpenGL                                              Simulation is The Future!
Transformer




• Transformer in world coordinates
• Must be set before object is drawn!
   – glRotatef(45.0, 0.0, 0.0, -1.0);
   – glVertex2f(1.0, 0.0);




                                        Centre for Computational Technologies
     OpenGL                                             Simulation is The Future!
Clipper



• Mostly automatic from viewport




                                   Centre for Computational Technologies
     OpenGL                                        Simulation is The Future!
Projector



Orthographic   Perspective




               Centre for Computational Technologies
    OpenGL                     Simulation is The Future!
Rasterizer




•   Interesting algorithms
•   To window coordinates




                             Centre for Computational Technologies
       OpenGL                                Simulation is The Future!
The OpenGL Vertex Pipeline




                        Centre for Computational Technologies
OpenGL                                  Simulation is The Future!
OpenGL shaded-quad code
glClearColor(1, 1, 1, 1);          // white
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glOrtho(0, 100, 0, 100, -1, 1);
glBegin(GL_TRIANGLE_STRIP);
  glColor3f(0, 0.5, 0); // dark green
  glVertex2i(11, 31);
  glVertex2i(37, 71);
  glColor3f(0.5, 0, 0); // dark red
  glVertex2i(91, 38);
  glVertex2i(65, 71);
glEnd();
glFlush();
                                  Centre for Computational Technologies
  OpenGL                                          Simulation is The Future!
OpenGL vertex pipeline
                                                    Application
Emphasis is on data types
Diagram ignores                                   Vertex assembly
    – Pixel pipeline
    – Texture memory                             Vertex operations
    – Display lists
                                                 Primitive assembly
    – …
Display is not part of OpenGL                   Primitive operations

                                                    Rasterization

                                                Fragment operations

                                                    Framebuffer

                                                       Display
                                   Centre for Computational Technologies
    OpenGL                                         Simulation is The Future!
Vertex assembly (data types)
                                             Application
         struct {
                                           Vertex assembly
           float x,y,z,w;
           float r,g,b,a;
                                          Vertex operations
         } vertex;
                                          Primitive assembly

                                         Primitive operations

                                             Rasterization

                                         Fragment operations

                                             Framebuffer

                                                Display
                            Centre for Computational Technologies
OpenGL                                      Simulation is The Future!
Vertex assembly (OpenGL)
Vertex assembly                                             Application
    – Force input to canonical format
        • Convert to internal representation              Vertex assembly
             – E.g., x, y to float
        • Initialize unspecified values
                                                         Vertex operations
             – E.g., z = 0, w=1
        • Insert current modal state
             – E.g., color to 0,0.5,0,1                  Primitive assembly
    – Or create using evaluators
Error detection                                         Primitive operations
    – INVALID_ENUM
    – INVALID_VALUE                                         Rasterization
    – INVALID_OPERATION
        • Especially between Begin and End
                                                        Fragment operations

                                                            Framebuffer

                                                               Display
                                           Centre for Computational Technologies
    OpenGL                                                 Simulation is The Future!
Vertex assembly (in our case)
glColor3f(0, 0.5, 0);                           Application
glVertex2i(11, 31);
glVertex2i(37, 71);                           Vertex assembly
glColor3f(0.5, 0, 0); // no effect
                                             Vertex operations

                                             Primitive assembly

struct {                                    Primitive operations
  float x,y,z,w; // 11, 31, 0, 1
  float r,g,b,a; // 0, 0.5, 0, 1                Rasterization
} vertex;
                                            Fragment operations
struct {
  float x,y,z,w; // 37, 71, 0, 1
                                                Framebuffer
  float r,g,b,a; // 0, 0.5, 0, 1
} vertex;
                                                   Display
                               Centre for Computational Technologies
  OpenGL                                       Simulation is The Future!
Vertex operations
                                                         Application
OpenGL
   – Transform coordinates                             Vertex assembly
        • 4x4 matrix arithmetic
    – Compute (vertex) lighting                       Vertex operations
    – Compute texture coordinates
                                                      Primitive assembly
    – …
In our case:                                         Primitive operations
    – Scale (arbitrary 100x100) coordinates to fit
       window                                            Rasterization
    – No lighting, no texture coordinates
                                                     Fragment operations

                                                         Framebuffer

                                                            Display
                                        Centre for Computational Technologies
    OpenGL                                              Simulation is The Future!
Primitive assembly (data types)
                                               Application
         struct {
                                             Vertex assembly
           float x,y,z,w;
           float r,g,b,a;
                                            Vertex operations
         } vertex;

         struct {                           Primitive assembly
           vertex v0,v1,v2;
                                           Primitive operations
         } triangle;
             or
                                               Rasterization
         struct {
           vertex v0,v1;                   Fragment operations
         } line;
             or                                Framebuffer
         struct {
           vertex v0;                             Display
         } point;             Centre for Computational Technologies
OpenGL                                        Simulation is The Future!
Primitive assembly
OpenGL                                                    Application
   – Group vertexes into primitives:
          • points,                                     Vertex assembly
          • lines, or
          • triangles                                  Vertex operations
    – Decompose polygons to triangles
    – Duplicate vertexes in strips or fans             Primitive assembly
In our case:
    – Create two triangles from a strip:              Primitive operations

                                                          Rasterization

                              1          3            Fragment operations
glBegin(GL_TRIANGLE_STRIP);
glColor(green);
glVertex2i(…); // 0
glVertex2i(…); // 1                                       Framebuffer
glColor(red);
glVertex2i(…); // 2
glVertex2i(…); // 3
glEnd();                                         2           Display
                        0                Centre for Computational Technologies
     OpenGL                                              Simulation is The Future!
Primitive operations
                                                              Application
OpenGL
   – Clip to the window boundaries                          Vertex assembly
        • Actually to the frustum surfaces
   – Perform back-face / front-face ops                    Vertex operations
        • Culling
        • Color assignment for 2-side lighting             Primitive assembly
In our case
                                                          Primitive operations
    – Nothing happens
                                                              Rasterization

                                                          Fragment operations

                                                              Framebuffer

                                                                 Display
                                             Centre for Computational Technologies
    OpenGL                                                   Simulation is The Future!
Rasterization (data types)
                                              Application
         struct {
                                            Vertex assembly
           float x,y,z,w;
           float r,g,b,a;
                                           Vertex operations
         } vertex;

         struct {                          Primitive assembly
           vertex v0,v1,v2
                                          Primitive operations
         } triangle;
         struct {                             Rasterization
           short int x,y;
           float depth;                   Fragment operations
           float r,g,b,a;
         } fragment;                          Framebuffer

                                                 Display
                             Centre for Computational Technologies
OpenGL                                       Simulation is The Future!
Rasterization
                                                           Application
OpenGL
   – Determine which pixels are included in the          Vertex assembly
     primitive
        • Generate a fragment for each such pixel       Vertex operations
    – Assign attributes (e.g., color) to each
       fragment                                         Primitive assembly
In our case:
                                                       Primitive operations

                                                           Rasterization

                                                       Fragment operations

                                                           Framebuffer

                                                              Display
                                          Centre for Computational Technologies
    OpenGL                                                Simulation is The Future!
Fragment operations
                                                        Application
OpenGL
    – Texture mapping                                 Vertex assembly
    – Fragment lighting (OpenGL 2.0)
    – Fog                                            Vertex operations
    – Scissor test
                                                     Primitive assembly
    – Alpha test
In our case, nothing happens:                       Primitive operations

                                                        Rasterization

                                                    Fragment operations

                                                        Framebuffer

                                                           Display
                                       Centre for Computational Technologies
    OpenGL                                             Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                     Centre for Computational Technologies
      OpenGL                                         Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                     Centre for Computational Technologies
      OpenGL                                         Simulation is The Future!
OpenGL Library Organization
• GLU (OpenGL Utility Library), modeling
• GLUT (GL Utility Toolkit), window system interface




                                  Centre for Computational Technologies
     OpenGL                                       Simulation is The Future!
Graphics Functions
•   Primitive functions
•   Attribute functions
•   Transformation functions
•   Viewing functions
•   Input functions
•   Control functions




                               Centre for Computational Technologies
      OpenGL                                   Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                   Centre for Computational Technologies
      OpenGL                                       Simulation is The Future!
Primitives
• Specified via vertices
• General schema
   glBegin(type);
      glVertex*(...);
      ...
      glVertex*(...);
   glEnd();


• type determines interpretation of vertices




                                   Centre for Computational Technologies
     OpenGL                                        Simulation is The Future!
Example: Square Outline
• Type GL_LINE_LOOP
   glBegin(GL_LINE_LOOP);
       glVertex2f(0.0, 0.0);
       glVertex2f(1.0, 0.0);
       glVertex2f(1.0, 1.0);
       glVertex2f(0.0, 1.0);
   glEnd();
• z coordinate defaults to 0
• Calls to other functions are allowed between
  glBegin(type) and glEnd();




                                  Centre for Computational Technologies
     OpenGL                                       Simulation is The Future!
Points and Line Segments




• Make sense in three dimensions




                               Centre for Computational Technologies
   OpenGL                                      Simulation is The Future!
Polygons

• Polygons enclose an area




• Rendering of area (fill) depends on attributes
• All vertices must be in one plane



                                  Centre for Computational Technologies
    OpenGL                                        Simulation is The Future!
Polygon Restrictions
• OpenGL Polygons must be simple
• OpenGL Polygons must be convex


                  (a) simple, but not convex




                               convex




                  (b) non-simple


                                    Centre for Computational Technologies
    OpenGL                                          Simulation is The Future!
Why Polygon Restrictions?
• Non-convex and non-simple polygons are
  expensive to process and render
• Convexity and simplicity is expensive to test
• Behavior of OpenGL implementation on
  disallowed polygons is “undefined”
• Some tools in GLU for decomposing complex polygons
  (tessellation)
• Triangles are most efficient




                               Centre for Computational Technologies
    OpenGL                                     Simulation is The Future!
Polygon Strips
• Efficiency in space and time
• Reduces visual artefacts




• Polygons have a front and a back, possibly with
  different attributes!



                                  Centre for Computational Technologies
     OpenGL                                       Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                   Centre for Computational Technologies
      OpenGL                                       Simulation is The Future!
Attributes
•   Part of the state of the graphics pipeline
•   Set before primitives are drawn
•   Remain in effect!
•   Examples:
    – Color, including transparency
    – Reflection properties
    – Shading properties




                                      Centre for Computational Technologies
      OpenGL                                          Simulation is The Future!
Color Spaces
• RGB (Red, Green, Blue)
   – Convenient for display
   – Can be unintuitive (3 floats in OpenGL)
• HSV (Hue, Saturation, Value)
   – Hue: what color
   – Saturation: how far away from gray
   – Value: how bright
• Others for movies and printing




                                          Centre for Computational Technologies
     OpenGL                                               Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                   Centre for Computational Technologies
      OpenGL                                       Simulation is The Future!
Example: Drawing a shaded polygon
• Initialization: the “main” function
   int main(int argc, char** argv)
   {
        glutInit(&argc, argv);
        glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize (500, 500);
        glutInitWindowPosition (100, 100);
        glutCreateWindow (argv[0]);
        init ();
        glutDisplayFunc(display);
        glutReshapeFunc(reshape);
        glutKeyboardFunc (keyboard);
        glutMainLoop();
        return 0;
   }

                                        Centre for Computational Technologies
       OpenGL                                           Simulation is The Future!
GLUT Callbacks
• Window system independent interaction

• glutDisplayFunc(display);
• glutReshapeFunc(reshape);
• glutKeyboardFunc (keyboard);

• glutMainLoop processes events




                                  Centre for Computational Technologies
    OpenGL                                        Simulation is The Future!
Initializing Attributes
• Separate in “init” function
   void init(void)
   {
        glClearColor (0.0, 0.0, 0.0, 0.0);
        /* glShadeModel (GL_FLAT); */
        glShadeModel (GL_SMOOTH);
   }




                                             Centre for Computational Technologies
       OpenGL                                                Simulation is The Future!
The Display Callback
• Handles exposure events
• Install with glutDisplayFunc(display)



   void display(void)
   {
        glClear (GL_COLOR_BUFFER_BIT); /* clear buffer */
        triangle (); /* draw triangle */
        glFlush (); /* force display */
   }




                                          Centre for Computational Technologies
       OpenGL                                               Simulation is The Future!
Drawing
• In world coordinates; remember state!
   void triangle(void)
   {
        glBegin (GL_TRIANGLES);
                glColor3f (1.0, 0.0, 0.0); /* red */
                glVertex2f (5.0, 5.0);
                glColor3f (0.0, 1.0, 0.0); /* green */
                glVertex2f (25.0, 5.0);
                glColor3f (0.0, 0.0, 1.0); /* blue */
                glVertex2f (5.0, 25.0);
        glEnd();
   }




                                                         Centre for Computational Technologies
       OpenGL                                                            Simulation is The Future!
The Image
• Color of last vertex with flat shading

glShadeModel(GL_FLAT)          glShadeModel(GL_SMOOTH)




                                    Centre for Computational Technologies
     OpenGL                                         Simulation is The Future!
Smooth Shading
• Approximating a sphere
Flat Shading               Smooth Shading




                            Centre for Computational Technologies
    OpenGL                                  Simulation is The Future!
Projection
• Mapping world to screen coordinates
   void reshape(int w, int h)
   {
        glViewport (0, 0, (GLsizei) w, (GLsizei) h);
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity ();
        if (w <= h)
            gluOrtho2D (0.0, 30.0, 0.0, 30.0 * (GLfloat) h/(GLfloat) w);
        else
            gluOrtho2D (0.0, 30.0 * (GLfloat) w/(GLfloat) h, 0.0, 30.0);
        glMatrixMode(GL_MODELVIEW);
   }



                                                Centre for Computational Technologies
       OpenGL                                                      Simulation is The Future!
Viewport
• Determines clipping in window coordinates
• glViewPort(x, y, w, h)




                                 Centre for Computational Technologies
     OpenGL                                      Simulation is The Future!
Orthographic Projection
• 2D and 3D versions
• glOrtho2D(left, right, bottom, top)
• In world coordinates!




                                    Centre for Computational Technologies
     OpenGL                                         Simulation is The Future!
Outline
1.   Introduction to Computer Graphics
2.   Computer Graphics Applications
3.   A Graphics Pipeline
4.   The OpenGL API
5.   Primitives: vertices, lines, polygons
6.   Attributes: color
7.   Example: drawing a shaded triangle




                                     Centre for Computational Technologies
      OpenGL                                         Simulation is The Future!
Reminder
• Programming Assignment 1 out today
• Due in two weeks
• Compilation instructions on course page together with
  assignment




                                  Centre for Computational Technologies
     OpenGL                                       Simulation is The Future!
Questions?




         Centre for Computational Technologies
OpenGL                   Simulation is The Future!

Weitere ähnliche Inhalte

Was ist angesagt?

Opengl presentation
Opengl presentationOpengl presentation
Opengl presentationelnaqah
 
Graphics pipelining
Graphics pipeliningGraphics pipelining
Graphics pipeliningAreena Javed
 
Lecture 3 image sampling and quantization
Lecture 3 image sampling and quantizationLecture 3 image sampling and quantization
Lecture 3 image sampling and quantizationVARUN KUMAR
 
3D Transformation
3D Transformation3D Transformation
3D TransformationSwatiHans10
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"Ankit Surti
 
Modern OpenGL Usage: Using Vertex Buffer Objects Well
Modern OpenGL Usage: Using Vertex Buffer Objects Well Modern OpenGL Usage: Using Vertex Buffer Objects Well
Modern OpenGL Usage: Using Vertex Buffer Objects Well Mark Kilgard
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsMichael Heron
 
Visible surface determination
Visible  surface determinationVisible  surface determination
Visible surface determinationPatel Punit
 
Introduction to computer graphics
Introduction to computer graphics Introduction to computer graphics
Introduction to computer graphics Priyodarshini Dhar
 
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
 
Shader Programming With Unity
Shader Programming With UnityShader Programming With Unity
Shader Programming With UnityMindstorm Studios
 
Color model in computer graphics
Color model in computer graphicsColor model in computer graphics
Color model in computer graphicsPuja Dhakal
 

Was ist angesagt? (20)

Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
 
Polygon mesh
Polygon  meshPolygon  mesh
Polygon mesh
 
Open gl
Open glOpen gl
Open gl
 
Graphics pipelining
Graphics pipeliningGraphics pipelining
Graphics pipelining
 
Introduction to 2D/3D Graphics
Introduction to 2D/3D GraphicsIntroduction to 2D/3D Graphics
Introduction to 2D/3D Graphics
 
Lecture 3 image sampling and quantization
Lecture 3 image sampling and quantizationLecture 3 image sampling and quantization
Lecture 3 image sampling and quantization
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"
 
Modern OpenGL Usage: Using Vertex Buffer Objects Well
Modern OpenGL Usage: Using Vertex Buffer Objects Well Modern OpenGL Usage: Using Vertex Buffer Objects Well
Modern OpenGL Usage: Using Vertex Buffer Objects Well
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D Graphics
 
Visible surface determination
Visible  surface determinationVisible  surface determination
Visible surface determination
 
Introduction to computer graphics
Introduction to computer graphics Introduction to computer graphics
Introduction to computer graphics
 
OpenGL L04-Lighting
OpenGL L04-LightingOpenGL L04-Lighting
OpenGL L04-Lighting
 
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
 
3 d viewing
3 d viewing3 d viewing
3 d viewing
 
Shader Programming With Unity
Shader Programming With UnityShader Programming With Unity
Shader Programming With Unity
 
Color model in computer graphics
Color model in computer graphicsColor model in computer graphics
Color model in computer graphics
 
ANIMATION SEQUENCE
ANIMATION SEQUENCEANIMATION SEQUENCE
ANIMATION SEQUENCE
 
unit-1-intro
 unit-1-intro unit-1-intro
unit-1-intro
 

Andere mochten auch

Incorportating Multimedia Technology In The Preschool Classroom
Incorportating Multimedia Technology In The Preschool ClassroomIncorportating Multimedia Technology In The Preschool Classroom
Incorportating Multimedia Technology In The Preschool ClassroomLady Dolandolan
 
Flexible Transport of 3D Videos over Networks
Flexible Transport of 3D Videos over NetworksFlexible Transport of 3D Videos over Networks
Flexible Transport of 3D Videos over NetworksAhmed Hamza
 
Eγκατάσταση (Clean install) Λ.Σ. Windows
Eγκατάσταση (Clean install) Λ.Σ. WindowsEγκατάσταση (Clean install) Λ.Σ. Windows
Eγκατάσταση (Clean install) Λ.Σ. Windowsgogosf
 
Future technologies for business simulations
Future technologies for business simulationsFuture technologies for business simulations
Future technologies for business simulationsMichal Augustini
 
multimedia technologies Introduction
multimedia technologies Introductionmultimedia technologies Introduction
multimedia technologies IntroductionMohammed Fareed
 
Medical Multimedia Information Systems (ACMMM17 Tutorial)
Medical Multimedia Information Systems (ACMMM17 Tutorial) Medical Multimedia Information Systems (ACMMM17 Tutorial)
Medical Multimedia Information Systems (ACMMM17 Tutorial) klschoef
 
Computer Animation PowerPoint
Computer Animation PowerPointComputer Animation PowerPoint
Computer Animation PowerPointoacore2
 
Computer animation Computer Graphics
Computer animation Computer Graphics Computer animation Computer Graphics
Computer animation Computer Graphics University of Potsdam
 
Robots presentation
Robots presentationRobots presentation
Robots presentationaroobkazim
 
presentation on 3D Technology
presentation on 3D Technologypresentation on 3D Technology
presentation on 3D TechnologyMatti Ur Rehman
 
(Computer) Animation Technique
(Computer) Animation Technique(Computer) Animation Technique
(Computer) Animation Techniquejustinesolano
 
Animation's Life Cycle And Its Application
Animation's Life Cycle And Its ApplicationAnimation's Life Cycle And Its Application
Animation's Life Cycle And Its ApplicationShakaib Arif
 
Introduction to Animation
Introduction to AnimationIntroduction to Animation
Introduction to Animationmrnasim
 
3Ds Max presentation
3Ds Max presentation3Ds Max presentation
3Ds Max presentationNader Soubra
 
Computer technology power point
Computer technology power pointComputer technology power point
Computer technology power pointoacore2
 
Basic Concepts of Animation
Basic Concepts of AnimationBasic Concepts of Animation
Basic Concepts of Animationjamalharun
 
3D printer Technology _ A complete presentation
3D printer Technology _ A complete presentation3D printer Technology _ A complete presentation
3D printer Technology _ A complete presentationVijay Patil
 

Andere mochten auch (20)

Incorportating Multimedia Technology In The Preschool Classroom
Incorportating Multimedia Technology In The Preschool ClassroomIncorportating Multimedia Technology In The Preschool Classroom
Incorportating Multimedia Technology In The Preschool Classroom
 
Flexible Transport of 3D Videos over Networks
Flexible Transport of 3D Videos over NetworksFlexible Transport of 3D Videos over Networks
Flexible Transport of 3D Videos over Networks
 
Eγκατάσταση (Clean install) Λ.Σ. Windows
Eγκατάσταση (Clean install) Λ.Σ. WindowsEγκατάσταση (Clean install) Λ.Σ. Windows
Eγκατάσταση (Clean install) Λ.Σ. Windows
 
Future technologies for business simulations
Future technologies for business simulationsFuture technologies for business simulations
Future technologies for business simulations
 
Multimedia Services: Audio
Multimedia Services: AudioMultimedia Services: Audio
Multimedia Services: Audio
 
Nioc2015 final
Nioc2015 finalNioc2015 final
Nioc2015 final
 
multimedia technologies Introduction
multimedia technologies Introductionmultimedia technologies Introduction
multimedia technologies Introduction
 
Medical Multimedia Information Systems (ACMMM17 Tutorial)
Medical Multimedia Information Systems (ACMMM17 Tutorial) Medical Multimedia Information Systems (ACMMM17 Tutorial)
Medical Multimedia Information Systems (ACMMM17 Tutorial)
 
Computer Animation PowerPoint
Computer Animation PowerPointComputer Animation PowerPoint
Computer Animation PowerPoint
 
Computer animation Computer Graphics
Computer animation Computer Graphics Computer animation Computer Graphics
Computer animation Computer Graphics
 
Robots presentation
Robots presentationRobots presentation
Robots presentation
 
presentation on 3D Technology
presentation on 3D Technologypresentation on 3D Technology
presentation on 3D Technology
 
(Computer) Animation Technique
(Computer) Animation Technique(Computer) Animation Technique
(Computer) Animation Technique
 
Animation's Life Cycle And Its Application
Animation's Life Cycle And Its ApplicationAnimation's Life Cycle And Its Application
Animation's Life Cycle And Its Application
 
Introduction to Animation
Introduction to AnimationIntroduction to Animation
Introduction to Animation
 
3Ds Max presentation
3Ds Max presentation3Ds Max presentation
3Ds Max presentation
 
Computer technology power point
Computer technology power pointComputer technology power point
Computer technology power point
 
Basic Concepts of Animation
Basic Concepts of AnimationBasic Concepts of Animation
Basic Concepts of Animation
 
3D printer Technology _ A complete presentation
3D printer Technology _ A complete presentation3D printer Technology _ A complete presentation
3D printer Technology _ A complete presentation
 
ANIMATION PPT
ANIMATION PPTANIMATION PPT
ANIMATION PPT
 

Ähnlich wie OpenGL Basics

OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL TransformationSandip Jadhav
 
GPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaGPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaJanie Clayton
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Droidcon Berlin
 
GPU Programming 360iDev
GPU Programming 360iDevGPU Programming 360iDev
GPU Programming 360iDevJanie Clayton
 
GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015Janie Clayton
 
Gpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and MetalGpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and MetalJanie Clayton
 
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsGFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsPrabindh Sundareson
 
10cs65-cgnotes
10cs65-cgnotes10cs65-cgnotes
10cs65-cgnotesmushtaqdm
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGLJungsoo Nam
 
CG simple openGL point & line-course 2
CG simple openGL point & line-course 2CG simple openGL point & line-course 2
CG simple openGL point & line-course 2fungfung Chen
 
Java on the GPU: Where are we now?
Java on the GPU: Where are we now?Java on the GPU: Where are we now?
Java on the GPU: Where are we now?Dmitry Alexandrov
 
Compute API –Past & Future
Compute API –Past & FutureCompute API –Past & Future
Compute API –Past & FutureOfer Rosenberg
 
Computer Graphics Through OpenGL: From Theory to Experiments
Computer Graphics Through OpenGL: From Theory to ExperimentsComputer Graphics Through OpenGL: From Theory to Experiments
Computer Graphics Through OpenGL: From Theory to Experimentskuwizotuji
 

Ähnlich wie OpenGL Basics (20)

OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
 
OpenGL Interaction
OpenGL InteractionOpenGL Interaction
OpenGL Interaction
 
Introduction to OpenGL.ppt
Introduction to OpenGL.pptIntroduction to OpenGL.ppt
Introduction to OpenGL.ppt
 
GPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaGPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf Atlanta
 
Realizing OpenGL
Realizing OpenGLRealizing OpenGL
Realizing OpenGL
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
 
GPU Programming 360iDev
GPU Programming 360iDevGPU Programming 360iDev
GPU Programming 360iDev
 
GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015GPU Programming: Chicago CocoaConf 2015
GPU Programming: Chicago CocoaConf 2015
 
Gpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and MetalGpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and Metal
 
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specificationsGFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
 
10cs65-cgnotes
10cs65-cgnotes10cs65-cgnotes
10cs65-cgnotes
 
Let there be light
Let there be lightLet there be light
Let there be light
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
CG simple openGL point & line-course 2
CG simple openGL point & line-course 2CG simple openGL point & line-course 2
CG simple openGL point & line-course 2
 
september11.ppt
september11.pptseptember11.ppt
september11.ppt
 
Java on the GPU: Where are we now?
Java on the GPU: Where are we now?Java on the GPU: Where are we now?
Java on the GPU: Where are we now?
 
Compute API –Past & Future
Compute API –Past & FutureCompute API –Past & Future
Compute API –Past & Future
 
Computer Graphics Through OpenGL: From Theory to Experiments
Computer Graphics Through OpenGL: From Theory to ExperimentsComputer Graphics Through OpenGL: From Theory to Experiments
Computer Graphics Through OpenGL: From Theory to Experiments
 
Opengl basics
Opengl basicsOpengl basics
Opengl basics
 
Graphics Libraries
Graphics LibrariesGraphics Libraries
Graphics Libraries
 

Kürzlich hochgeladen

Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...Nguyen Thanh Tu Collection
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEMISSRITIMABIOLOGYEXP
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfChristalin Nelson
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 

Kürzlich hochgeladen (20)

Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdf
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 

OpenGL Basics

  • 1. OpenGL & Computer Graphics Basic http://www.learncax.com/ Centre for Computational Technologies CCTech Recruitment Brochure Simulation is The Future!
  • 2. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 3. Textbook OpenGL Programming Guide, Fourth Edition: The Official Guide to Learning OpenGL, Version 1.5, by Woo et al., Addison Wesley, ISBN: 0201604582. Centre for Computational Technologies OpenGL Simulation is The Future!
  • 4. Basic goal • Teach you the fundamentals for writing your own graphics applications Centre for Computational Technologies OpenGL Simulation is The Future!
  • 5. Evolution Centre for Computational Technologies OpenGL Simulation is The Future!
  • 6. PC Architecture Centre for Computational Technologies OpenGL Simulation is The Future!
  • 7. Programming Graphics Applications • The application is programmed to the 3D graphics API and links with the driver at runtime Centre for Computational Technologies OpenGL Simulation is The Future!
  • 8. The Graphics Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 9. The Graphics Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 10. The Graphics Pipeline  SolidWorks:  define software behavior  user input events  Software logic  CAD operations Centre for Computational Technologies OpenGL Simulation is The Future!
  • 11. The Graphics Pipeline  SolidWorks:  send OpenGL commands  OpenGL driver:  process GL command stream  talk to GPU Centre for Computational Technologies OpenGL Simulation is The Future!
  • 12. The Graphics Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 13. The Graphics Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 14. The Graphics Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 15. The Graphics Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 16. Rasterization vs. Ray Tracing Centre for Computational Technologies OpenGL Simulation is The Future!
  • 17. Rasterization vs. Ray Tracing • Rasterization: • for each object ... – for each pixel ... • Ray tracing: • for each pixel ... – for each object ... Centre for Computational Technologies OpenGL Simulation is The Future!
  • 18. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 19. Computer Graphics Applications • Computer Aided Design • Computer Aided Manufacturing • Architecture • Simulation • Virtual Reality • Visualization • Games • Movies  • Medical Imaging Centre for Computational Technologies OpenGL Simulation is The Future!
  • 20. Computer Aided Design (CAD) Centre for Computational Technologies OpenGL Simulation is The Future!
  • 21. Movies Centre for Computational Technologies OpenGL Simulation is The Future!
  • 22. Games Centre for Computational Technologies OpenGL Simulation is The Future!
  • 23. Visualization Centre for Computational Technologies OpenGL Simulation is The Future!
  • 24. Virtual and Augmented Reality Centre for Computational Technologies OpenGL Simulation is The Future!
  • 25. Mobile Media Centre for Computational Technologies OpenGL Simulation is The Future!
  • 26. New Information Spaces Centre for Computational Technologies OpenGL Simulation is The Future!
  • 27. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 28. Programming a Pipeline • Specify the operation of each box • Replace or accumulate • State and lack of modularity • Immediate mode graphics – On-line (OpenGL) • Modeling-rendering pipeline – Off-line (Pixar’s Renderman) Centre for Computational Technologies OpenGL Simulation is The Future!
  • 29. Vertex • Vertices in world coordinates • void glVertex3f(GLfloat x, GLfloat y, GLfloat z) – Vertex (x, y, z) sent down the pipeline – Function call returns • Use GLtype for portability and consistency – glVertex{234}{sfid}[v](TYPE coords) Centre for Computational Technologies OpenGL Simulation is The Future!
  • 30. Transformer • Transformer in world coordinates • Must be set before object is drawn! – glRotatef(45.0, 0.0, 0.0, -1.0); – glVertex2f(1.0, 0.0); Centre for Computational Technologies OpenGL Simulation is The Future!
  • 31. Clipper • Mostly automatic from viewport Centre for Computational Technologies OpenGL Simulation is The Future!
  • 32. Projector Orthographic Perspective Centre for Computational Technologies OpenGL Simulation is The Future!
  • 33. Rasterizer • Interesting algorithms • To window coordinates Centre for Computational Technologies OpenGL Simulation is The Future!
  • 34. The OpenGL Vertex Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
  • 35. OpenGL shaded-quad code glClearColor(1, 1, 1, 1); // white glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glOrtho(0, 100, 0, 100, -1, 1); glBegin(GL_TRIANGLE_STRIP); glColor3f(0, 0.5, 0); // dark green glVertex2i(11, 31); glVertex2i(37, 71); glColor3f(0.5, 0, 0); // dark red glVertex2i(91, 38); glVertex2i(65, 71); glEnd(); glFlush(); Centre for Computational Technologies OpenGL Simulation is The Future!
  • 36. OpenGL vertex pipeline Application Emphasis is on data types Diagram ignores Vertex assembly – Pixel pipeline – Texture memory Vertex operations – Display lists Primitive assembly – … Display is not part of OpenGL Primitive operations Rasterization Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 37. Vertex assembly (data types) Application struct { Vertex assembly float x,y,z,w; float r,g,b,a; Vertex operations } vertex; Primitive assembly Primitive operations Rasterization Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 38. Vertex assembly (OpenGL) Vertex assembly Application – Force input to canonical format • Convert to internal representation Vertex assembly – E.g., x, y to float • Initialize unspecified values Vertex operations – E.g., z = 0, w=1 • Insert current modal state – E.g., color to 0,0.5,0,1 Primitive assembly – Or create using evaluators Error detection Primitive operations – INVALID_ENUM – INVALID_VALUE Rasterization – INVALID_OPERATION • Especially between Begin and End Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 39. Vertex assembly (in our case) glColor3f(0, 0.5, 0); Application glVertex2i(11, 31); glVertex2i(37, 71); Vertex assembly glColor3f(0.5, 0, 0); // no effect Vertex operations Primitive assembly struct { Primitive operations float x,y,z,w; // 11, 31, 0, 1 float r,g,b,a; // 0, 0.5, 0, 1 Rasterization } vertex; Fragment operations struct { float x,y,z,w; // 37, 71, 0, 1 Framebuffer float r,g,b,a; // 0, 0.5, 0, 1 } vertex; Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 40. Vertex operations Application OpenGL – Transform coordinates Vertex assembly • 4x4 matrix arithmetic – Compute (vertex) lighting Vertex operations – Compute texture coordinates Primitive assembly – … In our case: Primitive operations – Scale (arbitrary 100x100) coordinates to fit window Rasterization – No lighting, no texture coordinates Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 41. Primitive assembly (data types) Application struct { Vertex assembly float x,y,z,w; float r,g,b,a; Vertex operations } vertex; struct { Primitive assembly vertex v0,v1,v2; Primitive operations } triangle; or Rasterization struct { vertex v0,v1; Fragment operations } line; or Framebuffer struct { vertex v0; Display } point; Centre for Computational Technologies OpenGL Simulation is The Future!
  • 42. Primitive assembly OpenGL Application – Group vertexes into primitives: • points, Vertex assembly • lines, or • triangles Vertex operations – Decompose polygons to triangles – Duplicate vertexes in strips or fans Primitive assembly In our case: – Create two triangles from a strip: Primitive operations Rasterization 1 3 Fragment operations glBegin(GL_TRIANGLE_STRIP); glColor(green); glVertex2i(…); // 0 glVertex2i(…); // 1 Framebuffer glColor(red); glVertex2i(…); // 2 glVertex2i(…); // 3 glEnd(); 2 Display 0 Centre for Computational Technologies OpenGL Simulation is The Future!
  • 43. Primitive operations Application OpenGL – Clip to the window boundaries Vertex assembly • Actually to the frustum surfaces – Perform back-face / front-face ops Vertex operations • Culling • Color assignment for 2-side lighting Primitive assembly In our case Primitive operations – Nothing happens Rasterization Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 44. Rasterization (data types) Application struct { Vertex assembly float x,y,z,w; float r,g,b,a; Vertex operations } vertex; struct { Primitive assembly vertex v0,v1,v2 Primitive operations } triangle; struct { Rasterization short int x,y; float depth; Fragment operations float r,g,b,a; } fragment; Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 45. Rasterization Application OpenGL – Determine which pixels are included in the Vertex assembly primitive • Generate a fragment for each such pixel Vertex operations – Assign attributes (e.g., color) to each fragment Primitive assembly In our case: Primitive operations Rasterization Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 46. Fragment operations Application OpenGL – Texture mapping Vertex assembly – Fragment lighting (OpenGL 2.0) – Fog Vertex operations – Scissor test Primitive assembly – Alpha test In our case, nothing happens: Primitive operations Rasterization Fragment operations Framebuffer Display Centre for Computational Technologies OpenGL Simulation is The Future!
  • 47. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 48. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 49. OpenGL Library Organization • GLU (OpenGL Utility Library), modeling • GLUT (GL Utility Toolkit), window system interface Centre for Computational Technologies OpenGL Simulation is The Future!
  • 50. Graphics Functions • Primitive functions • Attribute functions • Transformation functions • Viewing functions • Input functions • Control functions Centre for Computational Technologies OpenGL Simulation is The Future!
  • 51. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 52. Primitives • Specified via vertices • General schema glBegin(type); glVertex*(...); ... glVertex*(...); glEnd(); • type determines interpretation of vertices Centre for Computational Technologies OpenGL Simulation is The Future!
  • 53. Example: Square Outline • Type GL_LINE_LOOP glBegin(GL_LINE_LOOP); glVertex2f(0.0, 0.0); glVertex2f(1.0, 0.0); glVertex2f(1.0, 1.0); glVertex2f(0.0, 1.0); glEnd(); • z coordinate defaults to 0 • Calls to other functions are allowed between glBegin(type) and glEnd(); Centre for Computational Technologies OpenGL Simulation is The Future!
  • 54. Points and Line Segments • Make sense in three dimensions Centre for Computational Technologies OpenGL Simulation is The Future!
  • 55. Polygons • Polygons enclose an area • Rendering of area (fill) depends on attributes • All vertices must be in one plane Centre for Computational Technologies OpenGL Simulation is The Future!
  • 56. Polygon Restrictions • OpenGL Polygons must be simple • OpenGL Polygons must be convex (a) simple, but not convex convex (b) non-simple Centre for Computational Technologies OpenGL Simulation is The Future!
  • 57. Why Polygon Restrictions? • Non-convex and non-simple polygons are expensive to process and render • Convexity and simplicity is expensive to test • Behavior of OpenGL implementation on disallowed polygons is “undefined” • Some tools in GLU for decomposing complex polygons (tessellation) • Triangles are most efficient Centre for Computational Technologies OpenGL Simulation is The Future!
  • 58. Polygon Strips • Efficiency in space and time • Reduces visual artefacts • Polygons have a front and a back, possibly with different attributes! Centre for Computational Technologies OpenGL Simulation is The Future!
  • 59. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 60. Attributes • Part of the state of the graphics pipeline • Set before primitives are drawn • Remain in effect! • Examples: – Color, including transparency – Reflection properties – Shading properties Centre for Computational Technologies OpenGL Simulation is The Future!
  • 61. Color Spaces • RGB (Red, Green, Blue) – Convenient for display – Can be unintuitive (3 floats in OpenGL) • HSV (Hue, Saturation, Value) – Hue: what color – Saturation: how far away from gray – Value: how bright • Others for movies and printing Centre for Computational Technologies OpenGL Simulation is The Future!
  • 62. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 63. Example: Drawing a shaded polygon • Initialization: the “main” function int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutMainLoop(); return 0; } Centre for Computational Technologies OpenGL Simulation is The Future!
  • 64. GLUT Callbacks • Window system independent interaction • glutDisplayFunc(display); • glutReshapeFunc(reshape); • glutKeyboardFunc (keyboard); • glutMainLoop processes events Centre for Computational Technologies OpenGL Simulation is The Future!
  • 65. Initializing Attributes • Separate in “init” function void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); /* glShadeModel (GL_FLAT); */ glShadeModel (GL_SMOOTH); } Centre for Computational Technologies OpenGL Simulation is The Future!
  • 66. The Display Callback • Handles exposure events • Install with glutDisplayFunc(display) void display(void) { glClear (GL_COLOR_BUFFER_BIT); /* clear buffer */ triangle (); /* draw triangle */ glFlush (); /* force display */ } Centre for Computational Technologies OpenGL Simulation is The Future!
  • 67. Drawing • In world coordinates; remember state! void triangle(void) { glBegin (GL_TRIANGLES); glColor3f (1.0, 0.0, 0.0); /* red */ glVertex2f (5.0, 5.0); glColor3f (0.0, 1.0, 0.0); /* green */ glVertex2f (25.0, 5.0); glColor3f (0.0, 0.0, 1.0); /* blue */ glVertex2f (5.0, 25.0); glEnd(); } Centre for Computational Technologies OpenGL Simulation is The Future!
  • 68. The Image • Color of last vertex with flat shading glShadeModel(GL_FLAT) glShadeModel(GL_SMOOTH) Centre for Computational Technologies OpenGL Simulation is The Future!
  • 69. Smooth Shading • Approximating a sphere Flat Shading Smooth Shading Centre for Computational Technologies OpenGL Simulation is The Future!
  • 70. Projection • Mapping world to screen coordinates void reshape(int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); if (w <= h) gluOrtho2D (0.0, 30.0, 0.0, 30.0 * (GLfloat) h/(GLfloat) w); else gluOrtho2D (0.0, 30.0 * (GLfloat) w/(GLfloat) h, 0.0, 30.0); glMatrixMode(GL_MODELVIEW); } Centre for Computational Technologies OpenGL Simulation is The Future!
  • 71. Viewport • Determines clipping in window coordinates • glViewPort(x, y, w, h) Centre for Computational Technologies OpenGL Simulation is The Future!
  • 72. Orthographic Projection • 2D and 3D versions • glOrtho2D(left, right, bottom, top) • In world coordinates! Centre for Computational Technologies OpenGL Simulation is The Future!
  • 73. Outline 1. Introduction to Computer Graphics 2. Computer Graphics Applications 3. A Graphics Pipeline 4. The OpenGL API 5. Primitives: vertices, lines, polygons 6. Attributes: color 7. Example: drawing a shaded triangle Centre for Computational Technologies OpenGL Simulation is The Future!
  • 74. Reminder • Programming Assignment 1 out today • Due in two weeks • Compilation instructions on course page together with assignment Centre for Computational Technologies OpenGL Simulation is The Future!
  • 75. Questions? Centre for Computational Technologies OpenGL Simulation is The Future!