Version 5 (modified by osg, 6 years ago)

Added link to mail message about redirecting osg::notify

Tips And Tricks

Follows are a set of items that are useful to know for successfully using the OpenSceneGraph.

  • To control the verbosity of debugging messages of OpenSceneGraph=] applications set the OSG_NOTIFY_LEVEL evironmental variable: Unix, tcsh:
    setenv OSG_NOTIFY_LEVEL DEBUG
    
    Unix, bash:
    export OSG_NOTIFY_LEVEL=DEBUG
    
    Windows:
    set OSG_NOTIFY_LEVEL=DEBUG
    
  • To control the default level of database optimization use the OSG_OPTIMIZER environmental variable, and to switch off use OFF: Unix, tcsh:
    setenv OSG_OPTIMIZER "OFF"
    
    Unix, bash:
    export OSG_OPTIMIZER="OFF"
    

Windows:

set OSG_OPTIMIZER="OFF"

For Windows Users, see this mailing list message about how to redirect or otherwise display osg::notify messages:

http://article.gmane.org/gmane.comp.graphics.openscenegraph.user/1296


Save Project Settings with Vc7

If you are working with Vc7 and like to create a custom wizard for your OpenSceneGraph C++ Projects to keep the Compiler and Linker Settings, start the Custom Wizard choose without GUI and edit the default.js file. To configure the same settings as in the examples with the OSG fill in following lines:

  • Debug Compiler Settings (in the AddConfig function):
    CLTool.AdditionalIncludeDirectories='../../../include,../../../../OpenThreads/include,../../../../Producer/include,../../../../3rdParty/include';
    CLTool.PreprocessorDefinitions = '_CONSOLE;FL_DLL;WIN32;_DEBUG';
    CLTool.SuppressStartupBanner = true;
    CLTool.RuntimeLibrary = rtMultiThreadedDebugDLL;
    CLTool.UsePrecompiledHeader = pchGenerateAuto;
    CLTool.WarningLevel = 3;
    CLTool.Detect64BitPortabilityProblems = true;
    CLTool.DebugInformationFormat =4;
    CLTool.Optimization =0;
    CLTool.BufferSecurityCheck = true;
    CLTool.RuntimeTypeInfo= true;
    CLTool.PrecompiledHeaderFile = '.\\Debug/' + strProjectName + '.pch';
    CLTool.AssemblerListingLocation = '.\\Debug/';
    CLTool.ObjectFile = '.\\Debug/';
    CLTool.ProgramDataBaseFileName = '.\\Debug/';
    CLTool.CompileAs = 0; 
    
  • Debug Linker Settings (also in the AddConfig function):
    LinkTool.AdditionalDependencies = 'OpenThreadsWin32d.lib Producerd.lib osgd.lib osgDBd.lib osgProducerd.lib';
    LinkTool.IgnoreDefaultLibraryNames = 'libcmt';
    LinkTool.AdditionalLibraryDirectories='../../../lib,../../../../OpenThreads/lib/win32,../../../../Producer/lib,../../../../3rdParty/lib';
    LinkTool.OutputFile = '../../../bin/'+ strProjectName +'.exe';
    LinkTool.LinkIncremental =1;
    LinkTool.SuppressStartupBanner = true;
    LinkTool.GenerateDebugInformation = true;
    LinkTool.ProgramDataBaseFile = '$OutDir/' +strProjectName + '.pdb';
    LinkTool.SubSystem=1;
    LinkTool.TargetMachine=1;
    

Optimization

First you need to understand what to optimize. Read Jon Watte's article on the description of bottlenecks (http://www.mindcontrol.org/~hplus/graphics/ogl-perf.html).

Add to this Don Burns' explanations of DisplayLists and VBOs (http://osgcvs.no-ip.org/osgarchiver/archives/January2005/0684.html)


Debugging with valgrind

Valgrind is a very good memory checker and debugger. It does the job by emulating the CPU and all of the instructions your program makes. Valgrind doesn't require specialized instrumentation or other tricks, but rather just requires that you compile your program with debugging information. If you want to debug OpenSceneGraph itself, just compile it with debugging information and link it in. The best part is that valgrind is itself Open Source. There is, however, a drawback. Your application, when run with the debugger, will be very slow.

It is recommended that valgrind 3.0.1 or later be used with OSG applications. I have only used valgrind under the GNU/Linux operating system on the x86 platform with Nvidia graphics cards, using Nvidia's proprietary driver. Valgrind has been used successfully with GCC 3.4.2 under Fedora Core 3, and with GCC 4.0.1 under Fedora Core 4. Other modern versions of GNU/Linux should work equally well.

Valgrind exposes many unfixable problems in the Nvidia graphics driver when running OSG applications. Valgrind also allows these errors to be suppressed by describing them in a separate suppression file, reproduced below. I called this file opengl.supp. Here is the command line that I use to run OSG applications with valgrind (<progname> and <progargs> are your own program name and arguments):

 valgrind --gen-suppressions=all --leak-check=full --num-callers=40 --log-file=out --suppressions=opengl.supp --error-limit=no -v <progname> <progargs>

Here are the contents of opengl.supp:

{
   opengl addr4 (1)
   Memcheck:Addr4
   obj:/usr/lib/libGL*
}
{
   opengl param (2)
   Memcheck:Param
   ioctl(generic)
   fun:ioctl
   fun:_nv*gl
   obj:/usr/lib/libGL*
}
{
   opengl cond (3)
   Memcheck:Cond
   obj:/usr/lib/libGL*
}
{
   opengl param (4)
   Memcheck:Param
   ioctl(generic)
   fun:ioctl
   obj:/usr/lib/libGL*
}
{
   opengl cond (5)
   Memcheck:Cond
   fun:_nv*gl
   obj:/usr/lib/libGL*
}
{
   opengl cond (6)
   Memcheck:Cond
   fun:strcat
   obj:/usr/lib/libGL*
}
{
   opengl value4 (7)
   Memcheck:Value4
   obj:/usr/lib/libGL*
}
{
   opengl memleak (8)
   Memcheck:Leak
   fun:calloc
   obj:/usr/lib/libGL*
}
{
   opengl memleak (9)
   Memcheck:Leak
   fun:malloc
   obj:/usr/lib/libGL*
}

For Mac OS X Support/Tips And Tricks

http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/MacOSXTips