Introduce GraphicsOperation subclass from osg::Operation, and osgUtil::GLObjectOperation
for compiling subgraphs.
This commit is contained in:
@@ -41,35 +41,16 @@ void GraphicsThread::run()
|
||||
|
||||
}
|
||||
|
||||
struct BlockOperation : public Operation, public Block
|
||||
void GraphicsOperation::operator () (Object* object)
|
||||
{
|
||||
BlockOperation():
|
||||
Operation("Block",false)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
virtual void release()
|
||||
{
|
||||
Block::release();
|
||||
}
|
||||
|
||||
virtual void operator () (Object*)
|
||||
{
|
||||
glFlush();
|
||||
Block::release();
|
||||
}
|
||||
};
|
||||
|
||||
osg::GraphicsContext* context = dynamic_cast<osg::GraphicsContext*>(object);
|
||||
if (context) operator() (context);
|
||||
}
|
||||
|
||||
void SwapBuffersOperation::operator () (Object* object)
|
||||
void SwapBuffersOperation::operator () (GraphicsContext* context)
|
||||
{
|
||||
GraphicsContext* context = dynamic_cast<GraphicsContext*>(object);
|
||||
if (context)
|
||||
{
|
||||
context->swapBuffersImplementation();
|
||||
context->clear();
|
||||
}
|
||||
context->swapBuffersImplementation();
|
||||
context->clear();
|
||||
}
|
||||
|
||||
void BarrierOperation::release()
|
||||
@@ -77,7 +58,7 @@ void BarrierOperation::release()
|
||||
Barrier::release();
|
||||
}
|
||||
|
||||
void BarrierOperation::operator () (Object*)
|
||||
void BarrierOperation::operator () (GraphicsContext*)
|
||||
{
|
||||
if (_preBlockOp==GL_FLUSH) glFlush();
|
||||
if (_preBlockOp==GL_FINISH) glFinish();
|
||||
@@ -91,11 +72,8 @@ void ReleaseContext_Block_MakeCurrentOperation::release()
|
||||
}
|
||||
|
||||
|
||||
void ReleaseContext_Block_MakeCurrentOperation::operator () (Object* object)
|
||||
void ReleaseContext_Block_MakeCurrentOperation::operator () (GraphicsContext* context)
|
||||
{
|
||||
GraphicsContext* context = dynamic_cast<GraphicsContext*>(object);
|
||||
if (!context) return;
|
||||
|
||||
// release the graphics context.
|
||||
context->releaseContext();
|
||||
|
||||
@@ -111,7 +89,7 @@ void ReleaseContext_Block_MakeCurrentOperation::operator () (Object* object)
|
||||
|
||||
|
||||
BlockAndFlushOperation::BlockAndFlushOperation():
|
||||
Operation("Block",false)
|
||||
GraphicsOperation("Block",false)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@@ -121,7 +99,7 @@ void BlockAndFlushOperation::release()
|
||||
Block::release();
|
||||
}
|
||||
|
||||
void BlockAndFlushOperation::operator () (Object*)
|
||||
void BlockAndFlushOperation::operator () (GraphicsContext*)
|
||||
{
|
||||
glFlush();
|
||||
Block::release();
|
||||
|
||||
@@ -903,17 +903,15 @@ bool DatabasePager::getCompileGLObjectsForContextID(unsigned int contextID)
|
||||
|
||||
|
||||
DatabasePager::CompileOperation::CompileOperation(osgDB::DatabasePager* databasePager):
|
||||
osg::Operation("DatabasePager::CompileOperation",false),
|
||||
osg::GraphicsOperation("DatabasePager::CompileOperation",false),
|
||||
_databasePager(databasePager)
|
||||
{
|
||||
}
|
||||
|
||||
void DatabasePager::CompileOperation::operator () (osg::Object* object)
|
||||
void DatabasePager::CompileOperation::operator () (osg::GraphicsContext* context)
|
||||
{
|
||||
osg::GraphicsContext* context = dynamic_cast<osg::GraphicsContext*>(object);
|
||||
if (!context) return;
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Background thread compiling"<<std::endl;
|
||||
|
||||
if (_databasePager.valid()) _databasePager->compileAllGLObjects(*(context->getState()));
|
||||
|
||||
}
|
||||
|
||||
@@ -138,3 +138,19 @@ void GLObjectsVisitor::apply(osg::StateSet& stateset)
|
||||
stateset.checkValidityOfAssociatedModes(*_renderInfo.getState());
|
||||
}
|
||||
}
|
||||
|
||||
GLObjectsOperation::GLObjectsOperation(osg::Node* subgraph, GLObjectsVisitor::Mode mode):
|
||||
osg::GraphicsOperation("GLObjectOperation",false),
|
||||
_subgraph(subgraph),
|
||||
_mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
void GLObjectsOperation::operator () (osg::GraphicsContext* context)
|
||||
{
|
||||
GLObjectsVisitor glObjectsVisitor(_mode);
|
||||
|
||||
glObjectsVisitor.setState(context->getState());
|
||||
|
||||
_subgraph->accept(glObjectsVisitor);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <osgIntrospection/StaticMethodInfo>
|
||||
#include <osgIntrospection/Attributes>
|
||||
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osg/GraphicsThread>
|
||||
#include <osg/Object>
|
||||
|
||||
@@ -30,7 +31,7 @@ END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osg::BarrierOperation)
|
||||
I_DeclaringFile("osg/GraphicsThread");
|
||||
I_BaseType(osg::Operation);
|
||||
I_BaseType(osg::GraphicsOperation);
|
||||
I_BaseType(OpenThreads::Barrier);
|
||||
I_ConstructorWithDefaults2(IN, int, numThreads, , IN, osg::BarrierOperation::PreBlockOp, op, osg::BarrierOperation::NO_OPERATION,
|
||||
____BarrierOperation__int__PreBlockOp,
|
||||
@@ -46,7 +47,7 @@ END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osg::BlockAndFlushOperation)
|
||||
I_DeclaringFile("osg/GraphicsThread");
|
||||
I_BaseType(osg::Operation);
|
||||
I_BaseType(osg::GraphicsOperation);
|
||||
I_BaseType(OpenThreads::Block);
|
||||
I_Constructor0(____BlockAndFlushOperation,
|
||||
"",
|
||||
@@ -58,6 +59,15 @@ BEGIN_OBJECT_REFLECTOR(osg::BlockAndFlushOperation)
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsOperation)
|
||||
I_DeclaringFile("osg/GraphicsThread");
|
||||
I_BaseType(osg::Operation);
|
||||
I_Constructor2(IN, const std::string &, name, IN, bool, keep,
|
||||
____GraphicsOperation__C5_std_string_R1__bool,
|
||||
"",
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osg::GraphicsThread)
|
||||
I_DeclaringFile("osg/GraphicsThread");
|
||||
I_BaseType(osg::OperationThread);
|
||||
@@ -73,7 +83,7 @@ END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osg::ReleaseContext_Block_MakeCurrentOperation)
|
||||
I_DeclaringFile("osg/GraphicsThread");
|
||||
I_BaseType(osg::Operation);
|
||||
I_BaseType(osg::GraphicsOperation);
|
||||
I_BaseType(osg::RefBlock);
|
||||
I_Constructor0(____ReleaseContext_Block_MakeCurrentOperation,
|
||||
"",
|
||||
@@ -81,13 +91,13 @@ BEGIN_OBJECT_REFLECTOR(osg::ReleaseContext_Block_MakeCurrentOperation)
|
||||
I_Method0(void, release,
|
||||
Properties::VIRTUAL,
|
||||
__void__release,
|
||||
"if this operation is a barrier then release it. ",
|
||||
"",
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osg::SwapBuffersOperation)
|
||||
I_DeclaringFile("osg/GraphicsThread");
|
||||
I_BaseType(osg::Operation);
|
||||
I_BaseType(osg::GraphicsOperation);
|
||||
I_Constructor0(____SwapBuffersOperation,
|
||||
"",
|
||||
"");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osg/Node>
|
||||
#include <osg/RenderInfo>
|
||||
#include <osg/State>
|
||||
@@ -26,6 +27,15 @@
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgUtil::GLObjectsOperation)
|
||||
I_DeclaringFile("osgUtil/GLObjectsVisitor");
|
||||
I_BaseType(osg::GraphicsOperation);
|
||||
I_ConstructorWithDefaults2(IN, osg::Node *, subgraph, , IN, osgUtil::GLObjectsVisitor::Mode, mode, osgUtil::GLObjectsVisitor::COMPILE_DISPLAY_LISTS|osgUtil::GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|osgUtil::GLObjectsVisitor::CHECK_BLACK_LISTED_MODES,
|
||||
____GLObjectsOperation__osg_Node_P1__GLObjectsVisitor_Mode,
|
||||
"",
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
TYPE_NAME_ALIAS(unsigned int, osgUtil::GLObjectsVisitor::Mode)
|
||||
|
||||
BEGIN_ENUM_REFLECTOR(osgUtil::GLObjectsVisitor::ModeValues)
|
||||
|
||||
Reference in New Issue
Block a user