From Stephan Huber, "attached you'll find a small enhancement for GraphicsWindowCocoa to

implement the recently introduced setSyncToVBlank-method.

Additionally I added a ToggleSyncToVBlank-eventhandler to osgViewer. I
used it to test the code, perhaps you'll find it useful and include it
in the distribution."
This commit is contained in:
Robert Osfield
2011-05-04 16:01:21 +00:00
parent f0baf6abba
commit da1a354502
4 changed files with 88 additions and 4 deletions

View File

@@ -379,6 +379,29 @@ class OSGVIEWER_EXPORT LODScaleHandler : public osgGA::GUIEventHandler
int _keyEventDecreaseLODScale;
};
/** Event handler for toggling SyncToVBlank.*/
class OSGVIEWER_EXPORT ToggleSyncToVBlankHandler : public osgGA::GUIEventHandler
{
public:
ToggleSyncToVBlankHandler();
void setKeyEventToggleSyncToVBlankHandler(int key) { _keyEventToggleSyncToVBlank = key; }
int getKeyEventToggleSyncToVBlankHandler() const { return _keyEventToggleSyncToVBlank; }
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
/** Get the keyboard and mouse usage of this manipulator.*/
virtual void getUsage(osg::ApplicationUsage& usage) const;
protected:
int _keyEventToggleSyncToVBlank;
};

View File

@@ -163,7 +163,7 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
GraphicsWindowCocoaWindow* getWindow() { return _window; }
NSOpenGLPixelFormat* getPixelFormat() { return _pixelformat; }
void setVSync(bool f);
virtual void setSyncToVBlank(bool f);
/** adapts a resize / move of the window, coords in global screen space */
void adaptResize(int x, int y, int w, int h);