In my app I wrote this class function
void InitWindowsSystem (osgViewer::Viewer& viewer, const char* const title, int x, int y, int width, int height)
{
viewer.setUpViewInWindow(x, y, width, height);
//Get the traits of the current window
osg::ref_ptr< osg::GraphicsContext::Traits > traits = new osg::GraphicsContext::Traits( *viewer.getCamera()->getGraphicsContext()->getTraits());
//Set the title
traits->windowName = title;
// disable vertical sync
traits->vsync = false;
//Create a new graphics context with the modified traits
osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() );
//test to see if vsync has changed, but vsyn is alway true
osg::ref_ptr< osg::GraphicsContext::Traits > traits1 = new osg::GraphicsContext::Traits( *viewer.getCamera()->getGraphicsContext()->getTraits());
I have searched on forum for a way to do this but no one seem to have a clear way.
can someone tell me how to do this, pleases?
Julio
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
No, I do not think that controlling this at the driver level is the right way to do that.
I digged a litle and I think I found a better way, in case any anyone wants to know, here is how it can be done on initilaization
//Get the traits of the current window
osg::ref_ptr< osg::GraphicsContext::Traits > traits = new osg::GraphicsContext::Traits( *viewer.getCamera()->getGraphicsContext()->getTraits());
// disable vertical sync
traits->vsync = false;
//Create a new graphics context with the modified traits
osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() );
// set vertical blank off by default
osgViewer::Viewer::Windows windows;
gc->makeCurrent();
viewer.getWindows(windows);
for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) {
//(*itr)->setSyncToVBlank( !(*itr)->getSyncToVBlank() );
(*itr)->setSyncToVBlank( traits->vsync );
}
Oh there is one more thing you need to first, you need create a new context so that you can realize it, otherwise the function make current do not take place
here is the final code
viewer.setUpViewInWindow(x, y, width, height);
//Get the traits of the current window
osg::ref_ptr< osg::GraphicsContext::Traits > traits = new osg::GraphicsContext::Traits( *viewer.getCamera()->getGraphicsContext()->getTraits());
// disable vertical sync
traits->vsync = false;
//Create a new graphics context with the modified traits
osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() );
gc->realize();
gc->makeCurrent();
// set the vertical black off by default
osgViewer::Viewer::Windows windows;
viewer.getWindows(windows);
for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) {
//(*itr)->setSyncToVBlank( !(*itr)->getSyncToVBlank() );
(*itr)->setSyncToVBlank (false);
}
you would think that a simple function on the viewer would do that kind of thing without this kind of contorted code.
Julio