Below is the changes made to the included files. The examples CMakeList.txt file was not included but the code change needed for osgviewerMFC inclusion is listed below.
CMakeList.txt:
This is a little different than other example cmakelist.txt files in that I could not use the setup_example macro. I had to go in and extract out the important parts of the macro and inline them in the CMakeList.txt file so that I could add the WIN32 declaration into the ADD_EXECUTABLE() statement. In the future the setup_example macro might be modified to support osgviewerMFC but this is special case so you might not want to muddy the water for one example.
MFC_OSG.h:
This file had some small changes:
From: #include <osgViewer/GraphicsWindowWin32>
To: #include <osgViewer/api/win32/GraphicsWindowWin32>
Also added two new function declarations
Void PreFrameUpdate(void);
Void PostFrameUpdate(void);
MFC_OSG.cpp:
This file changed only in that I am explicitly showing the viewer run loop and added the two new functions in the MFC_OSG.h file.
"
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <osgViewer/Viewer>
|
|
#include <osgViewer/StatsHandler>
|
|
#include <osgViewer/api/win32/GraphicsWindowWin32>
|
|
#include <osgGA/TrackballManipulator>
|
|
#include <osgGA/KeySwitchMatrixManipulator>
|
|
#include <osgDB/DatabasePager>
|
|
#include <osgDB/Registry>
|
|
#include <osgDB/ReadFile>
|
|
#include <osgUtil/Optimizer>
|
|
#include <string>
|
|
|
|
class cOSG
|
|
{
|
|
public:
|
|
cOSG(HWND hWnd);
|
|
~cOSG(){};
|
|
|
|
void InitOSG(std::string filename);
|
|
void InitManipulators(void);
|
|
void InitSceneGraph(void);
|
|
void InitCameraConfig(void);
|
|
void SetupWindow(void);
|
|
void SetupCamera(void);
|
|
void PreFrameUpdate(void);
|
|
void PostFrameUpdate(void);
|
|
static void Render(void* ptr);
|
|
|
|
osgViewer::Viewer* getViewer() { return mViewer.get(); }
|
|
|
|
private:
|
|
std::string m_ModelName;
|
|
HWND m_hWnd;
|
|
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
|
osg::ref_ptr<osg::Group> mRoot;
|
|
osg::ref_ptr<osg::Node> mModel;
|
|
osg::ref_ptr<osgGA::TrackballManipulator> trackball;
|
|
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator;
|
|
};
|