Assignment No 1
Assignment No 1
Assignment Name:
Computer Graphics(Basic and how to install OpenGL/Glut)
INTRODUCTION
What is Computer Graphics?
Branch of Computer Science.
Computer + Graphs + Pics = Computer Graphics.
Drawing line, Chart, Graphs etc. on the screen using Programming language is computer
Graphics.
Computer graphics is the branch of computer science that deals with generating images
with the aid of computers. It displays the information in the from of graphics objects such
as picture, charts, graphs and diagrams instead of simple text. We can say computer
graphics makes it possible to express data in pictorial form.
OpenGL
It is cross-platform, cross-language API for rendering 2D and 3D Graphics(Vector
Graphics).
Getting started with OpenGL
Open Graphics Library (OpenGL) is a cross-language (language independent), cross-
platform (platform-independent) API for rendering 2D and 3D Vector Graphics(use of
polygons to represent image). OpenGL API is designed mostly in hardware.
Design : This API is defined as a set of functions which may be called by the client
program. Although functions are similar to those of C language but it is language
independent.
Development : It is an evolving API and Khronos Group regularly releases its new
version having some extended feature compare to previous one. GPU vendors may
also provide some additional functionality in the form of extension.
Associated Libraries : The earliest version is released with a companion library
called OpenGL utility library. But since OpenGL is quite a complex process. So in
order to make it easier other library such as OpenGL Utility Toolkit is added which is
later superseded by free glut. Later included library were GLEE, GLEW, and gliding.
Implementation : Mesa 3D is an open source implementation of OpenGL. It can do
pure software rendering and it may also use hardware acceleration on BSD, Linux,
and other platforms by taking advantage of Direct Rendering Infrastructure.
Rendering Pipeline
Most implementations of OpenGL have a similar order of operations, a series of
processing stages called the OpenGL rendering pipeline. Although this is not a strict rule
of how OpenGL is implemented, it provides a reliable guide for predicting what OpenGL
will do. Geometric data (verices, line, and polygons) follow a path through the row of
boxes that includes evaluators and per-vertex operations, while pixel data (pixels, images
and bitmaps) are treated differently for part of the process. Both types of data undergo the
same final step (raterization) before the final pixel data is written to the framebuffer.
Display Lists: All data, whether it describes geometry or pixels, can be saved in a
display list for current or later use. (The alternative to retaining data in a display list is
processing the data immediately-known as immediate mode.) When a display list is
executed, the retained data is sent from the display list just as if it were sent by the
application in immediate mode.
Pixel Operations: While geometric data takes one path through the OpenGL rendering
papeline, pixel data takes a different route. Pixels from an array in system memory are
first unpacked form one of a variety of formats into the proper number of components.
Next the data is scaled, biased, processed by a pixel map, and sent to the rasterization
step.
Rasterization: Rasterization is the conversion of both geometric and pixel data into
fragments. Each fragment square corresponds to a pixel in the framebuffer. Line width,
point size, shading model, and coverage calculations to support antialiasing are taken ito
consideration as vertices are connected into lines or the interior pixels are calculated for a
filled polygon. Color and depth values are assigned for each fragment square. The
processed fragment is then drawn into the appropriate buffer, where it has finally
advanced to be a pixel and achieved its final resting place.
Libraries
OpenGL provides a powerful but primitive set of rendering command, and all higher-
level drawing must be done in terms of these commands. There are several libraries that
allow you to simplify your programming tasks, including the following:
OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL
commands to perform such tasks as setting up matracies for specific viewing orientations
and projections and rendering surfaces.
OpenGL Utility Toolkit (GLUT) is a window-system-independent toolkit, written by
Mark Kilgard, to hide the complexities of differing window APIs.
Include Files
For all OpenGL applications, you want to include the gl.h header file in every file.
Almost all OpenGL applications use GLU, the aforementioned OpenGL Utility Library,
which also requires inclusion of the glu.h header file. So almost every OpenGL source
file begins with:
#include <GL/gl.h>
#include <GL/glu.h>
If you are using the OpenGL Utility Toolkit (GLUT) for managing your window
manager tasks, you should include:
#include <GL/glut.h>
OpenGl Functions:
glutInit:
Used to initialize GLUT.
glutCreateWindow
Used for creating a top-level window. You can supply the window name
as a label while creating the window.
glutInitWindowSize
Used to define the window size. The width and height of the window
are specified in pixels while defining the window size.
void glutInitWindowPosition