Introduction to OpenGL Programming

Report
Introduction to OpenGL
Programming
Jian-Liang Lin
2002
What is OpenGL? -1
OpenGL is a cross-platform standard
for 3D rendering. and software interface
to graphics hardware.
The OpenGL Architecture Review
Board(ARB), and independent
consortium formed in 1992, governs the
OpenGL specification.
OpenGL routines use the prefix gl.
What is OpenGL? -2
Designed as a hardware-independent
interface and implemented on many different
hardware platforms.
No commands for performing windowing
tasks or obtaining user input are included in
OpenGL.
You must work through whatever
windowing system controls the particular
hardware you're using.
What is OpenGL? -3
OpenGL doesn't provide high-level
commands for describing models of
three-dimensional objects.
With OpenGL, you must build up your
desired model from a small set of
geometric primitives.
– points, lines, triangles, and polygons …etc.
The Advantages of OpenGL
Industry standard
Fast
Portable
Easy to use
Well-documented
OpenGL rendering pipeline
Color Models
RGBA color
– Red, Green, Blue, and Alpha channels
– Up to 16M colors
Color-indexed
– Small numbers of colors accessed by
indices from a color lookup table(palette)
– 8 bits = 256 colors
Basic Features
Transformation
Materials Lighting & Smooth Shading
Texture mapping
Depth buffer test (Z-Buffer)
Alpha blending
Double buffering for animation
Pixel operations
OpenGL Buffering -1
OpenGL supports a variety of buffers
for advanced rendering
– Depended on driver implementation
Color buffers
– Front-left, front-right, back-left, back-right,
and any number of auxiliary buffers
Depth buffer
– Also known as Z-Buffer for HSR
OpenGL Buffering -2
Alpha buffer
– Blending
Stencil buffer
– To restrict drawing to certain portions of
the screen. (basic application)
Accumulation buffer
– Full scene manipulation
API Hierarchy
OpenGL library -1
SGI’s OpenGL SDK
– OpenGL.DLL & GLU.DLL
– Open source implementation for hardware
vendor reference.
– Best software rendering library.
– Can be downloaded from SGI’s website.
OpenGL library -2
Microsoft’s implementation
– From Win95 OSR2, Microsoft Windows
ship with OpenGL32.DLL.
– For old Win95 users, you still can
download OPENGL95.EXE via Microsoft
website.
– Header files and import library files are
already included in Win32 Platform SDK.
OpenGL library -3
Microsoft’s OpenGL32.DLL applies a
hardware accelerated driver registered
in Registry.
–
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers
– You can search it by using REGEDIT.EXE
Mesa Graphics Library
A OpenGL clone library.
You can use it as using OpenGL.
Portable on many OS.
You can download it in the following
website
– http://www.mesa3d.org/
OpenGL Utility Library
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
GLU routines use the prefix glu.
– gluLookAt( … );
– …
Windows system related
helper library
For every window system, there is a
library that extends the functionality of
that window system to support
OpenGL rendering.
– X Window System -> GLX
– Microsoft Windows -> WGL
– IBM OS/2 -> PGL
OpenGL Utility Toolkit -1
The OpenGL Utility Toolkit (GLUT) is a
window system-independent toolkit,
written by Mark Kilgard, to hide the
complexities of differing window
system APIs.
GLUT routines use the prefix glut.
– glutPostRedisplay();
–…
OpenGL Utility Toolkit -2
You can download this toolkit in the
following website
– http://reality.sgi.com/mjk_asd/glut3/glut3.html
We focus on this toolkit.
Programming Environment -1
PC(X86)
– OpenGL v1.1 software runtime is included
as part of operating system for Win 2000,
Windows 98, Windows 95 (OSR2) and
Windows NT
– Linux, FreeBSD, …other UNIX-like
OS can use Mesa graphics library.
Programming Environment -2
SGI workstation
– Personal IRIS, Indigo, Indy, Indigo2 O2,
– Octane in CGGM Lab.
– All with IRIS Operating System and X
Window System
Compilers – Microsoft Visual C++
Start a new workspace of Win32
Console application.
Add OpenGL32.lib glu32.lib glut32.lib
in Projects/Setting/Link/Library
modules column for linking
Compilers – Unix-like OS
Library files needed
– libGL.so, libGLU.so, libglut.a, libX11.a,
libX11.so …etc
Command line:
– gcc [source files] –o [output file] –lglut –
lGLU –lGL –lX11 –lm
– The ordering of the linking flags is not
changeable.
– Suggest to write a Makefile.
Where is the reference?
OpenGL official site
– http://www.opengl.org
You refer to OpenGL API
documentation in MSDN Library.
How can you start?
Choose your platform
Get your desire OpenGL related library.
Start a GLUT simple program, build and test.
Refine the code as you wish.
Refer to some reference materials.
Consult with TA 
Feel happy to see the result.
Any Question?

similar documents