From Ulrich Hertlien with little bits from Robert Osfield and Chris Hanson, added provisionl support for controlling sync to vblank.
This commit is contained in:
@@ -134,6 +134,14 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
|
||||
/** Create a new mouse cursor from the usual bitmap data.*/
|
||||
//virtual MouseCursor createCursor(const char *data, const char *mask, unsigned w, unsigned h, unsigned hotx, unsigned hoty) { osg::notify(osg::NOTICE)<<"GraphicsWindow::createCursor(..) not implemented."<<std::endl; }
|
||||
|
||||
/** Set sync-to-vblank. */
|
||||
virtual void setSyncToVBlank(bool on)
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "GraphicsWindow::setSyncToVBlank(" << on << ") not implemented." << std::endl;
|
||||
}
|
||||
|
||||
bool getSyncToVBlank() const { return _traits.valid() ? _traits->vsync : true; }
|
||||
|
||||
public:
|
||||
|
||||
/** Return whether a valid and usable GraphicsContext has been created.*/
|
||||
|
||||
@@ -68,7 +68,9 @@ class OSGVIEWER_EXPORT HelpHandler : public osgGA::GUIEventHandler
|
||||
|
||||
};
|
||||
|
||||
/** Event handler for adding on screen stats reporting to Viewers.*/
|
||||
/**
|
||||
* Event handler for adding on screen stats reporting to Viewers.
|
||||
*/
|
||||
class OSGVIEWER_EXPORT StatsHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
@@ -91,6 +93,9 @@ class OSGVIEWER_EXPORT StatsHandler : public osgGA::GUIEventHandler
|
||||
void setKeyEventPrintsOutStats(int key) { _keyEventPrintsOutStats = key; }
|
||||
int getKeyEventPrintsOutStats() const { return _keyEventPrintsOutStats; }
|
||||
|
||||
void setKeyEventToggleVSync(int key) { _keyEventToggleVSync = key; }
|
||||
int getKeyEventToggleVSync() const { return _keyEventToggleVSync; }
|
||||
|
||||
double getBlockMultiplier() const { return _blockMultiplier; }
|
||||
|
||||
void reset();
|
||||
@@ -123,6 +128,7 @@ class OSGVIEWER_EXPORT StatsHandler : public osgGA::GUIEventHandler
|
||||
|
||||
int _keyEventTogglesOnScreenStats;
|
||||
int _keyEventPrintsOutStats;
|
||||
int _keyEventToggleVSync;
|
||||
|
||||
int _statsType;
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow, public osgViewer:
|
||||
_initialized(false),
|
||||
_realized(false),
|
||||
_ownsWindow(true),
|
||||
_currentCursor(RightArrowCursor)
|
||||
_currentCursor(RightArrowCursor),
|
||||
_currentVSync(true)
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
@@ -108,7 +109,10 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow, public osgViewer:
|
||||
virtual void setWindowName (const std::string & name);
|
||||
virtual void useCursor(bool cursorOn);
|
||||
virtual void setCursor(MouseCursor mouseCursor);
|
||||
|
||||
|
||||
/** Set sync-to-vblank. */
|
||||
virtual void setSyncToVBlank(bool on);
|
||||
|
||||
WindowRef getNativeWindowRef() { return _window; }
|
||||
|
||||
bool handleMouseEvent(EventRef theEvent);
|
||||
@@ -168,6 +172,7 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow, public osgViewer:
|
||||
bool _closeRequested;
|
||||
UInt32 _lastModifierKeys;
|
||||
MouseCursor _currentCursor;
|
||||
bool _currentVSync;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,10 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
|
||||
|
||||
/** Set mouse cursor to a specific shape.*/
|
||||
virtual void setCursor(MouseCursor cursor);
|
||||
|
||||
|
||||
/** Set sync-to-vblank. */
|
||||
virtual void setSyncToVBlank(bool on);
|
||||
|
||||
/** Handle a native (Win32) windowing event as received from the system */
|
||||
virtual LRESULT handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user