lecture 03 overview of computer graphics programming n.
Skip this Video
Loading SlideShow in 5 Seconds..
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University PowerPoint Presentation
Download Presentation
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University

Loading in 2 Seconds...

play fullscreen
1 / 49

CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University - PowerPoint PPT Presentation

  • Uploaded on

Lecture 03 Overview of Computer Graphics Programming. CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University. Creating 3D Graphics Content. Different ways to create graphics content If you want to create non-interactive 3D animations

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University' - jana

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
lecture 03 overview of computer graphics programming
Lecture 03

Overview of Computer Graphics Programming

CSC4820/6820 Computer Graphics AlgorithmsYing ZhuGeorgia State University
creating 3d graphics content
Creating 3D Graphics Content
  • Different ways to create graphics content
  • If you want to create non-interactive 3D animations
    • Use graphics modeling/animation tools: 3DS Max, Maya, Blender, etc.
  • If you want to create interactive 3D applications (game, training & simulation program)
    • A combination of both modeling/animation tools and programming
    • C/CPP + scene graph + OpenGL/D3D + Shader
graphics libraries apis
Graphics Libraries (APIs)
  • 3D graphics applications are built on top of graphics libraries
  • A collection of graphics routines that an application program can call
  • The APIs hide the underlying complexity of graphics hardware and/or lower level APIs
  • Large scale graphics applications are usually built on top of high level graphics APIs
graphics libraries apis1
Graphics Libraries (APIs)
  • High level APIs are implemented on top of low level graphics APIs
  • Low level APIs control graphics hardware through graphics drivers
  • Between low level graphics APIs and graphics drivers there are shader libraries
high level graphics apis
High Level Graphics APIs
  • Also known as Scene Graph APIs
  • Non-real-time oriented APIs
    • Java3D
    • VRML & X3D
    • Open Inventor
    • Renderman
high level graphics apis1
High Level Graphics APIs
  • Real-time oriented APIs
  • 3D graphics and game engines
    • Torque Game Engine
    • OGRE
    • OpenGL Performer
    • Open Scene Graph
    • OpenSG
  • Many proprietary high level APIs
game engines
Game Engines
  • Game engine
    • Graphics API designed specifically for game development
    • Contains all non-content related functions/elements
game engine
Game Engine
  • Game Architecture


Game engine

Tools & Editor

Graphics Hardware

modern game engine features
Modern Game Engine Features
  • Scene management
    • Culling,
    • Rendering
      • Bump mapping
      • Shadow
    • Collision
    • Decals
    • AI
  • Particle systems, etc.
  • Shader management
game engines1
Game Engines
  • There are hundreds of game engines
  • Most popular game engines
    • Torque Game Engine (commercial)
    • OGRE (open source)
  • For a comprehensive list, check out http://www.devmaster.net/engines/
torque game engine
Torque Game Engine
  • A very popular game engine with multi-player network code, indoor/outdoor rendering engines, skeletal animation, drag and drop GUI creation, a built in world editor, and a C-like scripting language.
  • http://www.garagegames.com/
  • Object-oriented Graphics Rendering Engine
  • A scene-oriented, flexible 3D engine written in C++ designed to make it easier and more intuitive for developers to produce games and demos using 3D hardware.
  • http://www.ogre3d.org/
  • High level object-oriented scene graph API
    • https://java3d.dev.java.net/
    • http://www.j3d.org/
  • Platform independent, implemented on top of Direct3D or OpenGL
  • Try to meet a wide variety of application requirements
    • Real-time performance
    • Object modeling
    • Input devices support
    • Stereoscopic vision
  • Java OpenGL (JOGL)
    • https://jogl.dev.java.net/
    • A wrapper library that allows OpenGL to be used in the Java programming language
vrml x3d
  • VRML = Virtual Reality Modeling Language
    • HTML like language for describing 3D shapes and interaction
  • X3D
    • Next generation open standard for 3D on the web
    • Officially replaced VRML in July 2004
    • X3D supports XML for tight integration with Web technologies and tools
    • http://www.web3d.org/
