Hi,

For those lost souls trying to build the OpenVRML plug-in on Windows,
here's how I did it with OSG 3.2.1. Hope this helps, as I was
desperately looking for such informations the passed days ;-)

First, the informations at [1] are completely outdated. By contrast to
what's stated there, OpenVRML 0.14.x is no more relevant at all, even
on Windows. OpenVRML 0.18.x is the way to go. So, to build the
OpenVRML plug-in, you need to build OpenVRML first. For this, the
Boost C++ Libraries are required. And OpenVRML's default build
configuration also has dependencies on libpng and FreeType.

I've successfully built OpenVRML 0.18.9 against Boost 1.55.0, libpng
1.6.13 and FreeType 2.5.0 on a Windows XP x64 PC using the Visual
Studio 2010 Professional IDE. I'm assuming here (i) that your OSG root
_build_ folder is C:\OpenSceneGraph and (ii) that you've correctly set
up and/or built Boost, libpng and FreeType. Here are the steps:
- Download OpenVRML 0.18.9 source code openvrml-0.18.9.tar.gz from
http://sourceforge.net/projects/openvrml/files/openvrml/0.18.9/;
- Extract openvrml-0.18.9.tar.gz somewhere; say in C:\openvrml-0.18.9 folder;
- Get the following missing project files from
https://svn.code.sf.net/p/openvrml/code/tags/0.18.9/ and copy them to:
  - src/local/libopenvrml-dl/openvrml-dl.vcxproj:
C:\openvrml-0.18.9/src/local/libopenvrml-dl/openvrml-dl.vcxproj;
  - src/node/x3d-interpolation/x3d-interpolation.vcxproj:
C:\openvrml-0.18.9/src/node/x3d-interpolation/x3d-interpolation.vcxproj;
  - src/script/javascript.vcxproj:
C:\openvrml-0.18.9/src/script/javascript.vcxproj;
- Remove any entry <PlatformToolset>Windows7.1SDK</PlatformToolset>
from the project files;
- Remove any entry <IncludePath
Condition="'$(Configuration)|$(Platform)'=='{Debug|Release}|x64'">C:\Boost\include\boost-1_43;$(IncludePath)</IncludePath>
from the project files;
- Fix the x64 platform settings of all projects files, copying from
the Win32 section. Most were incorrectly created as Applications
rather than DLLs!
- Go to C:\openvrml-0.18.9 and open OpenVRML.sln solution;
- Add $(BOOST_ROOT) to additional include directories of all projects;
- Add $(BOOST_ROOT)\lib{32|64}-msvc-10.0 to additional library
directories of all projects;
- Add /bigobj compiler option to Debug|x64 configuration of openvrml
DLL project to work around fatal error C1128;
- Ensure that input libraries of openvrml DLL project is set to
shlwapi.lib;XmlLite.lib;%(AdditionalDependencies) for all
targets/platforms;
- Ensure that input libraries of vrml97 DLL project is set to
libpng16[d].lib;freetype250[_D].lib;%(AdditionalDependencies) for all
targets/platforms and that additional library directories are properly
set;
- Build the vrml97 and x3d-* DLL projects. The openvrml DLL and
openvrml-dl static library projects are automatically built as
dependencies;
- Copy the headers from C:\openvrml-0.18.9\src\libopenvrml hierarchy
to C:\OpenSceneGraph\3rdParty\include\openvrml, replicating the
hierarchy, as well as the resulting openvrml.lib library files to
OpenSceneGraph\3rdParty\lib and openvrml.dll DLL files to
OpenSceneGraph\3rdParty\bin;
- Add OPENVRML_DIR environment variable, pointing to C:\OpenSceneGraph\3rdParty;
- Update OpenSceneGraph\OpenSceneGraph-3.2.1\src\osgPlugins\vrml\CMakeLists.txt
file to build against OpenVRML 0.18.x:
  - add references to Boost: add ln. 1-3:

    FIND_PACKAGE(Boost COMPONENTS thread)

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})

LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

  - remove references to antlr and regexp libraries: delete ln. 9-21
and ln. 23-24;
  - add OPENVRML_USE_DLL preprocessor definition: add ln. 31:

    ADD_DEFINITIONS(-DOPENVRML_USE_DLL)

