5162fcc108
with the StatsHandler. When the 's' key is pressed, the rendering window will be halted. I tried solving the problem by commenting a line in CMFC_OSG_MDIView::OnKeyDown() and it seems to work now. Another improvement here is to use a thread class derived from OpenThreads to replace the old _beginthread(). It helps a lot in keeping a high frame rate when you open more than one MDI child windows. And the application using OpenThreads in my opinion will be more compatible and portable."
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <osgViewer/Viewer>
|
|
#include <osgViewer/ViewerEventHandlers>
|
|
#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);
|
|
void Done(bool value) { mDone = value; }
|
|
bool Done(void) { return mDone; }
|
|
//static void Render(void* ptr);
|
|
|
|
osgViewer::Viewer* getViewer() { return mViewer; }
|
|
|
|
private:
|
|
bool mDone;
|
|
std::string m_ModelName;
|
|
HWND m_hWnd;
|
|
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;
|
|
};
|
|
|
|
class CRenderingThread : public OpenThreads::Thread
|
|
{
|
|
public:
|
|
CRenderingThread( cOSG* ptr );
|
|
virtual ~CRenderingThread();
|
|
|
|
virtual void run();
|
|
|
|
protected:
|
|
cOSG* _ptr;
|
|
bool _done;
|
|
};
|