24
Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU GLUT and GLVU Andy Wilson Andy Wilson September 22, 1999 September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Embed Size (px)

Citation preview

Page 1: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 1

GLUT and GLVUGLUT and GLVU

Andy WilsonAndy Wilson

September 22, 1999September 22, 1999

Page 2: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 2

OutlineOutline

• IntroductionIntroduction

• GLUTGLUT

• GLVUGLVU

• Where to learn moreWhere to learn more

• Questions and AnswersQuestions and Answers

Page 3: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 3

Introduction: MotivationIntroduction: Motivation

• So you want to use OpenGL?So you want to use OpenGL?

–Low-level commandsLow-level commands

» Manage rendering stateManage rendering state

» Render primitivesRender primitives

• The windowing system is in your wayThe windowing system is in your way

• No “world management” availableNo “world management” available

Page 4: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 4

Introduction: GLUTIntroduction: GLUT

• GLUT: simple interface to window systemGLUT: simple interface to window system

–User functions handle window eventsUser functions handle window events

» mouse, keyboard, resize, expose…mouse, keyboard, resize, expose…

–Simple pop-up menusSimple pop-up menus

–A few simple shapes (sphere, cone, teapot)A few simple shapes (sphere, cone, teapot)

• No concept of world or camera managementNo concept of world or camera management

–You reinvent the wheel a lot.You reinvent the wheel a lot.

Page 5: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 5

Introduction: GLVUIntroduction: GLVU

• GLVU: object and camera managementGLVU: object and camera management

–Several different model formatsSeveral different model formats

–Renderable objectsRenderable objects

–Easily extensibleEasily extensible

» Several modules available or under development - Several modules available or under development - IBR, tracking, large models, LOD...IBR, tracking, large models, LOD...

Page 6: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 6

OutlineOutline

• IntroductionIntroduction

• GLUTGLUT

• GLVUGLVU

• Where to learn moreWhere to learn more

• Questions and AnswersQuestions and Answers

Page 7: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 7

GLUT: System OverviewGLUT: System Overview

User Callbacks(Display, Idle, Keyboard, Mouse, Resize, …)

GLUT

Window System

Events(Mouse, Keyboard,

Window Expose/Hide/Resize/Destroy)

Page 8: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 8

GLUT: Program StructureGLUT: Program Structure

• Initialization and window/menu setupInitialization and window/menu setup

• Interface callbacksInterface callbacks

–Handle mouse, keyboard inputHandle mouse, keyboard input

• Display functionDisplay function

–Draw world (including camera management)Draw world (including camera management)

• Idle functionIdle function

–Runs when no events pendingRuns when no events pending

Page 9: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 9

GLUT: Interface CallbacksGLUT: Interface Callbacks

• KeyboardKeyboard

–Key press, key release, window location Key press, key release, window location

• MouseMouse

–Enter/leave window, button down/up, dragEnter/leave window, button down/up, drag

• MenuMenu

–Item selectItem select

Page 10: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 10

GLUT: Display CallbackGLUT: Display Callback

• Responsible for entire display processResponsible for entire display process

–Clear buffersClear buffers

–Set up camera, GL matrix stacksSet up camera, GL matrix stacks

–Draw objects (including multipass rendering)Draw objects (including multipass rendering)

–Swap front/back bufferSwap front/back buffer

• Good place to put per-frame world updatesGood place to put per-frame world updates

–physics, collision, trackersphysics, collision, trackers

Page 11: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 11

GLUT: Idle CallbackGLUT: Idle Callback

• Invoked when events not being received from Invoked when events not being received from window systemwindow system

• Typical uses: Typical uses:

–request redraw (continuous update)request redraw (continuous update)

–update simulation clockupdate simulation clock

• No guarantee on when it’ll be called!No guarantee on when it’ll be called!

Page 12: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 12

What GLUT Doesn’t DoWhat GLUT Doesn’t Do

• World and model managementWorld and model management

–Load and place and render models yourselfLoad and place and render models yourself

• Camera managementCamera management

–Manage GL projection stack yourselfManage GL projection stack yourself

• Motion controlMotion control

–Arcball? Drive? Strafe? Look around?Arcball? Drive? Strafe? Look around?

• Multipipe Multipipe anythinganything

Page 13: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 13

OutlineOutline

• IntroductionIntroduction

• GLUTGLUT

• GLVUGLVU

• Where to learn moreWhere to learn more

• Questions and AnswersQuestions and Answers

