Abstract
Abstract
Abstract
of Computer Engineering
ABSTRACT
computer graphics. The interface consists of over 250 different function calls which
OpenGL was developed by Silicon Graphics Inc. (SGI) in 1992 and is widely used in
INTRODUCTION:
become the industry's most widely used and supported 2D and 3D graphics
Developers can leverage the power of OpenGL across all popular desktop
Developer-Driven Advantages
• Industry standard
An independent consortium, the OpenGL Architecture Review Board,
guides the OpenGL specification. With broad industry support, OpenGL
is the only truly open, vendor-neutral, multiplatform graphics standard.
• Stable
OpenGL implementations have been available for more than seven
years on a wide variety of platforms. Additions to the specification are
well controlled, and proposed updates are announced in time for
developers to adopt changes. Backward compatibility requirements
ensure that existing applications do not become obsolete.
• Reliable and portable
All OpenGL applications produce consistent visual display results on
Vidyavardhini’s college of Engineering & Technology Department
of Computer Engineering
OBJECTIVES:
To study and implement OpenGL and its associated technologies, which are
widely used in todays industries and from games to virtual reality,
mobile phones to supercomputers
Advantages of OpenGL:
• OpenGL advantages:
o device independent
o Fast! If hardware acceleration exists, then high quality graphics
possible in realtime
o 2D and 3D (3D will be extension of 2D shapes, but in 3D
coordinate space)
o sophisticated features: shadows, fog, textures, lighting effects
(later in course)
o popular standard: OpenGL applications may begin to appear for
PC's
• drawing primitives covered thus far have limitations:
o OpenGL primitives looked at do not retain the geometric shapes
drawn: they simply writes over pixels in its raster display
o If you want to delete a line, rescale a square, or do other re-
editing, the application program has to send additional
commands to do it;
o akin to using MacPaint; compare with MacDraw, in which you can
grab objects (lines, squares, .,..) rescale them, and move them
about screen
o the openGL application should retain model information
o Some graphics libraries will retain data structures that save the
geometric shapes:
Vidyavardhini’s college of Engineering & Technology Department
of Computer Engineering
eg. VRML
But also see OpenGL's display lists!
• glut library:
o comprehensive
o Windows-based systems will permit other I/O to be used
Disadvantages of OpenGL:
If you want to use advanced graphics output, you have to decide, whether
you prefer OpenGL or DirectX. Each of them has its specific advantages and
disadvantages. While OpenGL exists on all major platforms (Linux, Windows,
Macintosh,…) DirectX is limited to Windows, but on the other hand DirectX
supports multimedia, which OpenGL is just starting to support (the so called
OpenML). Due to the platform independence of OpenGL, I will use OpenGL to
show how advanced graphics can be implemented.
CODE:
#include <GL/glut.h>
void
Vidyavardhini’s college of Engineering & Technology Department
of Computer Engineering
drawBox(void)
{
int i;
void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawBox();
glutSwapBuffers();
}
void
init(void)
{
/* Setup cube vertex data. */
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(
40.0,
/* aspect ratio */
1.0,
/* Z near */
1.0,
/* Z far */
10.0);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 0.0, 5.0,
/* eye is at (0,0,5) */
/* center is at (0,0,0) */
/* up is in positive Y direction */
int
main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("red 3D lighted cube");
glutDisplayFunc(display);
init();
glutMainLoop();
return 0;
ANALYSIS:
GLfloat light_diffuse[ ]
This will create diffused RED light
GLfloat n[ ][ ]
Creates normals for the 6 faces of a cube.
GLint faces[ ][ ]
Creates vertex indices for the 6 faces of a cube.
drawBox(void)
This function draws a box.
display(void)
This function calls the various functions required to display the3D model.
init(void)
Initializes the current position of the cube.
Vidyavardhini’s college of Engineering & Technology Department
of Computer Engineering
OUTPUT:
Vidyavardhini’s college of Engineering & Technology Department
of Computer Engineering
Result:
CREDIT:
We would like to thank our project guide and class-incharge Prof. Sunil Katkar
without whom this project would not have been possible. We would also like to
thank the non-profit technology consortium, the Khronos Group for creating this
REFERENCES
http://www.opengl.org
http://www.opengl.org/developers/documentation/overviews.h
tml
http://www.nullterminator.net/opengl32.html
http://www.opengl.org/developers/code/tutorials.html
Vidyavardhini’s college of Engineering & Technology Department
of Computer Engineering
http://en.wikipedia.org/wiki/OpenGL