Added osg::MultiDrawMeshTasksIndirect class
This commit is contained in:
parent
874c9ac691
commit
27a664a4e3
@ -19,6 +19,7 @@
|
||||
#include <osg/Shader>
|
||||
#include <osg/DrawMeshTasks>
|
||||
#include <osg/DrawMeshTasksIndirect>
|
||||
#include <osg/MultiDrawMeshTasksIndirect>
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
int main( int argc, char** argv )
|
||||
@ -62,7 +63,7 @@ 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.
|
||||
|
||||
osgDB::writeNodeFile(*group, "test.osgt");
|
||||
|
59
include/osg/MultiDrawMeshTasksIndirect
Normal file
59
include/osg/MultiDrawMeshTasksIndirect
Normal file
@ -0,0 +1,59 @@
|
||||
/* -*-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_MULTIDRAWMESHTASKSINDIRECT
|
||||
#define OSG_MULTIDRAWMESHTASKSINDIRECT 1
|
||||
|
||||
#include <osg/Drawable>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** MultiDrawMeshTasksIndirect is an osg::Drawable subclass which encapsulates glMultiDrawMeshTasksIndirectNV.*/
|
||||
class OSG_EXPORT MultiDrawMeshTasksIndirect : public Drawable
|
||||
{
|
||||
public:
|
||||
|
||||
MultiDrawMeshTasksIndirect();
|
||||
|
||||
MultiDrawMeshTasksIndirect(GLintptr offset, GLsizei drawCount, GLsizei stride);
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
MultiDrawMeshTasksIndirect(const MultiDrawMeshTasksIndirect& drawimage,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Node(osg, MultiDrawMeshTasksIndirect);
|
||||
|
||||
void setOffset(GLintptr offset) { _offset = offset; }
|
||||
GLintptr getOffset() const { return _offset; }
|
||||
|
||||
void setDrawCount(GLsizei count) { _drawCount = count; }
|
||||
GLsizei getDrawCount() const { return _drawCount; }
|
||||
|
||||
void setStride(GLsizei stride) { _stride = stride; }
|
||||
GLsizei getStride() const { return _stride; }
|
||||
|
||||
virtual void drawImplementation(RenderInfo& renderInfo) const;
|
||||
|
||||
protected:
|
||||
|
||||
MultiDrawMeshTasksIndirect& operator = (const MultiDrawMeshTasksIndirect&) { return *this;}
|
||||
|
||||
virtual ~MultiDrawMeshTasksIndirect();
|
||||
|
||||
GLintptr _offset;
|
||||
GLsizei _drawCount;
|
||||
GLsizei _stride;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -75,6 +75,7 @@ SET(TARGET_H
|
||||
${HEADER_PATH}/Drawable
|
||||
${HEADER_PATH}/DrawMeshTasks
|
||||
${HEADER_PATH}/DrawMeshTasksIndirect
|
||||
${HEADER_PATH}/MultiDrawMeshTasksIndirect
|
||||
${HEADER_PATH}/DrawPixels
|
||||
${HEADER_PATH}/Endian
|
||||
${HEADER_PATH}/Export
|
||||
@ -293,6 +294,7 @@ SET(TARGET_SRC
|
||||
Drawable.cpp
|
||||
DrawMeshTasks.cpp
|
||||
DrawMeshTasksIndirect.cpp
|
||||
MultiDrawMeshTasksIndirect.cpp
|
||||
DrawPixels.cpp
|
||||
dxtctool.cpp
|
||||
dxtctool.h
|
||||
|
@ -26,6 +26,8 @@ DrawMeshTasks::DrawMeshTasks(GLuint first, GLuint count):
|
||||
_first(first),
|
||||
_count(count)
|
||||
{
|
||||
// turn off display lists as they are inappropriate
|
||||
setSupportsDisplayList(false);
|
||||
}
|
||||
|
||||
DrawMeshTasks::DrawMeshTasks(const DrawMeshTasks& dmt,const CopyOp& copyop):
|
||||
|
@ -24,6 +24,8 @@ DrawMeshTasksIndirect::DrawMeshTasksIndirect() :
|
||||
DrawMeshTasksIndirect::DrawMeshTasksIndirect(GLintptr offset):
|
||||
_offset(offset)
|
||||
{
|
||||
// turn off display lists as they are inappropriate
|
||||
setSupportsDisplayList(false);
|
||||
}
|
||||
|
||||
DrawMeshTasksIndirect::DrawMeshTasksIndirect(const DrawMeshTasksIndirect& dmt,const CopyOp& copyop):
|
||||
|
59
src/osg/MultiDrawMeshTasksIndirect.cpp
Normal file
59
src/osg/MultiDrawMeshTasksIndirect.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/* -*-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 <osg/MultiDrawMeshTasksIndirect>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
MultiDrawMeshTasksIndirect::MultiDrawMeshTasksIndirect() :
|
||||
_offset(0),
|
||||
_drawCount(0),
|
||||
_stride(0)
|
||||
{
|
||||
// turn off display lists as they are inappropriate
|
||||
setSupportsDisplayList(false);
|
||||
}
|
||||
|
||||
MultiDrawMeshTasksIndirect::MultiDrawMeshTasksIndirect(GLintptr offset, GLsizei drawCount, GLsizei stride):
|
||||
_offset(offset),
|
||||
_drawCount(drawCount),
|
||||
_stride(stride)
|
||||
{
|
||||
// turn off display lists as they are inappropriate
|
||||
setSupportsDisplayList(false);
|
||||
}
|
||||
|
||||
MultiDrawMeshTasksIndirect::MultiDrawMeshTasksIndirect(const MultiDrawMeshTasksIndirect& dmt,const CopyOp& copyop):
|
||||
Drawable(dmt, copyop),
|
||||
_offset(dmt._offset),
|
||||
_drawCount(dmt._drawCount),
|
||||
_stride(dmt._stride)
|
||||
{
|
||||
}
|
||||
|
||||
MultiDrawMeshTasksIndirect::~MultiDrawMeshTasksIndirect()
|
||||
{
|
||||
}
|
||||
|
||||
void MultiDrawMeshTasksIndirect::drawImplementation(RenderInfo& renderInfo) const
|
||||
{
|
||||
const GLExtensions* extensions = renderInfo.getState()->get<GLExtensions>();
|
||||
if (extensions->isMeshShaderSupported && extensions->glMultiDrawMeshTasksIndirectNV)
|
||||
{
|
||||
extensions->glMultiDrawMeshTasksIndirectNV(_offset, _drawCount, _stride);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"glMultiDrawMeshTasksIndirectNV not supported. "<<std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
#include <osg/MultiDrawMeshTasksIndirect>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( MultiDrawMeshTasksIndirect,
|
||||
new osg::MultiDrawMeshTasksIndirect,
|
||||
osg::MultiDrawMeshTasksIndirect,
|
||||
"osg::Object osg::Node osg::Drawable osg::MultiDrawMeshTasksIndirect" )
|
||||
{
|
||||
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLintptr >( \
|
||||
"Offset", 0, &MyClass::getOffset, &MyClass::setOffset), osgDB::BaseSerializer::RW_INT );
|
||||
|
||||
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLsizei >( \
|
||||
"DrawCount", 0, &MyClass::getDrawCount, &MyClass::setDrawCount), osgDB::BaseSerializer::RW_INT );
|
||||
|
||||
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLsizei>( \
|
||||
"Stride", 0, &MyClass::getStride, &MyClass::setStride), osgDB::BaseSerializer::RW_INT );
|
||||
}
|
Loading…
Reference in New Issue
Block a user