10-06-2013, 02:23 PM
PROJECT REPORT ON LIGHT LAB
LIGHT LAB.doc (Size: 817 KB / Downloads: 32)
OpenGL.doc (Size: 26.5 KB / Downloads: 24)
INTRODUCTION
COMPUTER GRAPHICS
Computer graphics is the creation and manipulation of pictures with the aid of computers. It is divided into two broad classes.
1. Non interactive Computer Graphics
2. Interactive Computer Graphics
1. Non-interactive Computer Graphics:
In non-interactive graphics or passive graphics the observer has no control over the pictures produced on the screen. While in interactive graphics the pictures displayed on the screen are controlled by the user through an input device.
Interactive Computer Graphics:
This is the type of Computer Graphics in which the user can control the pictures produced. It involves two-way communication between user and computer. The computer upon receiving signal from the input device can modify the displayed picture appropriately. To the user it appears that the picture is changing instantaneously in response to his commands. In this way he maintains a conversation with the computer.
The graphics editor extensively uses the standard header file available in package to implement the user interface, i.e., Windows and popup menus.
The editor takes a file from the disk and loads the file into editor. The user can modify the file as he likes by using the keyboard or the menus provided and if he wishes he could also save the changes made by saving the file. This puts back the new file in the disk, i.e., the storage device. The user can also perform other useful operations like printing, change color. He can also delete a file from the secondary storage without leaving the editor.
OPENGL
OpenGL is a software interface to graphics hardware. This interface consists of about 150 distinct three-dimensional applications.
OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms. To achieve these qualities, no command for performing windowing tasks system controls the particular hardware we are using.
A sophisticated library that provides these features could certainly be built on top of OpenGL. The OpenGL Utility Library (GLU) provides many of the modeling features, such as quadric surfaces and NURBS curves and surfaces. GLU is a standard part of every OpenGL implementation. Also, there is a higher-level, object-oriented toolkit, Open Inventor, which is built at OpenGL, and is available separately for many implementations of OpenGL.
The color plates give us an idea of the kinds of things we can do with the OpenGL graphics system. The following list briefly describes the major graphics operations which OpenGL performs to render an image on the screen.
Construct shapes from geometric primitives, thereby creating mathematical descriptions of objects. (OpenGL considers points, lines, polygons, images, and bitmaps to be primitives).
Arrange the objects in three-dimensional space and select the desired vantage point for viewing the composed scene.
Calculate the color of all the objects. The color might be explicitly assigned by the application, determined from specified lighting conditions, obtained by pasting a texture onto the objects, or some combination of these three actions.
Convert the mathematical description of objects and their associated color information to pixels on the screen. This process is called rasterization.
A Smidgen of OpenGL Code
Because we can do so many things with the OpenGL graphics system, an OpenGL program can be complicated. However, the basic structure of a useful program can be simple: Its tasks are to initialize certain states that control how OpenGL renders and to specify objects to be rendered. The final rendered image consists of pixels drawn on the screen; a pixel is the smallest visible element the display hardware can put on the screen. Information about the pixels (for instance, what color they’re supposed to be) is organized in memory into bitplanes. A bitplane is an area of memory that holds one bit of information for every pixel on the screen; the bit might indicate how red a particular pixel is supposed to be, for example. The bitplanes are themselves organized into a framebuffer, which holds all the information that the graphics display needs to control the color and intensity of all the pixels on the screen.
OpenGL as a State Machine
OpenGL is a state machine. We put it into various states (or modes) that then remain in effect until we change them. As we have already seen, the current color is a state variable. We can set the current color to white, red, or any other color, and thereafter every object is drawn with that color until we set the current color to something else. The current color is only one of many state variables that OpenGL maintains. Others control such things as the current viewing and projection transformations; line and polygon stipple patterns, polygon drawing modes, pixel-packing conventions, positions and characteristics of lights, and material properties of the objects being drawn. Many state variables refer to modes that are enabled or disabled with the command glEnable() or glDisable(). Each state variable or mode has a default value, and at any point we can query the system for each variable’s current value.
LIGHTING IN OPENGL
Light is the most important idea behind visual representation of anything that a human being can visually perceive. The light rays commonly originate from an energy source such as the sun, lamp etc.
A surface can either emit light by self-emission, as a light bulb does, or reflect light from other surfaces that illuminate it. Some surfaces may both reflect light and emit light from internal physical process. When we look at a point on an object, the color that we see is determined by multiple interactions among light sources and reflective surfaces.
OpenGL adopts three different types of lights. Namely ambient light, diffuse light and specular light.
How lighting is enabled in OpenGL?
glEnable(GLenum cap): This function has many uses. It can "enable" many features of OpenGL. The feature we want to enable is specified in the flag cap. How is this related to light programming? glEnable is used to enable lighting on the whole when we pass GL_LIGHTING parameter to it. gEnable is also responsible for enabling a particular light source in our 3D scene. This is done by calling glEnable(GL_LIGHTn); where n is the index number of the color we are enabling, ranging from 0 to 7 because OpenGL lets us specify a maximum of eight light sources.
CONCLUSION
This package has been developed as per requirements specified by the VTU as a partial fulfillment of the computer graphics lab prescribed for 6th semester, CSE. All the requirements given have been implemented in the editor. It utilizes various inbuilt functions provided by the C++ with OpenGL language.
This project is about demonstrating the lighting and shading effects of the objects.
In our package we develop an user interactive system where user can select the left light color, right light color and material of the object. The objects used are torus, teapot and icosahedron. The colors of the light used are red, green and white or we can disable the light. The materials used for the object are red plastic, emerald, brass and slate.
Though the presented project is developed in c/c++, they can be further upgraded to support some other languages as well. Thus the entire source code or the project gives a brief description of the entire Graphics system concepts being used today (i.e.) the use of OpenGL for various graphics applications or develop interactive graphic models providing 3D view.