diff --git a/examples/osgmeshshader/osgmeshshader.cpp b/examples/osgmeshshader/osgmeshshader.cpp index 86d0ca795..b981b67e5 100644 --- a/examples/osgmeshshader/osgmeshshader.cpp +++ b/examples/osgmeshshader/osgmeshshader.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include int main( int argc, char** argv ) @@ -63,8 +64,9 @@ int main( int argc, char** argv ) group->getOrCreateStateSet()->setAttribute( program.get() ); group->addChild( new osg::DrawMeshTasks(0, 1) ); - // group->addChild( new osg::MultiDrawMeshTasksIndirect(0, 0, 0) ); // will require a buffer to be bound. // group->addChild( new osg::DrawMeshTasksIndirect(0) ); // will require a buffer to be bound. + // group->addChild( new osg::MultiDrawMeshTasksIndirect(0, 0, 0) ); // will require a buffer to be bound. + // group->addChild( new osg::MultiDrawMeshTasksIndirectCount(0, 0, 0, 0) ); // will require a buffer to be bound. osgDB::writeNodeFile(*group, "test.osgt"); diff --git a/include/osg/MultiDrawMeshTasksIndirectCount b/include/osg/MultiDrawMeshTasksIndirectCount new file mode 100644 index 000000000..486577d19 --- /dev/null +++ b/include/osg/MultiDrawMeshTasksIndirectCount @@ -0,0 +1,63 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_MULTIDRAWMESHTASKSINDIRECTCOUNT +#define OSG_MULTIDRAWMESHTASKSINDIRECTCOUNT 1 + +#include + +namespace osg { + +/** MultiDrawMeshTasksIndirectCount is an osg::Drawable subclass which encapsulates glMultiDrawMeshTasksIndirectCountNV.*/ +class OSG_EXPORT MultiDrawMeshTasksIndirectCount : public Drawable +{ + public: + + MultiDrawMeshTasksIndirectCount(); + + MultiDrawMeshTasksIndirectCount(GLintptr offset, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride); + + /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ + MultiDrawMeshTasksIndirectCount(const MultiDrawMeshTasksIndirectCount& drawimage,const CopyOp& copyop=CopyOp::SHALLOW_COPY); + + META_Node(osg, MultiDrawMeshTasksIndirectCount); + + void setOffset(GLintptr offset) { _offset = offset; } + GLintptr getOffset() const { return _offset; } + + void setDrawCount(GLintptr count) { _drawCount = count; } + GLintptr getDrawCount() const { return _drawCount; } + + void setMaxDrawCount(GLsizei count) { _maxDrawCount = count; } + GLsizei getMaxDrawCount() const { return _maxDrawCount; } + + void setStride(GLsizei stride) { _stride = stride; } + GLsizei getStride() const { return _stride; } + + virtual void drawImplementation(RenderInfo& renderInfo) const; + + protected: + + MultiDrawMeshTasksIndirectCount& operator = (const MultiDrawMeshTasksIndirectCount&) { return *this;} + + virtual ~MultiDrawMeshTasksIndirectCount(); + + GLintptr _offset; + GLintptr _drawCount; + GLsizei _maxDrawCount; + GLsizei _stride; +}; + +} + +#endif diff --git a/src/osg/CMakeLists.txt b/src/osg/CMakeLists.txt index ced55d877..eba854680 100644 --- a/src/osg/CMakeLists.txt +++ b/src/osg/CMakeLists.txt @@ -76,6 +76,7 @@ SET(TARGET_H ${HEADER_PATH}/DrawMeshTasks ${HEADER_PATH}/DrawMeshTasksIndirect ${HEADER_PATH}/MultiDrawMeshTasksIndirect + ${HEADER_PATH}/MultiDrawMeshTasksIndirectCount ${HEADER_PATH}/DrawPixels ${HEADER_PATH}/Endian ${HEADER_PATH}/Export @@ -295,6 +296,7 @@ SET(TARGET_SRC DrawMeshTasks.cpp DrawMeshTasksIndirect.cpp MultiDrawMeshTasksIndirect.cpp + MultiDrawMeshTasksIndirectCount.cpp DrawPixels.cpp dxtctool.cpp dxtctool.h diff --git a/src/osg/MultiDrawMeshTasksIndirectCount.cpp b/src/osg/MultiDrawMeshTasksIndirectCount.cpp new file mode 100644 index 000000000..86f601864 --- /dev/null +++ b/src/osg/MultiDrawMeshTasksIndirectCount.cpp @@ -0,0 +1,62 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ +#include + +using namespace osg; + +MultiDrawMeshTasksIndirectCount::MultiDrawMeshTasksIndirectCount() : + _offset(0), + _drawCount(0), + _maxDrawCount(0), + _stride(0) +{ + // turn off display lists as they are inappropriate + setSupportsDisplayList(false); +} + +MultiDrawMeshTasksIndirectCount::MultiDrawMeshTasksIndirectCount(GLintptr offset, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride): + _offset(offset), + _drawCount(drawCount), + _maxDrawCount(maxDrawCount), + _stride(stride) +{ + // turn off display lists as they are inappropriate + setSupportsDisplayList(false); +} + +MultiDrawMeshTasksIndirectCount::MultiDrawMeshTasksIndirectCount(const MultiDrawMeshTasksIndirectCount& dmt,const CopyOp& copyop): + Drawable(dmt, copyop), + _offset(dmt._offset), + _drawCount(dmt._drawCount), + _maxDrawCount(dmt._maxDrawCount), + _stride(dmt._stride) +{ +} + +MultiDrawMeshTasksIndirectCount::~MultiDrawMeshTasksIndirectCount() +{ +} + +void MultiDrawMeshTasksIndirectCount::drawImplementation(RenderInfo& renderInfo) const +{ + const GLExtensions* extensions = renderInfo.getState()->get(); + if (extensions->isMeshShaderSupported && extensions->glMultiDrawMeshTasksIndirectCountNV) + { + extensions->glMultiDrawMeshTasksIndirectCountNV(_offset, _drawCount, _maxDrawCount, _stride); + } + else + { + OSG_NOTICE<<"glMultiDrawMeshTasksIndirectCountNV not supported. "< +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( MultiDrawMeshTasksIndirectCount, + new osg::MultiDrawMeshTasksIndirectCount, + osg::MultiDrawMeshTasksIndirectCount, + "osg::Object osg::Node osg::Drawable osg::MultiDrawMeshTasksIndirectCount" ) +{ + wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLintptr >( \ + "Offset", 0, &MyClass::getOffset, &MyClass::setOffset), osgDB::BaseSerializer::RW_INT ); + + wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLintptr >( \ + "DrawCount", 0, &MyClass::getDrawCount, &MyClass::setDrawCount), osgDB::BaseSerializer::RW_INT ); + + wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLsizei >( \ + "MaxDrawCount", 0, &MyClass::getMaxDrawCount, &MyClass::setMaxDrawCount), osgDB::BaseSerializer::RW_INT ); + + wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLsizei>( \ + "Stride", 0, &MyClass::getStride, &MyClass::setStride), osgDB::BaseSerializer::RW_INT ); +}