Merge branch 'master' into text_improvements
This commit is contained in:
@@ -772,7 +772,7 @@ void ComputeNode::initComputingSetup()
|
||||
_dataArray->setBufferObject(_ssbo.get());
|
||||
|
||||
|
||||
_ssbb = new osg::ShaderStorageBufferBinding(0, _dataArray, 0, blockSize);
|
||||
_ssbb = new osg::ShaderStorageBufferBinding(0, _dataArray.get(), 0, blockSize);
|
||||
statesetComputation->setAttributeAndModes(_ssbb.get(), osg::StateAttribute::ON);
|
||||
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ struct IndirectTarget
|
||||
}
|
||||
void endRegister(unsigned int index, unsigned int rowsPerInstance, GLenum pixelFormat, GLenum type, GLint internalFormat, bool useMultiDrawArraysIndirect )
|
||||
{
|
||||
indirectCommandTextureBuffer = new osg::TextureBuffer(indirectCommands);
|
||||
indirectCommandTextureBuffer = new osg::TextureBuffer(indirectCommands.get());
|
||||
indirectCommandTextureBuffer->setInternalFormat( GL_R32I );
|
||||
indirectCommandTextureBuffer->bindToImageUnit(index, osg::Texture::READ_WRITE);
|
||||
indirectCommandTextureBuffer->setUnRefImageDataAfterApply(false);
|
||||
@@ -199,11 +199,12 @@ struct IndirectTarget
|
||||
{
|
||||
std::vector<osg::DrawArraysIndirect*> newPrimitiveSets;
|
||||
|
||||
for(unsigned int j=0;j<indirectCommands->size(); ++j){
|
||||
for(unsigned int j=0;j<indirectCommands->size(); ++j)
|
||||
{
|
||||
osg::DrawArraysIndirect *ipr=new osg::DrawArraysIndirect( GL_TRIANGLES, j );
|
||||
ipr->setIndirectCommandArray( indirectCommands);
|
||||
ipr->setIndirectCommandArray( indirectCommands.get());
|
||||
newPrimitiveSets.push_back(ipr);
|
||||
}
|
||||
}
|
||||
|
||||
geometryAggregator->getAggregatedGeometry()->removePrimitiveSet(0,geometryAggregator->getAggregatedGeometry()->getNumPrimitiveSets() );
|
||||
|
||||
@@ -215,7 +216,7 @@ struct IndirectTarget
|
||||
else // use glMultiDrawArraysIndirect()
|
||||
{
|
||||
osg::MultiDrawArraysIndirect *ipr=new osg::MultiDrawArraysIndirect( GL_TRIANGLES );
|
||||
ipr->setIndirectCommandArray( indirectCommands );
|
||||
ipr->setIndirectCommandArray( indirectCommands.get() );
|
||||
geometryAggregator->getAggregatedGeometry()->removePrimitiveSet(0,geometryAggregator->getAggregatedGeometry()->getNumPrimitiveSets() );
|
||||
geometryAggregator->getAggregatedGeometry()->addPrimitiveSet( ipr );
|
||||
}
|
||||
@@ -236,6 +237,7 @@ struct IndirectTarget
|
||||
instanceTarget->bindToImageUnit(OSGGPUCULL_MAXIMUM_INDIRECT_TARGET_NUMBER+index, osg::Texture::READ_WRITE);
|
||||
|
||||
}
|
||||
|
||||
void addIndirectCommandData( const std::string& uniformNamePrefix, int index, osg::StateSet* stateset )
|
||||
{
|
||||
std::string uniformName = uniformNamePrefix + char( '0' + index );
|
||||
@@ -245,6 +247,7 @@ struct IndirectTarget
|
||||
|
||||
|
||||
}
|
||||
|
||||
void addIndirectTargetData( bool cullPhase, const std::string& uniformNamePrefix, int index, osg::StateSet* stateset )
|
||||
{
|
||||
std::string uniformName;
|
||||
@@ -257,6 +260,7 @@ struct IndirectTarget
|
||||
stateset->addUniform( uniform );
|
||||
stateset->setTextureAttribute( OSGGPUCULL_MAXIMUM_INDIRECT_TARGET_NUMBER+index, instanceTarget.get() );
|
||||
}
|
||||
|
||||
void addDrawProgram( const std::string& uniformBlockName, osg::StateSet* stateset )
|
||||
{
|
||||
drawProgram->addBindUniformBlock(uniformBlockName, 1);
|
||||
@@ -286,6 +290,7 @@ struct GPUCullData
|
||||
instanceTypesUBB = new osg::UniformBufferBinding(1, instanceTypes.get(), 0, 0);
|
||||
|
||||
}
|
||||
|
||||
void setUseMultiDrawArraysIndirect( bool value )
|
||||
{
|
||||
useMultiDrawArraysIndirect = value;
|
||||
@@ -297,6 +302,7 @@ struct GPUCullData
|
||||
return;
|
||||
targets[index] = IndirectTarget( agv, targetDrawProgram );
|
||||
}
|
||||
|
||||
bool registerType(unsigned int typeID, unsigned int targetID, osg::Node* node, const osg::Vec4& lodDistances, float maxDensityPerSquareKilometer )
|
||||
{
|
||||
if( typeID >= instanceTypes->getData().size() )
|
||||
@@ -328,6 +334,7 @@ struct GPUCullData
|
||||
target->second.maxTargetQuantity += maxQuantity;
|
||||
return true;
|
||||
}
|
||||
|
||||
// endRegister() method is called after all indirect targets and instance types are registered.
|
||||
// It creates indirect targets with pixel format and data type provided by user ( indirect targets may hold
|
||||
// different information about single instance depending on user's needs ( in our example : static rendering
|
||||
@@ -388,10 +395,12 @@ struct StaticInstance
|
||||
: position(m), extraParams(params), idParams(typeID,id,0,0)
|
||||
{
|
||||
}
|
||||
|
||||
osg::Vec3d getPosition() const
|
||||
{
|
||||
return position.getTrans();
|
||||
}
|
||||
|
||||
osg::Matrixf position;
|
||||
osg::Vec4f extraParams;
|
||||
osg::Vec4i idParams;
|
||||
@@ -705,10 +714,12 @@ struct ResetTexturesCallback : public osg::StateSet::Callback
|
||||
ResetTexturesCallback()
|
||||
{
|
||||
}
|
||||
|
||||
void addTextureDirty( unsigned int texUnit )
|
||||
{
|
||||
texUnitsDirty.push_back(texUnit);
|
||||
}
|
||||
|
||||
void addTextureDirtyParams( unsigned int texUnit )
|
||||
{
|
||||
texUnitsDirtyParams.push_back(texUnit);
|
||||
@@ -748,6 +759,7 @@ struct InvokeMemoryBarrier : public osg::Drawable::DrawCallback
|
||||
: _barriers(barriers)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void drawImplementation(osg::RenderInfo& renderInfo,const osg::Drawable* drawable) const
|
||||
{
|
||||
//DrawIndirectGLExtensions *ext = DrawIndirectGLExtensions::getExtensions( renderInfo.getContextID(), true );
|
||||
@@ -836,11 +848,13 @@ osg::Group* createSimpleHouse( float detailRatio, const osg::Vec4& buildingColor
|
||||
osg::ref_ptr<osg::Geode> chimneyGeode = convertShapeToGeode( *chimney.get(), tessHints.get(), chimneyColor );
|
||||
root->addChild( chimneyGeode.get() );
|
||||
}
|
||||
|
||||
{
|
||||
osg::ref_ptr<osg::Cylinder> chimney = new osg::Cylinder( osg::Vec3( -5.5, 3.0, 16.5 ), 0.1, 1.0 );
|
||||
osg::ref_ptr<osg::Geode> chimneyGeode = convertShapeToGeode( *chimney.get(), tessHints.get(), chimneyColor );
|
||||
root->addChild( chimneyGeode.get() );
|
||||
}
|
||||
|
||||
{
|
||||
osg::ref_ptr<osg::Cylinder> chimney = new osg::Cylinder( osg::Vec3( -5.0, 3.0, 16.25 ), 0.1, 0.5 );
|
||||
osg::ref_ptr<osg::Geode> chimneyGeode = convertShapeToGeode( *chimney.get(), tessHints.get(), chimneyColor );
|
||||
@@ -1183,6 +1197,7 @@ struct AnimateObjectsCallback : public osg::DrawableUpdateCallback
|
||||
for(; i<3*_quantityPerType; ++i) // speed of airplanes
|
||||
_speed.push_back( random( 10.0, 16.0 ) );
|
||||
}
|
||||
|
||||
virtual void update(osg::NodeVisitor* nv, osg::Drawable* drawable)
|
||||
{
|
||||
if( nv->getVisitorType() != osg::NodeVisitor::UPDATE_VISITOR )
|
||||
@@ -1213,6 +1228,7 @@ struct AnimateObjectsCallback : public osg::DrawableUpdateCallback
|
||||
setRotationUsingRotSpeed( i, 5, osg::Matrix::rotate( osg::DegreesToRadians(90.0), osg::Vec3(0.0,1.0,0.0)) * osg::Matrix::translate(0.0,2.0,-6.0), currentTime, 0.5 );
|
||||
setRotationUsingRotSpeed( i, 6, osg::Matrix::rotate( osg::DegreesToRadians(90.0), osg::Vec3(0.0,1.0,0.0)) * osg::Matrix::translate(0.0,-2.0,-6.0), currentTime, -0.5 );
|
||||
}
|
||||
|
||||
for(;i<2*_quantityPerType;++i) //update cars
|
||||
{
|
||||
nbbox.expandBy( updateObjectPosition( vertexArray, i, deltaTime ) );
|
||||
@@ -1223,6 +1239,7 @@ struct AnimateObjectsCallback : public osg::DrawableUpdateCallback
|
||||
setRotationUsingRotSpeed( i, 3, osg::Matrix::rotate( osg::DegreesToRadians(90.0), osg::Vec3(1.0,0.0,0.0)) * osg::Matrix::translate(2.0,-1.8,1.0), currentTime, wheelRotSpeed );
|
||||
setRotationUsingRotSpeed( i, 4, osg::Matrix::rotate( osg::DegreesToRadians(90.0), osg::Vec3(1.0,0.0,0.0)) * osg::Matrix::translate(-2.0,-1.8,1.0), currentTime, wheelRotSpeed );
|
||||
}
|
||||
|
||||
for(;i<3*_quantityPerType;++i) // update airplanes
|
||||
{
|
||||
nbbox.expandBy( updateObjectPosition( vertexArray, i, deltaTime ) );
|
||||
@@ -1251,6 +1268,7 @@ struct AnimateObjectsCallback : public osg::DrawableUpdateCallback
|
||||
(*vertexArray)[index] = newPosition;
|
||||
return newPosition;
|
||||
}
|
||||
|
||||
void setRotationUsingRotSpeed( unsigned int index, unsigned int boneIndex, const osg::Matrix& zeroMatrix, double currentTime, double rotSpeed )
|
||||
{
|
||||
// setRotationUsingRotSpeed() is a very unoptimally written ( because it uses osg::Matrix::inverse() ),
|
||||
@@ -1473,12 +1491,16 @@ int main( int argc, char **argv )
|
||||
|
||||
if ( arguments.read("--skip-static") )
|
||||
showStaticRendering = false;
|
||||
|
||||
if ( arguments.read("--skip-dynamic") )
|
||||
showDynamicRendering = false;
|
||||
|
||||
if ( arguments.read("--export-objects") )
|
||||
exportInstanceObjects = true;
|
||||
|
||||
if ( arguments.read("--use-multi-draw") )
|
||||
useMultiDrawArraysIndirect = true;
|
||||
|
||||
arguments.read("--instances-per-cell",instancesPerCell);
|
||||
arguments.read("--static-area-size",staticAreaSize);
|
||||
arguments.read("--dynamic-area-size",dynamicAreaSize);
|
||||
|
||||
@@ -69,10 +69,24 @@ int main( int argc, char**argv )
|
||||
arguments.read("--numX",MAXX);
|
||||
arguments.read("--numY",MAXY);
|
||||
|
||||
bool MDIenable=true;
|
||||
enum PrimtiveSetUsage
|
||||
{
|
||||
MultiDraw,
|
||||
MultiplePrimitiveSets,
|
||||
SinglePrimitiveSet
|
||||
};
|
||||
|
||||
PrimtiveSetUsage usage = MultiDraw;
|
||||
if(arguments.read("--classic"))
|
||||
{ MDIenable=false;
|
||||
OSG_WARN<<"disabling MDI"<<std::endl;
|
||||
{
|
||||
usage = MultiplePrimitiveSets;
|
||||
OSG_WARN<<"disabling MDI, using multiple PrimitiveSet"<<std::endl;
|
||||
}
|
||||
|
||||
if(arguments.read("--single"))
|
||||
{
|
||||
usage = SinglePrimitiveSet;
|
||||
OSG_WARN<<"disabling MDI, using single PrimitiveSet"<<std::endl;
|
||||
}
|
||||
|
||||
osg::Geode* root( new osg::Geode );
|
||||
@@ -86,6 +100,7 @@ int main( int argc, char**argv )
|
||||
|
||||
osg::ref_ptr<osg::Geometry> geom=new osg::Geometry();
|
||||
geom->setUseVertexBufferObjects(true);
|
||||
|
||||
osg::BoundingBox bb;
|
||||
bb.set(0,0,0,MAXX,0,MAXY);
|
||||
//set bounds by hand cause of the lack of support of basevertex in PrimitiveFunctors
|
||||
@@ -104,10 +119,10 @@ int main( int argc, char**argv )
|
||||
|
||||
osg::Vec3Array * verts=new osg::Vec3Array();
|
||||
|
||||
|
||||
for(int j =0 ; j<MAXY; ++j) {
|
||||
for(int i =0 ; i<MAXX; ++i) {
|
||||
|
||||
for(int j =0 ; j<MAXY; ++j)
|
||||
{
|
||||
for(int i =0 ; i<MAXX; ++i)
|
||||
{
|
||||
///create indirect command
|
||||
osg::DrawElementsIndirectCommand cmd;
|
||||
cmd.count=4;
|
||||
@@ -116,24 +131,58 @@ int main( int argc, char**argv )
|
||||
cmd.baseVertex=verts->size();
|
||||
mdicommands->push_back(cmd);
|
||||
|
||||
for(int z=0; z<4; z++) {
|
||||
for(int z=0; z<4; z++)
|
||||
{
|
||||
verts->push_back(osg::Vec3(i,0,j)+myCoords[z]);
|
||||
mdi->addElement(myIndices[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
geom->setVertexArray(verts);
|
||||
if(MDIenable) {
|
||||
geom->addPrimitiveSet(mdi);
|
||||
|
||||
} else
|
||||
for(int i=0; i<MAXY*MAXX; ++i) {
|
||||
osg::DrawElementsUInt *dre=new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP,4,myIndicesUI) ;
|
||||
dre->setElementBufferObject(ebo);
|
||||
geom->addPrimitiveSet(dre);
|
||||
for(int z=0; z<4; z++)myIndicesUI[z]+=4;
|
||||
geom->setVertexArray(verts);
|
||||
|
||||
switch(usage)
|
||||
{
|
||||
case(MultiDraw):
|
||||
{
|
||||
geom->addPrimitiveSet(mdi);
|
||||
break;
|
||||
|
||||
}
|
||||
case(MultiplePrimitiveSets):
|
||||
{
|
||||
for(int i=0; i<MAXY*MAXX; ++i)
|
||||
{
|
||||
osg::ref_ptr<osg::DrawElementsUInt> dre = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP,4,myIndicesUI);
|
||||
dre->setElementBufferObject(ebo.get());
|
||||
geom->addPrimitiveSet(dre.get());
|
||||
for(int z=0; z<4; z++) myIndicesUI[z]+=4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(SinglePrimitiveSet):
|
||||
{
|
||||
osg::ref_ptr<osg::DrawElementsUInt> primitives = new osg::DrawElementsUInt(GL_TRIANGLES);
|
||||
primitives->setElementBufferObject(ebo.get());
|
||||
geom->addPrimitiveSet(primitives.get());
|
||||
|
||||
unsigned int vi = 0;
|
||||
for(int i=0; i<MAXY*MAXX; ++i)
|
||||
{
|
||||
primitives->push_back(vi);
|
||||
primitives->push_back(vi+2);
|
||||
primitives->push_back(vi+1);
|
||||
primitives->push_back(vi+1);
|
||||
primitives->push_back(vi+2);
|
||||
primitives->push_back(vi+3);
|
||||
vi += 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
root->addChild(geom);
|
||||
|
||||
osgViewer::Viewer viewer;
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
viewer.setSceneData( root );
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
class EscapeHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
EscapeHandler() {}
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
|
||||
@@ -22,7 +22,7 @@ class EscapeHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
||||
if (view) view->getViewerBase()->setDone(true);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,8 @@ class EscapeHandler : public osgGA::GUIEventHandler
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>", "Provide authentication information for http file access.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--password <password>", "Provide password for any vnc url on command line not mentioned in --login.");
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
|
||||
@@ -52,6 +54,15 @@ int main(int argc,char** argv)
|
||||
{
|
||||
}
|
||||
|
||||
std::string url, username, password;
|
||||
while (arguments.read("--login", url, username, password))
|
||||
{
|
||||
osgDB::Registry::instance()->getOrCreateAuthenticationMap()->addAuthenticationDetails(
|
||||
url,
|
||||
new osgDB::AuthenticationDetails(username, password)
|
||||
);
|
||||
}
|
||||
|
||||
for(int i=1; i<arguments.argc(); ++i)
|
||||
{
|
||||
if (!arguments.isOption(i))
|
||||
@@ -60,15 +71,19 @@ int main(int argc,char** argv)
|
||||
|
||||
if (!password.empty())
|
||||
{
|
||||
if (!osgDB::Registry::instance()->getAuthenticationMap()) osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
|
||||
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(hostname, new osgDB::AuthenticationDetails("", password));
|
||||
const osgDB::AuthenticationMap* authenticationMap = osgDB::Registry::instance()->getOrCreateAuthenticationMap();
|
||||
const osgDB::AuthenticationDetails* details = authenticationMap->getAuthenticationDetails(hostname);
|
||||
if (details == NULL)
|
||||
{
|
||||
authenticationMap->addAuthenticationDetails(hostname, new osgDB::AuthenticationDetails("", password));
|
||||
}
|
||||
}
|
||||
|
||||
osg::ref_ptr<osgWidget::VncClient> vncClient = new osgWidget::VncClient;
|
||||
if (vncClient->connect(arguments[i], hints))
|
||||
{
|
||||
{
|
||||
group->addChild(vncClient.get());
|
||||
|
||||
|
||||
hints.position.x() += 1.1f;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user