Exploring Graphics Design in C/C++ with OpenGL
Instruction for compilation on
Unix
or
Windows
platforms!
Playing Cards executable file for Windows platform:
* NOTE: GLUT32.DLL file has to be placed in the same
diractory as CARDS.exe
- A low-level graphics imaging library, which can be used to create simple
two demantional pictures. This library offers a set of geometric primitives
- points, lines, polygons, images, and bitmaps. Using this primitives we can
draw varies images like triangles, circles, squares and other figures.
- The OpenGL was designed for use with the C and C++ programming languages
but there are also other programming languages such as Java, Tcl, Ada, and
FORTRAN that use OpenGL for graphcal use.
- Any C++ program can include OpenGL library which is platform independent,
meaning it can be recompiled on any platform like:
- X Window System under UNIX
- Microsoft Windows or Windows NT
- IBM OS/2
- Apple Mac OS
Where do you get OpenGL?
- Windows
An OpenGL v1.1 software runtime ships as part of Windows NT v4.0, Windows
2000, Windows 98, and Windows 95 (OSR2) . The OpenGL v1.1 libraries are also
available as the self-extracting archive file from the Microsoft Site via
HTTP or FTP.
OpenGL v1.2, 1.3, & 1.4 are included with the drivers for your OpenGL
video cards. So you only need to make sure you have the latest OpenGL driver
for your video card. If you do not have the latest driver with OpenGL 1.2
or 1.3 or 1.4 support, either use GLSetup (for Win95/98 only) or go to the
website of your video card manufacturer download the latest OpenGL driver
for your card and OS.
- Texture Mapping
- the ability to apply an image to graphics surface
use to rapidly generate realistic images without having to specify an excessive
amout of detail
- ie. create a wooden floor by painting the floor’s rectangular surface
with a wood grain texture
- Z-buffering
- the ability to calculate the distance from the viewer’s location
- make it easy for the program to automatically remove surfaces or parts of
surface that are hidden from view
- Double buffering
- support for smooth animation using double buffering
drawing into the back buffer while displaying the front buffer and then swapping
the buffers when you are ready to display.
- Lighting effects
-the ability to calculate the effects on the lightness of a surface’s
color when different lighting models are applied to the surface from one or
more light sources
- Smooth shading
- the ability to calculate the shading effects that occur when light hits
a surface at an angle and results in subtle color differences across the surface
- this effect is important for making a model look “realistic”
- Material Properties
- the ability to specify the material properties of a surface
1. dullness
2. shininess
- Alpha Blending
- the ability to specify an alpha or “opacity” value in addition
to regular RGB value
- Transformation Matrices
- the ability to change the location, size and perspective of an object in
3D coordinate
space
· the same way that GDI ( Graphics Device Interface) work
whenever a program makes an OpenGL call, the OPENGL32 and GLU32 DLLs are loaded.
What is not in OpenGL?
- any function for window management
- user interaction
- file I/O
Limitation of OpenGL?
Microsoft Generic implementation of OpenGL
- no direct support for printing OpenGL graphics to a monochrome printer or
a color printer with less than 4 bit planes of color
- hardware palettes for various windows are not supported
- some OpenGL features are not implemented, including stereoscopic images,
auxiliary buffers, and alpha bit planes.
The most easiest way to compile C++ program with OpenGL library is to create
a script.
Step 1: Create a file called “make” or give it any name
Step 2: Type in: g++ -I/sw8/include $1 –L/sw8/lib –lglut –lGLU
–lGL –lm –lXext
-lXmu –lXi –lX11 –o
(for compiling multiple files add $2,$3… Example: g++ -I/sw8/include $1
–L/sw8/lib –lglut –lGLU –lGL –lm –lXext
-lXmu –lXi –lX11 $2 $3 –o $4 , where $4 is the same as A.OUT)
Step 3: Change the mode of the file> chmod 711 make
Step 4: Compile your file> make filename.cpp
Step 5: (for multiple files)> make file1.cpp file2.cpp file3.cpp A_OUT