Final result should be:

FIND_PACKAGE(Boost COMPONENTS thread)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

INCLUDE_DIRECTORIES(${OPENVRML_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OPENVRML_INCLUDE_DIR}/openvrml)

IF (WIN32)
    INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
    INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
    INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})

    SET(TARGET_LIBRARIES_VARS
        OPENVRML_LIBRARY
        JPEG_LIBRARY
        PNG_LIBRARY
        ZLIB_LIBRARY)
    SET(TARGET_EXTERNAL_LIBRARIES
        Ws2_32.lib)

    ADD_DEFINITIONS(-DOPENVRML_USE_DLL)
ELSE()
    SET(TARGET_LIBRARIES_VARS
        OPENVRML_LIBRARY)
ENDIF()

SET(TARGET_SRC
    IndexedFaceSet.cpp
    Primitives.cpp
    ReaderWriterVRML2.cpp
    ConvertToVRML.cpp
)

SET(TARGET_H
    ReaderWriterVRML2.h
    ConvertToVRML.h
)

#### end var setup  ###
SETUP_PLUGIN(vrml vrml)


Check you CMake configuration and build the OpenVRML plug-in:
- OPENVRML_INCLUDE_DIR: C:/OpenSceneGraph/3rdParty/openvrml;
- OPENVRML_LIBRARY: C:/OpenSceneGraph/3rdParty/lib/openvrml.lib;
I didn't use OpenVRML Debug library in the end (see Notice below) so
OPENVRML_LIBRARY_DEBUG was not set.

Now, for runtime, OpenVRML requires some environment variables and
data or the OpenVRML plug-in won't work at all:
- Copy the resulting openvrml.dll DLL from
C:\openvrml-0.18.9\{Win32|x64}\{Debug|Release}\bin to e.g.
%OSG_ROOT%\bin; I'm assuming here that %OSG_ROOT%\bin is in your PATH;
- Copy the resulting DLL nodes from
C:\openvrml-0.18.9\{Win32|x64}\{Debug|Release}\bin\node to e.g.
%OSG_ROOT%\share\OpenVRML\bin\node and add OPENVRML_NODE_PATH
environment variable to point to this folder;
- Copy the C:\openvrml-0.18.9\data folder to e.g.
%OSG_ROOT%\share\OpenVRML and add OPENVRML_DATADIR environment
variable to point to %OSG_ROOT%\share\OpenVRML\data.

Optionally, you can enable scripting, compiling the javascript DLL
project. To this end, you'll also need XULRunner SDK 12.0 available
only for Win32 target, not x64 one. So I quickly gave up on this one
as I moreover wasn't able to run OpenVRML examples with scripting
(e.g. rotationToy.wrl, Click.wrl) without crashing OpenVRML (using a
Win32 build of course). Nevertheless, don't forget to copy the
resulting javascript.dll from
C:\openvrml-0.18.9\{Win32|x64}\{Debug|Release}\bin\script to e.g.
%OSG_ROOT%\share\OpenVRML\bin\script and add OPENVRML_SCRIPT_PATH
environment variable to point to this folder if you want to play with
scripting.

In some debugging scenario (e.g. VRML file displayed differently in
sdl-viewer and osgviewer, like OpenVRML's snoman.wrl example where the
arms are missing in osgviewer), it might be helpful to also build
OpenVRML's SDL-based viewer sdl-viewer. For this, you'll need SDL
1.2.x. I've successfully built sdl-viewer with SDL 1.2.15.

Notice: DON'T MIX Debug and Release versions of sdl-viewer.exe,
openvrml.dll, javascript.dll and the DLL nodes in the same folders:
even if they're named differently (e.g. with "d" suffix for Debug
version), OpenVRML will badly crash as it seems to try to use/load
both flavours!

For interested people, I've created from scratch native VS 2010
solution/projects files using property sheets for the external
dependencies. Just drop me a mail and I'll send you. I'll also submit
them to the OpenVRML authors/maintainers.

Cheers,

     Émeric


[1] 
http://www.openscenegraph.com/index.php/documentation/platform-specifics/windows/38-visual-studio-plugins
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to