Graphics Sw

download Graphics Sw

of 27

Transcript of Graphics Sw

  • 8/11/2019 Graphics Sw

    1/27

    Graphics s/w

    1.Special purpose packages.

    2. General programming packages.

  • 8/11/2019 Graphics Sw

    2/27

    Special purpose packages are designedfor non programmers who want togenerate pictures, graphs or charts.

    A set of menus that allows users tocommunicate with the programs in theirown terms.

    Eg: artists painting programs, variousarchitectural, business, medical andengineering CAD systems.

  • 8/11/2019 Graphics Sw

    3/27

  • 8/11/2019 Graphics Sw

    4/27

    Basic functions in a graphics library is to

    specifying picture components (straight

    lines, polygons, spheres and other

    objects), setting color values, selecting

    views of a scene and applying rotations or

    other transformation.

  • 8/11/2019 Graphics Sw

    5/27

    A set of graphics functions is often called a

    CG API (computer graphics applicationprogramming interface).

    Because the library provides a s/w

    interface between a programminglanguage and the h/w. so when we write

    an application program in OpenGL the

    graphics routines allow us to construct anddisplay a picture on an o/p device.

  • 8/11/2019 Graphics Sw

    6/27

    Graphic functions

    Graphics o/p primitives - The basic

    building blocks for pictures.

    Include character strings and geometric

    entities such as points, straight lines,

    curved lines, filled color areas ( polygons),

    and shapes defined with arrays of color

    points.

  • 8/11/2019 Graphics Sw

    7/27

    Attribute - properties of the o/p

    primitives. it describes how a particularprimitive is to be displayed. includes color

    specifications, line styles, text styles and

    area filling patterns. Geometric transformations we can

    change the size, position, or orientation of

    an object within a scene using geometrictransformations.

  • 8/11/2019 Graphics Sw

    8/27

    Viewing transformations - are used to

    select a view of the scene , the type of

    projection to be used , and the location ona video monitor where the view is to be

    displayed.

    input functions

    are used to control andprocess the dataflow from interactive

    devices.

  • 8/11/2019 Graphics Sw

    9/27

    Introduction to OpenGL

    A basic library of functions is provided in

    OpenGL for specifying graphic primitives,

    attributes, geometric transformations,Viewing transformations , and many other

    operations.

    OpenGL is h/w independent.

  • 8/11/2019 Graphics Sw

    10/27

    Basic OpenGL syntax

    Function names in the OpenGL basic library

    are prefixed with gl, and each component

    word within a function name has its first

    letter capitalized.

    Naming convention glBegin, glClear,

    glCopyPixels, glPolygonMode.

  • 8/11/2019 Graphics Sw

    11/27

    Constants begin with uppercase letters

    GL.

    Component words within a constant nameare written in capital letters.

    Underscore (_) is used as a separator.

    GL_2D,

    GL_RGB,

    GL_CCW,

    GL_POLYGON

  • 8/11/2019 Graphics Sw

    12/27

    Data types in OpenGL

    GLbyte

    GLshort

    GLint GLfloat

    GLdouble

    GLboolean

  • 8/11/2019 Graphics Sw

    13/27

    OpenGL variable types and corresponding C data

    types

    OpenGL Data Type| Internal Representation| defined as C TypeGLbyte 8-bit integer Signed char

    GLshort 16-bit integer Short

    GLint 32-bit integer Long

    GLfloat 32-bit floating point Float

    GLdouble 64-bit floating point Double

    GLboolean 8-bit unsigned integer Unsigned char

    GLushort 16-bit unsigned integer Unsigned short

    GLuint, GLenum, GLbitfield 32-bit unsigned integer

    Unsigned long

  • 8/11/2019 Graphics Sw

    14/27

    Header files

    #include

    #include

    #include #include

    #include

  • 8/11/2019 Graphics Sw

    15/27

    glutInt - Initialization function

    Eg: glutInt (&argc ,argv);

    glutCreateWindow -Caption for the title bar

    Eg: glutCreateWindow (example);

    glutDisplayFunc assigns the picture to the

    display window.

    Eg: glutDisplayFunc (lineSegment)

    glutMainLoop(); all display windows that

    we have created ,are activated. (the o/p

    screen will wait there).

    ----------------------

    G hi i li

  • 8/11/2019 Graphics Sw

    16/27

    Graphics pipeline

    Graphics pipeline or rendering pipeline

    refers to the sequence of steps used to createa 2D raster representation of a 3D scene.

    once you have created a 3D model, in a video

    game, or a 3D computer animation, thegraphics pipeline is the process of turning that

    3D model into what the computer displays.

    allowing greater flexibility in graphicsrendering.

  • 8/11/2019 Graphics Sw

    17/27

    Stages of the graphics pipeline

    3D geometric primitives

    First, the scene is created out of geometric

    primitives. this is done using triangles,

    which are particularly well suited to this as

    they always exist on a single plane.

  • 8/11/2019 Graphics Sw

    18/27

    Modeling and transformation

    Transform from the local coordinate

    system to the 3D world coordinate

    system.

    Eg: A model of a teapot in abstract is

    placed in the coordinate system of the

    3D world.

  • 8/11/2019 Graphics Sw

    19/27

    Camera transformation

    Transform the 3D world coordinate system

    into the 3D camera coordinate system,

    with the camera as the origin.

  • 8/11/2019 Graphics Sw

    20/27

    Lighting

    Illuminate according to lighting and

    reflectance.

    Eg: If the teapot is a brilliant white color,

    but in a totally black room, the camera

    sees it as black. In this step the effect of

    lighting and reflections are calculated.

  • 8/11/2019 Graphics Sw

    21/27

    Projection transformation

    Transform the 3D world coordinates into the2D view of the camera.

    In the case of a Perspective projection,objects which are distant from the cameraare made smaller. This is achieved bydividing the X and Y coordinates of eachvertex of each primitive by its Z coordinate(which represents its distance from thecamera).

    In an orthographic projection, objects retaintheir original size regardless of distance fromthe camera.

  • 8/11/2019 Graphics Sw

    22/27

    Clipping

    Geometric primitives that now fall

    completely outside of the viewing frustum

    will not be visible and are discarded at this

    stage.

  • 8/11/2019 Graphics Sw

    23/27

    Scan conversion or rasterization

    Rasterization is the process by which the2D image space representation of the

    scene is converted into raster format and

    the correct resulting pixel values aredetermined.

  • 8/11/2019 Graphics Sw

    24/27

    Texturing, fragment shading

    At this stage of the pipeline individual

    fragments (or pre-pixels) are assigned a

    color based on values interpolated from

    the vertices during rasterization, from a

    texture in memory, or from a shader

    program.

  • 8/11/2019 Graphics Sw

    25/27

    The graphics pipeline in hardware

    The rendering pipeline is mapped onto current

    graphics acceleration hardware such that theinput to the GPU (graphics processing unit) is in

    the form of vertices.

    These vertices then undergo transformation and

    per-vertex lighting. At this point in modern GPUpipelines a custom vertex shader program can be

    used to manipulate the 3D vertices prior to

    rasterization.

  • 8/11/2019 Graphics Sw

    26/27

    Once transformed and lit, the vertices

    undergo clipping and rasterization resulting

    in fragments. A second custom shader

    program can then be run on each fragment

    before the final pixel values are output to the

    frame buffer for display. The graphics pipeline is well suited to the

    rendering process because it allows the GPU

    to function as a stream processor since all

    vertices and fragments can be thought of asindependent.

  • 8/11/2019 Graphics Sw

    27/27

    This allows all stages of the pipeline to be

    used simultaneously for different vertices orfragments as they work their way through the

    pipe.

    In addition to pipelining vertices and

    fragments, their independence allows

    graphics processors to use parallel

    processing units to process multiple vertices

    or fragments in a single stage of the pipelineat the same time.

    ----------------------