This building process was implemented in Windows 10, Visual Studio 2010, CMake 3.5.2, OpenSceneGraph-3.0.1
Step 1. Preparation
Building the OSG requires CMake, due to the extensive use of CMake directives in the Makefiles. I used CMake-GUI to make easy setting up OSG option. You may download cmake from https://cmake.org
Next preparation, download the OSG source from OpenSceneGraph website. In this project, I used version OpenSceneGraph-3.0.1
Extract the OpenSceneGraph source into the correct folder for example
C:\osg\OpenSceneGraph-3.0.1
Create new folder osgBuild
C:\osg\osgBuild
Step 2. Configure and Generate OSG
Please open your CMake-GUI
put "Where is the source code" with path C:\osg\OpenSceneGraph-3.0.1 and next put "Where to build the binaries" with path C:\osg\osgBuild then click button Configure, cmake will ask you to select "Specify the generator for this project". Please select Visual Studio 10 2010 then click finish.
CMake will report with Configuring Done and click Generate. CMake will generate all configured file in your build folder C:\osg\osgBuild.
Step 3. Compile OSG with Visual Studio 2010
Please open your Visual Studio 2010 and open ALL_BUILD.vcxproj project from your build folder C:\osg\osgBuild and Build (or press F7).
Finally, let test the binaries
Step 4. Hello World OSG with Visual Studio 2010
Please create new project by clicking File --> New --> Project --> Win32 Console Application and just put in your project name as HelloWorld. Copy code as below into your main.cpp file
/**
Hello World to display capsule geometry
*/
#include "stdafx.h"
#include <iostream>
#include <osgViewer/Viewer>
#include <osg/ShapeDrawable>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> root (new osg::Group);
osg::ref_ptr<osg::Geode> myshapegeode (new osg::Geode);
osg::ref_ptr<osg::Capsule> myCapsule (new osg::Capsule(osg::Vec3f(),1,2));
osg::ref_ptr<osg::ShapeDrawable> capsuledrawable (new
osg::ShapeDrawable(myCapsule.get()));
myshapegeode->addDrawable(capsuledrawable.get());
root->addChild(myshapegeode.get());
viewer.setSceneData( root.get() );
return (viewer.run());
}
Before compiling, let set the environment variables by right click on project and select properties.
In C/C++ properties, at Additional Include Directories puts C:\osg\osgBuild\include as shown as picture below
In Linker --> General properties, at Additional Library Directories puts C:\osg\osgBuild\lib as shown as picture below
In Linker --> Input properties, at Additional Dipendencies puts OpenThreadsd.lib;osgd.lib;osgDBd.lib;osgGAd.lib;osgUtild.lib;osgViewerd.lib; as shown as picture below
then click OK and Build your code by pressing F7. Then copy OSG DLL file from C:\osg\osgBuild\bin into your project folder, in my case at C:\Users\addiestar.silaban\Documents\Visual Studio 2010\Projects\osgHello\Debug please refer to picture below
Finally run the code by pressing F5 and if you are successfully, you will get result like picture as below
Thank you
Other Topics:
How to build NGINX RTMP module, Setup Live Streaming with NGINX RTMP module, Publishing Stream with Open Broadcaster Software (OBS), Create Adaptive Streaming with NGINX RTMP, Implementing Filtergraph in Streaming with NGINX RTMP, How to Implement Running Text in Streaming with NGINX RTMP, How to build OpenSceneGraph with Code::Blocks, How to build OpenSceneGraph with Visual Studio 2010, Building Geometry Model, How to run OpenSceneGraph with Netbean IDE 8.2 C++, Rendering Basic Shapes, Using OSG Node to Load 3D Object Model, Rendering 3D Simulator with OpenSceneGraph, How to compile wxWidgets with Visual Studio 2010
No comments:
Post a Comment