opengl performer
OpenGL Performer
  • A graphics API developed by SGI for real-time visual simulation and other performance oriented applications
  • Implemented on top of OpenGL, with performance as the first priority
  • http://www.sgi.com/products/software/performer/
  • Performer has great influence on other real-time graphics APIs
    • E.g. Open Scene Graph (http://www.openscenegraph.org/projects/osg)
why so many scene graph apis game engines
Why so many scene graph APIs & game engines?
  • Different target applications
    • Real-time vs. non-real-time applications
  • Application specific optimizations
  • Application specific entities
    • E.g. different game genres require different game engines
why so many scene graph apis game engines1
Why so many scene graph APIs & game engines?
  • Language and platform considerations
    • Platform specific optimizations
  • Open source vs. proprietary APIs
  • Integration of new technologies
  • Not necessarily a good thing
    • Lack of documents & sample code
low level graphics apis
Low Level Graphics APIs
  • Directly handles 3D rendering
  • Very efficient implementation
  • Only two major low level 3D graphics APIs
    • OpenGL
    • Direct3D (part of DirectX)
  • Comparison of Direct3D and OpenGL
    • http://en.wikipedia.org/wiki/Comparison_of_Direct3D_and_OpenGL
  • Part of Microsoft’s DirectX libraries
    • Including Direct3D, DirectInput, DirectSound, etc.
  • Designed for real-time graphics applications
    • Computer game
    • Home entertainment
  • Primary choice for game development
  • Latest version is DirectX 10
    • http://www.microsoft.com/windows/directx/default.aspx
  • Only supported on MS Windows platform
using direct3d
Using Direct3D
  • Benefits
    • Supported by most of the graphics hardware
    • Better game support
    • Better integration with other MS stuff (e.g. .Net)
    • Maintained by one single company
      • Quick to add new features to Direct3D
  • Drawbacks
    • Somewhat more difficult to learn than OpenGL
    • Windows only
  • Platform independent graphics API
    • MS Windows, Linux, IRIX, Solaris, Mac, etc.
  • Window system independent
    • MS Windows, X Window
  • Maintained by KHRONOS group (an industry consortium)
    • Members include 3Dlabs, AMD, NVIDIA, Intel, Google, etc.
  • Current specification: OpenGL 3.0


using opengl
Using OpenGL
  • Benefits
    • Open standard
    • Supported by all the graphics cards
    • Supported by all the platforms
    • Lots of books, tutorials, and samples available
      • Most of the mainstream 3D graphics textbooks use OpenGL
  • Drawbacks
    • Historically, OpenGL is often slow to add new features
    • Users are often forced to use OpenGL extensions
  • http://www.opengl.org/
opengl extension
OpenGL Extension
  • OpenGL extensions provide new rendering features above and beyond the features specified in the official OpenGL standard
  • To keep the OpenGL API current with the latest innovations in graphics hardware and rendering algorithms
  • Different kind of extensions:
    • Extensions ratified by the ARB: GL_ARB_multitexture();
    • Extensions agreed on by multiple vendors: GL_EXT_abgr();
    • Vendor specific extensions: GL_NV_register_combiners();
opengl extension1
OpenGL Extension
  • To find out what OpenGL extensions your graphics card supports, download and install Glview utility (OpenGL extension viewer)
    • http://www.realtech-vr.com/glview/
opengl related apis
OpenGL Related APIs
  • GLU (OpenGL Utility Library)
    • Mostly modeling related functions: NURBS, tessellators, etc.
    • Part of OpenGL
  • GLX: connecting OpenGL with X Window
  • WGL: connecting OpenGL with MS Windows
opengl related apis1
OpenGL Related APIs
  • GLUT (OpenGL Utility Toolkit)
    • implements a simple windowing application programming interface (API) for OpenGL
    • makes it easier to learn OpenGL programming
    • designed for constructing small to medium sized OpenGL programs
  • We will use GLUT in this class
    • Binary files: http://www.xmission.com/~nate/glut.html
    • Reference manual: http://www.opengl.org/resources/libraries/glut/spec3/spec3.html
gpu and shader
GPU and Shader
  • Graphics Processing Units are the microprocessors on the newer graphics cards
    • Nvidia, AMD, and Intel are the main GPU vendors
  • You can write programs that runs on GPU using a special programming language
    • These programs are called shaders
    • The programming languages are called shading languages
shader programming
Shader Programming
  • Why use shaders?
    • To implement features that are not available on OpenGL or Direct3D
    • Take advantage of GPU, which is is optimized for graphics applications
  • Faster and more flexible
  • High level shading languages
    • Cg, HLSL, OpenGL SL, Sh
  • Load, compile, and run shader programs from OpenGL or DirectX programs
opengl files
OpenGL Files
  • OpenGL files comes with MS Windows and/or Visual Studio installation
  • Header files
    • gl.h, glu.h
    • Glut.h (needs to be downloaded)
  • Static libraries
    • Opengl32.lib, glu32.lib
    • glut32.lib (needs to be downloaded)
  • DLLs
    • C:\windows\system32
    • Opengl32.dll, glu32.dll
    • glut32.dll (needs to be downloaded)
how to compile opengl glut programs
How to compile OpenGL/GLUT programs?
  • http://www.cs.uiowa.edu/~cwyman/classes/fall04-22C151/howto/winGLUT.html
sample opengl programs
Sample OpenGL programs
  • Examples from “OpenGL Programming Guide”
    • http://www.opengl.org/resources/code/samples/redbook/
  • OpenGL code samples: http://www.opengl.org/code/
    • Simple code samples: http://www.opengl.org/resources/code/samples/simple/
a simple opengl program 1
A Simple OpenGL Program (1)

#include <GL/glut.h>

void display(void)


/* clear all pixels */


/* draw white polygon (rectangle) with corners at

* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)


glColor3f (1.0, 1.0, 1.0);


glVertex3f (0.25, 0.25, 0.0);

glVertex3f (0.75, 0.25, 0.0);

glVertex3f (0.75, 0.75, 0.0);

glVertex3f (0.25, 0.75, 0.0);


a simple opengl program 2
A Simple OpenGL Program (2)

/* start processing buffered OpenGL routines */

glFlush ();


void init (void) {

/* select clearing color */

glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values */



glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);


a simple opengl program 3
A Simple OpenGL Program (3)

/* Declare initial window size, position, and display mode (single

buffer and RGBA). Open window with "hello" in its title bar. Call

initialization routines. Register callback function to display graphics.

Enter main loop and process events. */

int main(int argc, char** argv)


glutInit(&argc, argv);

glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);

