This document discusses graphics software and the graphics pipeline. It describes two types of graphics packages - special purpose packages for non-programmers to generate images and general programming packages that provide graphics libraries to be used within programming languages. It then explains the basic functions and components of graphics libraries, including primitives, attributes, transformations, and viewing. Finally, it outlines the stages of the graphics pipeline, from 3D modeling to rasterization and rendering on hardware.
This document discusses graphics software and the graphics pipeline. It describes two types of graphics packages - special purpose packages for non-programmers to generate images and general programming packages that provide graphics libraries to be used within programming languages. It then explains the basic functions and components of graphics libraries, including primitives, attributes, transformations, and viewing. Finally, it outlines the stages of the graphics pipeline, from 3D modeling to rasterization and rendering on hardware.
This document discusses graphics software and the graphics pipeline. It describes two types of graphics packages - special purpose packages for non-programmers to generate images and general programming packages that provide graphics libraries to be used within programming languages. It then explains the basic functions and components of graphics libraries, including primitives, attributes, transformations, and viewing. Finally, it outlines the stages of the graphics pipeline, from 3D modeling to rasterization and rendering on hardware.
2. General programming packages. Special purpose packages are designed for non programmers who want to generate pictures, graphs or charts. A set of menus that allows users to communicate with the programs in their own terms. Eg: artists painting programs, various architectural, business, medical and engineering CAD systems.
General programming packages provides a library of graphics functions that can be used in a programming language. Eg: GL (graphics library), OpenGL, VRML (virtual reality modeling language), Java 2D, Java 3D. 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.
A set of graphics functions is often called a CG API (computer graphics application programming interface). Because the library provides a s/w interface between a programming language and the h/w. so when we write an application program in OpenGL the graphics routines allow us to construct and display a picture on an o/p device. 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.
Attribute - properties of the o/p primitives. it describes how a particular primitive 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 geometric transformations. Viewing transformations - are used to select a view of the scene , the type of projection to be used , and the location on a video monitor where the view is to be displayed. input functions are used to control and process the dataflow from interactive devices. 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. 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. Constants begin with uppercase letters GL. Component words within a constant name are written in capital letters. Underscore (_) is used as a separator. GL_2D, GL_RGB, GL_CCW, GL_POLYGON Data types in OpenGL GLbyte GLshort GLint GLfloat GLdouble GLboolean OpenGL variable types and corresponding C data types OpenGL Data Type| Internal Representation| defined as C Type GLbyte 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 Header files #include<windows.h> #include<gl.h> #include<glu.h> #include<glut.h> #include <stdlib.h>
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). ----------------------
Graphics pipeline
Graphics pipeline or rendering pipeline refers to the sequence of steps used to create a 2D raster representation of a 3D scene. once you have created a 3D model, in a video game, or a 3D computer animation, the graphics pipeline is the process of turning that 3D model into what the computer displays. allowing greater flexibility in graphics rendering. 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. 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. Camera transformation Transform the 3D world coordinate system into the 3D camera coordinate system, with the camera as the origin. 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.
Projection transformation Transform the 3D world coordinates into the 2D view of the camera. In the case of a Perspective projection, objects which are distant from the camera are made smaller. This is achieved by dividing the X and Y coordinates of each vertex of each primitive by its Z coordinate (which represents its distance from the camera). In an orthographic projection, objects retain their original size regardless of distance from the camera.
Clipping Geometric primitives that now fall completely outside of the viewing frustum will not be visible and are discarded at this stage.
Scan conversion or rasterization Rasterization is the process by which the 2D image space representation of the scene is converted into raster format and the correct resulting pixel values are determined. 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. The graphics pipeline in hardware The rendering pipeline is mapped onto current graphics acceleration hardware such that the input 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 GPU pipelines a custom vertex shader program can be used to manipulate the 3D vertices prior to rasterization.
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 as independent.
This allows all stages of the pipeline to be used simultaneously for different vertices or fragments 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 pipeline at the same time. ----------------------