Added extra methods WindowSystemInterface for controlling frame rate and resolution, and adde useCursor flag.

This commit is contained in:
Robert Osfield
2007-01-17 21:11:57 +00:00
parent 3ebc5efe05
commit 552293eb03
7 changed files with 36 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ suppress reflector "osg::CullStack"
ignore file "osgViewer/GraphicsWindowX11"
ignore file "osgViewer/GraphicsWindowWin32"
ignore file "osgViewer/GraphicsWindowCocoa"
ignore file "osgViewer/GraphicsWindowCarbon"
#############################################################################

View File

@@ -75,6 +75,7 @@ class OSG_EXPORT GraphicsContext : public Referenced
face(0),
mipMapGeneration(false),
vsync(true),
useCursor(true),
sharedContext(0) {}
// graphics context orginal and size
@@ -114,6 +115,9 @@ class OSG_EXPORT GraphicsContext : public Referenced
// V-sync
bool vsync;
// enable cursor
bool useCursor;
// shared context
GraphicsContext* sharedContext;
};
@@ -125,7 +129,11 @@ class OSG_EXPORT GraphicsContext : public Referenced
virtual unsigned int getNumScreens(const ScreenIdentifier& screenIdentifier = ScreenIdentifier()) = 0;
virtual void getScreenResolution(const ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height) = 0;
virtual bool setScreenResolution(const ScreenIdentifier& /*screenIdentifier*/, unsigned int /*width*/, unsigned int /*height*/) { return false; }
virtual bool setScreenRefreshRate(const ScreenIdentifier& /*screenIdentifier*/, double /*refreshRate*/) { return false; }
virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0;
virtual ~WindowingSystemInterface() {};

View File

@@ -573,6 +573,8 @@ void CompositeViewer::setUpRenderingSupport()
sceneView->setSceneData(view->getSceneData());
sceneView->setFrameStamp(frameStamp);
if (dp) dp->setCompileGLObjectsForContextID(view->getCamera()->getGraphicsContext()->getState()->getContextID(), true);
view->getCamera()->getGraphicsContext()->add(new CompositeViewerRenderingOperation(sceneView, dp));
}
@@ -592,6 +594,8 @@ void CompositeViewer::setUpRenderingSupport()
sceneView->setSceneData(view->getSceneData());
sceneView->setFrameStamp(frameStamp);
if (dp) dp->setCompileGLObjectsForContextID(slave._camera->getGraphicsContext()->getState()->getContextID(), true);
slave._camera->getGraphicsContext()->add(new CompositeViewerRenderingOperation(sceneView, dp));
}
}

View File

@@ -358,6 +358,9 @@ void GraphicsWindowX11::useCursor(bool cursorOn)
XFlush(_display);
XSync(_display,0);
}
_traits->useCursor = cursorOn;
}
void GraphicsWindowX11::init()
@@ -488,7 +491,7 @@ void GraphicsWindowX11::init()
_nullCursor = XCreatePixmapCursor( _display, pixmap, pixmap, &ncol, &ncol, 0, 0 );
}
useCursor(true);
useCursor(_traits->useCursor);
XSelectInput( _display, _window, ExposureMask | StructureNotifyMask |
KeyPressMask | KeyReleaseMask |

View File

@@ -29,12 +29,15 @@ SimpleViewer::SimpleViewer():
_eventVisitor = new osgGA::EventVisitor;
setDatabasePager(new osgDB::DatabasePager);
_databasePager->setCompileGLObjectsForContextID(_sceneView->getState()->getContextID(), true);
}
SimpleViewer::~SimpleViewer()
{
_sceneView->releaseAllGLObjects();
osg::GraphicsContext::decrementContextIDUsageCount(_sceneView->getState()->getContextID());
_databasePager->setCompileGLObjectsForContextID(_sceneView->getState()->getContextID(), false);
}
void SimpleViewer::setSceneData(osg::Node* node)
@@ -53,6 +56,7 @@ void SimpleViewer::setSceneData(osg::Node* node)
{
// register any PagedLOD that need to be tracked in the scene graph
_databasePager->registerPagedLODs(node);
}
}

View File

@@ -463,12 +463,12 @@ struct ViewerRenderingOperation : public osg::GraphicsOperation
_sceneView->cull();
_sceneView->draw();
double availableTime = 0.004; // 4 ms
if (_databasePager.valid())
{
double availableTime = 0.004; // 4 ms
_databasePager->compileGLObjects(*(_sceneView->getState()), availableTime);
_sceneView->flushDeletedGLObjects(availableTime);
}
_sceneView->flushDeletedGLObjects(availableTime);
}
osg::observer_ptr<osgUtil::SceneView> _sceneView;
@@ -508,6 +508,8 @@ void Viewer::setUpRenderingSupport()
sceneView->setState(_camera->getGraphicsContext()->getState());
sceneView->setSceneData(getSceneData());
sceneView->setFrameStamp(frameStamp);
if (dp) dp->setCompileGLObjectsForContextID(_camera->getGraphicsContext()->getState()->getContextID(), true);
_camera->getGraphicsContext()->add(new ViewerRenderingOperation(sceneView, dp));
}
@@ -528,6 +530,8 @@ void Viewer::setUpRenderingSupport()
sceneView->setSceneData(getSceneData());
sceneView->setFrameStamp(frameStamp);
if (dp) dp->setCompileGLObjectsForContextID(slave._camera->getGraphicsContext()->getState()->getContextID(), true);
slave._camera->getGraphicsContext()->add(new ViewerRenderingOperation(sceneView, dp));
}
}

View File

@@ -309,6 +309,7 @@ BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext::Traits)
I_PublicMemberProperty(unsigned int, face);
I_PublicMemberProperty(unsigned int, mipMapGeneration);
I_PublicMemberProperty(bool, vsync);
I_PublicMemberProperty(bool, useCursor);
I_PublicMemberProperty(osg::GraphicsContext *, sharedContext);
END_REFLECTOR
@@ -325,6 +326,14 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsContext::WindowingSystemInterface)
__void__getScreenResolution__C5_ScreenIdentifier_R1__unsigned_int_R1__unsigned_int_R1,
"",
"");
I_Method3(bool, setScreenResolution, IN, const osg::GraphicsContext::ScreenIdentifier &, x, IN, unsigned, int, IN, unsigned, int,
__bool__setScreenResolution__C5_ScreenIdentifier_R1__unsigned__unsigned,
"",
"");
I_Method2(bool, setScreenRefreshRate, IN, const osg::GraphicsContext::ScreenIdentifier &, x, IN, double, x,
__bool__setScreenRefreshRate__C5_ScreenIdentifier_R1__double,
"",
"");
I_Method1(osg::GraphicsContext *, createGraphicsContext, IN, osg::GraphicsContext::Traits *, traits,
__GraphicsContext_P1__createGraphicsContext__Traits_P1,
"",