CSE328:Computer Graphics OpenGL Tutorial Dongli Zhang Department of Computer Science, SBU Department of Computer Science, Stony Brook University (SUNYSB)
TA Information Department of Computer Science, Stony Brook University (SUNYSB) TA Schedule: Time: Tuesday: 4:30~6:00pm; Location: Computer Science Building, 2110;
Introduction to OpenGL CSE328 What is OpenGL? Industrial standard library for doing computer graphics. Developed by Silicon Graphics Inc.(SGI) in Latest version: 4.3 (released at Aug 6, 2012). Features: Keep developing. More functions,GLSL,64-bit support. OpenGL is a Graphic rendering API (software interface to graphics hardware) consists of lots of commands. for example: GL_BEGIN(GLint TYPE) Operating system independent. References:
Introduction to OpenGL CSE328 If you want to be a Software Engineer in Computer graphics area, OpenGL is a MUST! Giant Companies: NVidia, ATI(AMD),Google, Adobe, Pixar, Blizzard, Siemens Medical…
Introduction to OpenGL CSE328 Other 3D Graphics APIs: Direct3D --- a competitor to OpenGL. Mesa 3D --- an open source implementation of OpenGL. Open Inventor --- C++ object oriented 3D graphics API in higher layer of programming. RISpec --- Pixar’s open API for photorealistic off-line rendering. Other 2D graphics APIs: GTK+. Java 2D, QT
OpenGL programming guide CSE328 Things you should know before coding: 1.OpenGL was designed be graphic output-only. Provide rendering functions only. Core API has no concept of windowing systems, audio, printing to screening, keyboard/mouse or other input devices. 2.OpenGL need add-on APIs to interact with the host system. GLX --- X11 WGL --- Microsoft Windows CGL --- Mac OS X 3.For convenient, people developed libraries to provide functionality for basic windowing using OpenGL, such as GLUT. OpenGL need a GUI in window system.
OpenGL programming guide Tools for programming: –C/C++ compiler and debugger: MS, gcc. –IDE: MS Visual studio, Dev-C++, Eclipse+cdt, Xcode, … –GUI: GLUT + GLUI, QT, MFC… Recommendation: VS GLUT + GLUI(QT) Reasons: free, easy for debug.
OpenGL language A state machine 1.You put OpenGL into various states that then remain in effect until you change them 2.State is encapsulated in contexts. Each OpenGL window has its own, separate, state. 3.Think of each context as a C/C++ struct with fields for each OpenGL state variable. Generally, there are two operations that you do with OpenGL: 1.Draw something 2.Change the state of how OpenGL draws OpenGL has two types of things that it can render: 1.Geometric primitives: points, lines and polygons 2.Image Primitives: bitmaps and graphics image Additionally, OpenGL links images and geometric primitives together using Texture Mapping.
OpenGL language
OpenGL geometric primitives
Rendering
Controlling current state
GLUT
What can GLUT do?
GLUT programming
Initialization
Open a window
Handle Events
Handle Event
Handle events
GLUT
Enter event processing loop
GLUT summary
GLUT Menu
Put together
GLUI
Examples
Helpful sources