Precondition
- OSG library has been built in x32 or x64
- OSG Example data has been downloaded.
- assuming OSGPATH is setting as D:\OSG
- include - D:\OSG\include
- lib - D:\OSG\lib
- bin - D:\OSG\bin
- data - D:\OSG\data
- System environment has been set corroctly
- PATH - add D:\OSG\bin to PATH
- OSG_FILE_PATH - create this key with value D:\OSG\data
- Qt Kit installed
- MSVC2015 32bit or 64bit should be same with OSG library build
Overview
Normally you can find many instructions to say “Hello World” in OSG style.
It should look like following steps:
- Create a empty Qt Console Application.
- Add OSG lib to project properties
- Add codes to show a 3D model
- Compile and run application.
Create Project
Create an empty Qt Console Application project.
Create new project
File -> New File or Project…
select -> Application -> Qt Console Application -> Choose…
Build system -> qmake -> Next
Kit Selection -> MSVC2015 64bit -> Finish
Configure Project Properties
right click project -> Add libraries…
Type -> select External library -> Next
Details select D:\OSG\lib\osg.lib -> Next
Summary -> Finish
Follow the same process to add
osgViewer.lib
osgDB.lib
OpenThreads.lib
Build -> Run qmake
Important
It’s a very important procedure never forget it, is to run qmake again after adding library, or it will not be imported to the project.
Notice
pay more attention to using same x64 or x32 Platform configuration!
Add Codes
Normally codes will be like this:
Alternatively, if we want to keep the same source code also can be built on Visual Studio, can add following code
Compile and Run
A 3D model should be displayed on the screen correctly.
Leave a Comment