glutInitWindowSize (250, 250);

glutInitWindowPosition (100, 100);

glutCreateWindow ("hello");

init ();



return 0; /* ANSI C requires main to return int. */


opengl functions overview 1
OpenGL Functions Overview (1)
  • Primitives: object creation
    • glBegin(), glEnd(); A glBegin()-glEnd() pair encloses an object definition. OpenGL functions called between glBegin() and glEnd() define the object
    • glVertex*(), glColor*(), glNormal*(), glMaterial*(), glCallList(), glCallLists(), glRect*(), gluSphere(), gluCylinder()
  • Attributes
    • glClearColor() and glClear() specify the color to be used when color buffers are cleared and to actually clear the buffer, respectively.
    • Attributes (all are modal) control how primitives are displayed: glPolygonMode(), glPointSize(), glLineStipple(), glLineWidth()
overview of opengl functions 2
Overview of OpenGL Functions (2)
  • Display lists
    • glNewList(), glEndList(), glGenLists(), glListBase()
    • Display lists are collections of graphics functions. You create them, name them, and "execute" them.
    • You define objects in between glNewList() and glEndList().
  • Modeling transformations
    • glScale*(), glTranslate*(), glRotate*()
    • Before invoking any matrix manipulating function, you normally call glLoadIdentity().
    • Remember that glRotate() rotates about the origin so in order to rotate an object you usually must make sure that it is positioned at the origin.
