What is OpenGL? Applications Main functions Demo Referencer
Simple, device independent 3D drawing and rendering API (~120 functions) Silicon Graphics main sponsor ~1993 and still going strong GLUT - adds device handling and utility functions
Modeling (Creating 3D Geometry)
Rendering (Creating, shading images from geometry, lighting, materials)
Vertex
Vertex
CPU Polygon definitions Display list compilations Colour definitions Texture loading Application logic: loops, collision detection, user interaction menus
Graphics Card Matrix and vector calculations Coordinate transformations Texture mapping Depth (z) buffer calculations Lighting and rendering Pixel drawing Display buffer switching
Platonic solids
Cube
Torus
Sphere
Platonic solids
Cube
Torus
Teapot
Sphere
glVertex*(); glVertex2f(a,b); glVertex3f(a,b,c); glVertex4f(a,b,c,d); V1
OpenGL spells glBegin(GL_*); *(POINTS, LINES, TRIANGLES, QUADS) glVertex3f(0, 0, 0); glVertex3f(2, 0, 0); glVertex3f(1, 2, 0); ... glEnd();
V2 V3
Single Color glColor3f(1, 0, 0); //RGB glVertex3f(0, 0, 0); glVertex3f(2, 0, 0); glVertex3f(1, 1, 0);
Auto Blending glColor3f (1, 0, 0); glVertex3f(0, 0, 0); glColor3f (0, 1, 0); glVertex3f(2, 0, 0); glColor3f (0, 0, 1); glVertex3f (1, 1, 0);
(0,0)
(0,1)
(1,0)
(1,1)
(0,0)
(1,0)
(0,1)
(1,1)
glTexCoord2f (0.4, 0.1); glVertex3f (0, 0, 0); glTexCoord2f (0.5, 1.0); glVertex3f (1, 1.0, 0); glTexCoord2f (1.0, 0.0); glVertex3f (0, 0, 2);
GLfloat amb[] = { 0.1, 0.1, 0.1, 1.0 }; GLfloat diff[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat spec[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat pos[] = { 20, 20, 20, 0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, diff); glLightfv(GL_LIGHT0, GL_SPECULAR, spec); glLightfv(GL_LIGHT0, GL_POSITION, pos);
glTranslatef(x, y, z); glRotatef(x, y, z); glScalef(x, y, z); glPushMatrix(); glPopMatrix();
Using only Simple geometrical objects Colors Textures Transformations
You can build complex programs Example
Display lists glNewList(LIST#, GL_COMPILE); glBegin(GL_QUADS); ... add C/C++ code glEnd(); glEndList();
Textures Use of mipmaps for texturing far away objects Geometry
Specify clipping of distant objects Reduce number of function calls Reduce polygon count for distand objects Vertex Arrays
OpenGL and GLUT are free All major OS s (Windows, Linux, Mac,..) Getting started on Windows MS Visual C++ 2008 Express Edition (free!) MS Platform SDK OpenGL and GLUT installation http://www.hackorama.com/opengl/)
Google OpenGL tutorial
CVS Viewer Solar system simulator* Lego builder 3D Curves H3 viewer KnotPlot Google Sketchup Orbiter Google Earth * Selected features only :-)
Anonymous, OpenGl Reference Manual , Addison-Wesley Mark Kilgard, GLUT Programming Interface Tom McReynolds et.al., Advanced Graphics Programming using OpenGL , Morgan Kaufmann Elsevier Jackie Neider et.al., OpenGl Programming Guide , AddisonWesley Robert Withrow, OpenGL graphics Through Applications , Springer Richard Wright et. al., OpenGl Superbible , Sams Publishing http://www.opengl.org http://ogle.eyebeamresearch.org/ http://nehe.gamedev.net/
This document was created with Win2PDF available at http://www.daneprairie.com. The unregistered version of Win2PDF is for evaluation or non-commercial use only.