+ All Categories
Home > Documents > CSE328:Computer Graphics OpenGL Tutorial

CSE328:Computer Graphics OpenGL Tutorial

Date post: 05-Feb-2016
Category:
Upload: neona
View: 94 times
Download: 1 times
Share this document with a friend
Description:
CSE328:Computer Graphics OpenGL Tutorial. Dongli Zhang Department of Computer Science, SBU [email protected]. Department of Computer Science, Stony Brook University (SUNYSB). TA Information. Department of Computer Science, Stony Brook University (SUNYSB). TA Schedule: - PowerPoint PPT Presentation
Popular Tags:
53
CSE328:Computer Graphics OpenGL Tutorial Dongli Zhang Department of Computer Science, SBU [email protected] Department of Computer Science, Stony Brook University (SUNYSB)
Transcript
Page 1: CSE328:Computer Graphics OpenGL Tutorial

CSE328:Computer Graphics

OpenGL Tutorial

Dongli Zhang

Department of Computer Science, SBU

[email protected]

Department of Computer Science, Stony Brook University (SUNYSB)

Page 2: CSE328:Computer Graphics OpenGL Tutorial

TA Information

Department of Computer Science, Stony Brook University (SUNYSB)

TA Schedule:•Time: Tuesday: 4:30~6:00pm;•Location: Computer Science Building, 2110;•Email: [email protected]

Page 3: CSE328:Computer Graphics OpenGL Tutorial

Introduction to OpenGL

CSE328

What is OpenGL?• Industrial standard library for doing computer graphics.• Developed by Silicon Graphics Inc.(SGI) in 1992.• 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:•http://en.wikipedia.org/wiki/Opengl•http://www.opengl.org/

Page 4: CSE328:Computer Graphics OpenGL Tutorial

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…

Page 5: CSE328:Computer Graphics OpenGL Tutorial

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

Page 6: CSE328:Computer Graphics OpenGL Tutorial

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 X3.For convenient, people developed libraries to provide

functionality for basic windowing using OpenGL, such as GLUT.

OpenGL need a GUI in window system.OpenGL need a GUI in window system.

Page 7: CSE328:Computer Graphics OpenGL Tutorial

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:• VS2010 + GLUT + GLUI(QT)• Reasons: free, easy for debug.

Page 8: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

• A state machine1. 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.

Page 9: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

Page 10: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

Page 11: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

Page 12: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

Page 13: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

Page 14: CSE328:Computer Graphics OpenGL Tutorial

OpenGL language

Page 15: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 16: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 17: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 18: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 19: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 20: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 21: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 22: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 23: CSE328:Computer Graphics OpenGL Tutorial

OpenGL geometric primitives

Page 24: CSE328:Computer Graphics OpenGL Tutorial

Rendering

Page 25: CSE328:Computer Graphics OpenGL Tutorial

Rendering

Page 26: CSE328:Computer Graphics OpenGL Tutorial

Controlling current state

Page 27: CSE328:Computer Graphics OpenGL Tutorial

GLUT

Page 28: CSE328:Computer Graphics OpenGL Tutorial

GLUT

What can GLUT do?What can GLUT do?

Page 29: CSE328:Computer Graphics OpenGL Tutorial

GLUT programming

Page 30: CSE328:Computer Graphics OpenGL Tutorial

Initialization

Page 31: CSE328:Computer Graphics OpenGL Tutorial

Initialization

Page 32: CSE328:Computer Graphics OpenGL Tutorial

Open a window

Page 33: CSE328:Computer Graphics OpenGL Tutorial

Open a window

Page 34: CSE328:Computer Graphics OpenGL Tutorial

Handle Events

Page 35: CSE328:Computer Graphics OpenGL Tutorial

Handle Event

Page 36: CSE328:Computer Graphics OpenGL Tutorial

Handle events

Page 37: CSE328:Computer Graphics OpenGL Tutorial

GLUT

Page 38: CSE328:Computer Graphics OpenGL Tutorial

GLUT

Page 39: CSE328:Computer Graphics OpenGL Tutorial

GLUT

Page 40: CSE328:Computer Graphics OpenGL Tutorial

GLUT

Page 41: CSE328:Computer Graphics OpenGL Tutorial

GLUT

Page 42: CSE328:Computer Graphics OpenGL Tutorial
Page 43: CSE328:Computer Graphics OpenGL Tutorial

Enter event processing loop

Page 44: CSE328:Computer Graphics OpenGL Tutorial

GLUT summary

Page 45: CSE328:Computer Graphics OpenGL Tutorial

GLUT Menu

Page 46: CSE328:Computer Graphics OpenGL Tutorial

GLUT Menu

Page 47: CSE328:Computer Graphics OpenGL Tutorial

Put together

Page 48: CSE328:Computer Graphics OpenGL Tutorial
Page 49: CSE328:Computer Graphics OpenGL Tutorial
Page 50: CSE328:Computer Graphics OpenGL Tutorial

GLUI

Page 51: CSE328:Computer Graphics OpenGL Tutorial

GLUI

Page 52: CSE328:Computer Graphics OpenGL Tutorial

Examples

Page 53: CSE328:Computer Graphics OpenGL Tutorial

Helpful sources


Recommended