Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Inventor with OpenGL 2001.08.21. Chapter objectives Create Inventor callback nodes that include calls to the OpenGL Library Explain how Inventor.

Similar presentations


Presentation on theme: "Using Inventor with OpenGL 2001.08.21. Chapter objectives Create Inventor callback nodes that include calls to the OpenGL Library Explain how Inventor."— Presentation transcript:

1 Using Inventor with OpenGL 2001.08.21

2 Chapter objectives Create Inventor callback nodes that include calls to the OpenGL Library Explain how Inventor uses and affects OpenGL state variables Write a program that combines use of Inventor and OpenGL and uses the SoGLRenderAction Use color index mode

3 Introduction This chapter –Describes how to combine calls to the inventor and OpenGL libraries in the same window Combine Inventor with OpenGL in several ways –Using SoCallback –Applying a Render Action Inside a GLX Window

4 OpenGL state variables and Inventor Combine inventor and OpenGL –If Inventor uses the current value of an OpenGL state value and never change it To save and restore OpenGL state –Use the OpenGL pushAttribute() and popAttributes() commands

5 OpenGL state variables and Inventor

6

7

8 Color-Index Mode Open an X window –Supports OpenGL rendering in either RGB mode or color-index mode –use color-index mode Be sure to load the color map Example –If you are using BASE_COLOR lighting.use the SoColorIndex node to specify the index into the color map

9 Using an SoCallback Node A typical use of an SoCallback node is to make calls to OpenGL If(action->isOfType(SoGLRenderAction::getClassTypeId()){ … execute rendering code …

10 Caching Caching saves the result of an operation so that it doesn ’ t need to be repeated Void maycallback(void *myData, SoAction *action) { If(action->isOfType(SoGLRenderAction:getClassTypeId())){ SoCacheElement::invalidate(action->getState()); // make sure this isn ’ t cached // … make OpenGL calls that depend on a global variable … // } // SoCacheElement::invalidate()  to prevent Inventor from automatically creating a cache

11 Using a Callback Node Inventor : red cube and a blue sphere GL calls to draw a checked “ floor ” //draw the lines that make up // callback routine to render floor the floor,using OpenGL using OpenGL void drawFloor() void myCallbackRoutine(..) { {... … drawFloor(); }...} main( … ) {... SoCallback *mycallback = new SoCallback; myCallback->setCallback(myCallbackRoutine);

12 Applying a Render Action Inside a GLX Window Example –Creates a GLX window,makes Inventor and OpenGL calls, and then applies a GL render action // draw the lines that make up the floor,using OpenGL void drawFloor() main( … ) { { … … drawFloor(); } … }


Download ppt "Using Inventor with OpenGL 2001.08.21. Chapter objectives Create Inventor callback nodes that include calls to the OpenGL Library Explain how Inventor."

Similar presentations


Ads by Google