opengl functions overview 3
OpenGL Functions Overview (3)
  • Viewing
    • gluLookAt()
    • The viewing transformation must precede modelling transformations in the code: you must first position the camera, then the objects.
  • Projection
    • gluOrtho2D(), glOrtho(), gluPerspective(), glViewport()
    • Call glMatrixMode( GL_PROJECTION) before you change projection parameters with any of the three functions above, then call glMatrixMode( GL_MODELVIEW). When the projection has been applied (whether simple discarding of z or a perspective division) we obtain normalized device coordinates. Finally these are mapped to (a portion of) the screen window. This mapping is specified with
opengl functions overview 4
OpenGL Functions Overview (4)
  • States
    • glEnable(), glDisable()
    • Almost everyting in OpenGL is modal, i.e. settings remain in effect until changed (this is true, not only of state variables we set with glEnable(), but also of normals, material properties, and colours).
  • Realism; light and shading
    • glLight*(), glLightModel*(), glMaterial*(), glShadeModel()
    • You must enable (with glEnable()) both lighting and the light sources you want to use.
opengl functions overview 5
OpenGL Functions Overview (5)
  • Hierarchical Models
    • glPushAttrib(), glPopAttrib(), glPushMatrix(), glPopMatrix()
    • In order to build hierarchical models we need ways of storing and restoring attributes and matrices. Display lists often start by pushing and ends by popping.
  • 2D Texture & pixels
    • glTexImage2D(), glBindTexture(), glTexCoord2*(), glRasterPos*(), glBitmap(), glDrawPixels()
    • Texturing must be enabled explicitly.
glut functions overview 1
GLUT Functions Overview (1)
  • Input and other callback functions
    • OpenGL programs execute in event mode, i.e. loops forever while awaiting user input. We write callback functions to be invoked as a result of user interaction. GLUT automatically calls the functions if we have registered them.
    • glutDisplayFunc(), glutMouseFunc(), glutMotionFunc(), glutReshapeFunc(), glutKeyboardFunc(), glutIdleFunc(), glutPostRedisplay()
glut functions overview 2
GLUT Functions Overview (2)
  • Control Functions
    • Control functions are functions that interface with the windowing system. You (usually) call them from your main() function.
    • glutInit(), glutInitDisplayMode(), glutInitWindowSize(), glutCreateWindow(), glutMainLoop()
how to learn opengl
How to learn OpenGL?
  • Read OpenGL Programming Guide
  • Read sample programs!
    • There are tons of OpenGL programs online: http://www.opengl.org/code
  • Read tutorials
  • Write programs
how to learn opengl1
How to learn OpenGL?
  • Bookmark the OpenGL manual pages
    • http://www.opengl.org/sdk/docs/man/
    • You need this more than anything else
  • Bookmark the GLUT manual page
    • http://www.opengl.org/resources/libraries/glut/spec3/spec3.html
  • If you are really serious about learning OpenGL, read OpenGL specification
    • http://www.khronos.org/opengl/
other opengl resources
Other OpenGL Resources
  • OpenGL tutor
    • http://www.xmission.com/~nate/tutors.html
    • Tutorial programs that demonstrate basic OpenGL functionality by allowing the user to modify the parameters of a function and see the effect on the scene
  • OpenGL FAQ & Troubleshooting Guide
    • http://www.opengl.org/resources/faq/technical/
  • A good OpenGL tutorial
    • http://nehe.gamedev.net/
  • “Red Book”: Chapter 1 and 2
next lecture
Next lecture
  • 3D graphics pipeline