Page 14: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 14

GLVU: OverviewGLVU: Overview

• Object managementObject management

–Several polygonal file formats supportedSeveral polygonal file formats supported

–Objects can render themselvesObjects can render themselves

• Camera and simple navigationCamera and simple navigation

–Walk, translate, examine, look aroundWalk, translate, examine, look around

• Easily extensibleEasily extensible

• Sits on top of GLUTSits on top of GLUT

Page 15: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 15

GLVU: System DiagramGLVU: System Diagram

GLUT

GLVU Input Handlers User Idle Func

User Display Func

User Input Handlers GLVU Model Formats

Page 16: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 16

GLVU: System ArchitectureGLVU: System Architecture

• Everything is object-oriented C++Everything is object-oriented C++

• Components all inherit from base classes Components all inherit from base classes

–Camera, ObjectCamera, Object

• Default GLUT keyboard and mouse handlers Default GLUT keyboard and mouse handlers providedprovided

–User typically extends rather than replacesUser typically extends rather than replaces

• GLVU divided into Core and Modules GLVU divided into Core and Modules

Page 17: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 17

GLVU: Writing a ProgramGLVU: Writing a Program

• Just like writing a GLUT program, except…Just like writing a GLUT program, except…

–Load models by instantiating objectsLoad models by instantiating objects

–Call Display() methods instead of rendering by Call Display() methods instead of rendering by handhand

–Motion handlers already providedMotion handlers already provided

Page 18: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 18

GLVU CoreGLVU Core

• Perspective CameraPerspective Camera

• VRML, BFF, OBJ, TRI, WFF model formatsVRML, BFF, OBJ, TRI, WFF model formats

• Bounding boxesBounding boxes

• PPM images (for texture maps)PPM images (for texture maps)

• Vector, Matrix math libraryVector, Matrix math library

• Walk, Examine, Look, Translate movement modesWalk, Examine, Look, Translate movement modes

Page 19: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 19

GLVU ModulesGLVU Modules

• IBR far-field representationsIBR far-field representations

–Textured depth mesh, environment-mapped cubes, Textured depth mesh, environment-mapped cubes, layered depth images, …layered depth images, …

• Light Cameras (place lights by moving viewpoint)Light Cameras (place lights by moving viewpoint)

• Large Model utilities (cells, memory management)Large Model utilities (cells, memory management)

• See Bill Baxter (baxter@cs) for latest list and ownersSee Bill Baxter (baxter@cs) for latest list and owners

Page 20: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 20

Extending GLVUExtending GLVU

• New model formatsNew model formats

–Just write a loader and a display methodJust write a loader and a display method

• Image-based rendering Image-based rendering

–Most work goes into display methodMost work goes into display method

–Almost anything can be cast as an ObjectAlmost anything can be cast as an Object

• Can always override default GLVU input handlersCan always override default GLVU input handlers

–Trackers, button boxes, joysticks...Trackers, button boxes, joysticks...

Page 21: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 21

User Interface ToolkitsUser Interface Toolkits

• Many available; choose your favoriteMany available; choose your favorite

• TCL/TkTCL/Tk

–http://dev.scriptics.comhttp://dev.scriptics.com

• GLUIGLUI

–http://www.cs.unc.edu/~rademach/gluihttp://www.cs.unc.edu/~rademach/glui

• FLTKFLTK

–http://www.fltk.orghttp://www.fltk.org

Page 22: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 22

OutlineOutline

• IntroductionIntroduction

• GLUTGLUT

• GLVUGLVU

• Where to learn moreWhere to learn more

• Questions and AnswersQuestions and Answers

Page 23: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 23

Where to Learn MoreWhere to Learn More

• Read the example code!Read the example code!

• GLUTGLUT

–http://reality.sgi.com/mjk_asd/glut3/glut3.htmlhttp://reality.sgi.com/mjk_asd/glut3/glut3.html

• GLVUGLVU

–Bill Baxter (baxter@cs) can tell you how to get Bill Baxter (baxter@cs) can tell you how to get the sourcethe source

Page 24: Andy Wilson - GLUT and GLVU - 9/99 - Slide 1 GLUT and GLVU Andy Wilson September 22, 1999

Andy Wilson - GLUT and GLVU - 9/99 - Slide 24

OutlineOutline

• IntroductionIntroduction

• GLUTGLUT

• GLVUGLVU

• Where to learn moreWhere to learn more

• Questions and AnswersQuestions and Answers