Open Inventor FAQs - Other Tools/Operating System Features

How can I write my application so it will run on UNIX, Linux, and Windows?

First, Linux is essentially the same as UNIX, no problem there. However, there is no "silver bullet" for cross-platform app development in general. Open Inventor itself is mostly platform independent. There are a few methods unique to UNIX or unique to Windows, but they are flagged in the help files. The real problem is the user interface. Here are some of the many possible strategies.

Write command line apps only (these can be very portable but inherently have a very limited user interface).

Use dialog boxes only for the user interface -- then you can use the DialogMaster component of Open Inventor to create portable apps. These user interfaces are also limited, but can be effective for test, demo, and prototype apps.

Use a third party cross-platform user interface (UI) toolkit. This may require some work on integrating Open Inventor with the UI toolkit, especially on UNIX where the Open Inventor SoXt components are specifically Motif widgets. However some UI toolkits use Motif on UNIX and allow you to get the actual Motif widget handle for a UI object. On Windows, the Open Inventor SoWin components only use Win32 APIs, so they should work with almost any UI toolkit that allows you to get the native window handle (HWnd) for a UI object. See, for example, Qt (http://www.trolltech.com).

Write the user interface twice, once using Motif and once using Win32 and/or MFC. This is the traditional approach. It provides a "native look and feel" in both environments, but at the cost of significantly more programming.

Write the user interface using Win32 and/or MFC and use a porting environment to build and run on UNIX. The major ones are Wind/U (http://www.bristol.com) and MainWin (http://www.mainsoft.com). FEI does not directly support these but we have customers using them. It allows a single source, but requires additional licensing and a runtime environment.

Use Java. FEI provides MeshViz and Open Inventor as a Java class library. You can write the entire application in Java or you can write the user interface in Java and use JNI to call into a C++ application "core". We have customers doing both. This allows a single source, but there can be problems with Java portability, security, etc.

Can we use OpenGL functions in Open Inventor?

The answer is a very resounding yes! However, one cannot arbitrarily mix Open Inventor and OpenGL calls in one's program. Usually the OpenGL calls are placed in an SoCallback node or in a custom node. You must be careful to save and restore any OpenGL state, so that Open Inventor doesn't get confused about which state changes it needs to send to OpenGL. The code might look something like the fragment below.

[Win32] If I want to use GDI with Open Inventor (e.g., for drawing a rubberband line), what do I need to look out for?

It is not guaranteed that GDI calls can be made on an OpenGL window. It does work in almost all cases with the Microsoft generic OpenGL, but may not work with some 3D accelerators.
You can tell if GDI rendering is allowed by looking at the PIXELFORMATDESCRIPTOR structure, specifically if the bit PFD_SUPPORT_GDI is set in the dwFlags member. (The oglinfo program supplied by FEI displays info about GDI support.)

There is absolutely no way to do GDI drawing on the OpenGL "back buffer". You can only draw on the "front buffer" (aka the screen). (This is a "feature" of OpenGL.) So you need to make sure the scene has been rendered and wglSwapBuffers has been called before doing GDI drawing. Usually this is not too hard in an Inventor program.
The boxZoom example (...\src\Inventor\examples\IVF) shows one way of using GDI calls.

Starting with Windows Vista, mixing GDI and Windows Aero is not possible in the same window. Furthermore, GDI compatible contexts produce a black screen when the window is created and displayed when aero is enbled which is very bad. We strongly recommand to use SoExtSelection or SoScreenDrawer API for drawing such objects.

Can I make my Open Inventor program multi-threaded to run on more than one CPU?

Yes!

Open Inventor includes multiple thread support. Here are just a few of the ways you can use multiple threads in your Open Inventor application:

One thread for rendering, another thread for computation.

Multiple threads rendering different scene graphs.

Multiple threads rendering the same scene graph.

In a multithreaded program, every thread that uses Open Inventor classes must call SoDB::threadInit.

FEI Visualization Sciences Group is the leading provider of advanced 3D visualization and analysis software tools for developers, engineers and scientists in natural resources, medical and life sciences, and engineering.