intro gp

Upload: budditha-hettige

Post on 03-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Intro Gp

    1/32

    CSC 307 1.0

    Graphics Programming

    Budditha Hettige

    Department of Statistics and Computer Science

  • 7/29/2019 Intro Gp

    2/32

    Graphics Programming

    2Budditha Hettige

  • 7/29/2019 Intro Gp

    3/32

    Common Uses for Computer

    Graphics

    Applications for real-time 3D graphics range from

    interactive games and simulations to data visualization

    for scientific, medical, or business uses

    Military flight simulators

    Computer-aided design (CAD)

    Architectural or civil planning

    Scientific visualization

    Entertainment

    3Budditha Hettige

  • 7/29/2019 Intro Gp

    4/32

    Movies

    Budditha Hettige 4

  • 7/29/2019 Intro Gp

    5/32

    Games

    Budditha Hettige 5

    http://localhost/var/www/apps/conversion/tmp/scratch_3/Fig/halflife2_pc73103_traptown_qt.mov
  • 7/29/2019 Intro Gp

    6/32

    Simulation

    Budditha Hettige 6

  • 7/29/2019 Intro Gp

    7/32

    CAD-CAM & Design

    Budditha Hettige 7

  • 7/29/2019 Intro Gp

    8/32

    Architecture

    Budditha Hettige 8

  • 7/29/2019 Intro Gp

    9/32

    Virtual Reality

    Budditha Hettige 9

  • 7/29/2019 Intro Gp

    10/32

    Visualization

    Budditha Hettige 10

  • 7/29/2019 Intro Gp

    11/32

    Medical Imaging

    Budditha Hettige 11

  • 7/29/2019 Intro Gp

    12/32

    Graphics System

    12

    User Program IO Devices

    Graphics API

    Graphics

    System

    Budditha Hettige

  • 7/29/2019 Intro Gp

    13/32

    Graphics Designing

    13Budditha Hettige

  • 7/29/2019 Intro Gp

    14/32

    Graphics: Conceptual Model

    Real Object

    Real Object

    Human Eye

    Human Eye

    DisplayDevice

    Graphics System

    SyntheticModel

    SyntheticCamera

    Real Light

    SyntheticLight Source

    Budditha Hettige 14

  • 7/29/2019 Intro Gp

    15/32

    OpenGL

    Standard specification defining a cross-language, cross-platform API

    Is not a programming language

    Writing applications that produce 2D and 3D computer

    graphics

    A software interface to graphics hardware

    Designed and optimized for the display and

    manipulation of 3D graphics

    Developed by Silicon Graphics Inc. (SGI) in 1992

    15Budditha Hettige

  • 7/29/2019 Intro Gp

    16/32

    OpenGL-Graphics rendering API

    Rendering API

    High-quality color images composed of geometric

    and image primitives

    Window system independent Operating system independent

    OpenGL Pipeline

    16Budditha Hettige

  • 7/29/2019 Intro Gp

    17/32

    OpenGL Architecture

    17

    Display

    List

    Polynomial

    Evaluator

    Per Vertex

    Operations &

    Primitive

    Assembly

    RasterizationPer Fragment

    Operations

    Frame

    Buffer

    TextureMemory

    CPU

    Pixel

    Operations

    Budditha Hettige

  • 7/29/2019 Intro Gp

    18/32

    Software & Hardware Interfaces

    18

    Software Interface Hardware Interface

    Budditha Hettige

  • 7/29/2019 Intro Gp

    19/32

    OpenGL and Related APIs

    19

    GLUT

    GLU

    GL

    GLX, AGL

    or WGL

    X, Win32, Mac O/S

    software and/or hardware

    application program

    OpenGL Motif

    widget or similar

    Budditha Hettige

  • 7/29/2019 Intro Gp

    20/32

    Related APIs

    AGL, GLX, WGL glue between OpenGL and windowing systems

    GLU (OpenGL Utility Library) part of OpenGL

    NURBS, tessellators, quadric shapes, etc. GLUT (OpenGL Utility Toolkit)

    portable windowing API

    not officially part of OpenGL

    Initial header inclusions (for Windows) #include

    #include

    #include

    #include

    20Budditha Hettige

  • 7/29/2019 Intro Gp

    21/32

    Function-Naming Conventions

    All OpenGL functions take the following

    format

    21Budditha Hettige

  • 7/29/2019 Intro Gp

    22/32

    OpenGL data types

    22Budditha Hettige

  • 7/29/2019 Intro Gp

    23/32

    2D Coordinates

    23Budditha Hettige

  • 7/29/2019 Intro Gp

    24/32

    Coordinate Clipping

    24Budditha Hettige

  • 7/29/2019 Intro Gp

    25/32

    Viewports

    Mapping Drawing Coordinates to WindowCoordinates

    25

    viewport defined as twice the size of the clipping area

    Budditha Hettige

  • 7/29/2019 Intro Gp

    26/32

    Viewports

    26

    viewport that matches the clipping area

    Budditha Hettige

  • 7/29/2019 Intro Gp

    27/32

    OpenGL 3-D coordinates

    Right-handed system

    From point of view of camera looking out intoscene:

    +X right, -X left +Y up, -Y down

    +Zbehind camera, -Z in front

    Positive rotations are counterclockwise around

    axis of rotation

    27Budditha Hettige

  • 7/29/2019 Intro Gp

    28/32

    28

    OpenGL Geometric Primitives

    GL_QUAD_STRIP

    GL_POLYGON

    GL_TRIANGLE_STRIP

    GL_TRIANGLE_FAN

    GL_POINTSGL_LINES

    GL_LINE_LOOPGL_LINE_STRIP

    GL_TRIANGLES

    GL_QUADS

    Primitives are one- or two-dimensional entities orsurfaces such as points, lines, and polygons

    Budditha Hettige

  • 7/29/2019 Intro Gp

    29/32

    The VertexA Position in Space

    Each corner of the any primitive is called a

    vertex. Ex: three-dimensional cube consists of

    six two dimensional squares, each placed on a

    separate face

    29Budditha Hettige

  • 7/29/2019 Intro Gp

    30/32

    Projections: Getting 3D to 2D

    Orthographic Projections

    Perspective Projections

    30Budditha Hettige

  • 7/29/2019 Intro Gp

    31/32

    RGB Color Space

    Green(1,0,0)

    Blue

    (0,0,1)

    Red(1,0,0)

    Yellow(1,1,0)

    Magenta(1,0,1)

    Blk

    Cyan

    (0,1,1)

    White(1,1,1)

    G

    B

    R

    Image: Pixel maps to color

    Budditha Hettige 31

  • 7/29/2019 Intro Gp

    32/32

    Common Composite Colors

    32Budditha Hettige