Added osg::DrawMeshTasksIndirect class
This commit is contained in:
parent
64404e9de3
commit
874c9ac691
@ -18,6 +18,7 @@
|
|||||||
#include <osg/Program>
|
#include <osg/Program>
|
||||||
#include <osg/Shader>
|
#include <osg/Shader>
|
||||||
#include <osg/DrawMeshTasks>
|
#include <osg/DrawMeshTasks>
|
||||||
|
#include <osg/DrawMeshTasksIndirect>
|
||||||
#include <osgUtil/Optimizer>
|
#include <osgUtil/Optimizer>
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
@ -57,14 +58,18 @@ int main( int argc, char** argv )
|
|||||||
program->addShader( vShader.get() );
|
program->addShader( vShader.get() );
|
||||||
program->addShader( fShader.get() );
|
program->addShader( fShader.get() );
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> drawMesh = new osg::DrawMeshTasks(0, 1);
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
drawMesh->getOrCreateStateSet()->setAttribute( program.get() );
|
group->getOrCreateStateSet()->setAttribute( program.get() );
|
||||||
|
|
||||||
osgDB::writeNodeFile(*drawMesh, "test.osgt");
|
group->addChild( new osg::DrawMeshTasks(0, 1) );
|
||||||
|
|
||||||
|
// group->addChild( new osg::DrawMeshTasksIndirect(0) ); // will require a buffer to be bound.
|
||||||
|
|
||||||
|
osgDB::writeNodeFile(*group, "test.osgt");
|
||||||
|
|
||||||
osgViewer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer(arguments);
|
||||||
|
|
||||||
viewer.setSceneData( drawMesh );
|
viewer.setSceneData( group );
|
||||||
|
|
||||||
// for non GL3/GL4 and non GLES2 platforms we need enable the osg_ uniforms that the shaders will use,
|
// for non GL3/GL4 and non GLES2 platforms we need enable the osg_ uniforms that the shaders will use,
|
||||||
// you don't need thse two lines on GL3/GL4 and GLES2 specific builds as these will be enable by default.
|
// you don't need thse two lines on GL3/GL4 and GLES2 specific builds as these will be enable by default.
|
||||||
|
@ -11,12 +11,10 @@
|
|||||||
* OpenSceneGraph Public License for more details.
|
* OpenSceneGraph Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OSG_DRAWPIXELS
|
#ifndef OSG_DRAWMESHTASKS
|
||||||
#define OSG_DRAWPIXELS 1
|
#define OSG_DRAWMESHTASKS 1
|
||||||
|
|
||||||
#include <osg/Drawable>
|
#include <osg/Drawable>
|
||||||
#include <osg/Vec3>
|
|
||||||
#include <osg/Image>
|
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
51
include/osg/DrawMeshTasksIndirect
Normal file
51
include/osg/DrawMeshTasksIndirect
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/* -*-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_DRAWMESHTASKSINDIRECT
|
||||||
|
#define OSG_DRAWMESHTASKSINDIRECT 1
|
||||||
|
|
||||||
|
#include <osg/Drawable>
|
||||||
|
|
||||||
|
namespace osg {
|
||||||
|
|
||||||
|
/** DrawMeshTasksIndirect is an osg::Drawable subclass which encapsulates glDrawMeshTasksIndirectNV.*/
|
||||||
|
class OSG_EXPORT DrawMeshTasksIndirect : public Drawable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect();
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect(GLintptr offset);
|
||||||
|
|
||||||
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||||
|
DrawMeshTasksIndirect(const DrawMeshTasksIndirect& drawimage,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||||
|
|
||||||
|
META_Node(osg, DrawMeshTasksIndirect);
|
||||||
|
|
||||||
|
void setOffset(GLintptr offset) { _offset = offset; }
|
||||||
|
GLintptr getOffset() const { return _offset; }
|
||||||
|
|
||||||
|
virtual void drawImplementation(RenderInfo& renderInfo) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect& operator = (const DrawMeshTasksIndirect&) { return *this;}
|
||||||
|
|
||||||
|
virtual ~DrawMeshTasksIndirect();
|
||||||
|
|
||||||
|
GLintptr _offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -74,6 +74,7 @@ SET(TARGET_H
|
|||||||
${HEADER_PATH}/DisplaySettings
|
${HEADER_PATH}/DisplaySettings
|
||||||
${HEADER_PATH}/Drawable
|
${HEADER_PATH}/Drawable
|
||||||
${HEADER_PATH}/DrawMeshTasks
|
${HEADER_PATH}/DrawMeshTasks
|
||||||
|
${HEADER_PATH}/DrawMeshTasksIndirect
|
||||||
${HEADER_PATH}/DrawPixels
|
${HEADER_PATH}/DrawPixels
|
||||||
${HEADER_PATH}/Endian
|
${HEADER_PATH}/Endian
|
||||||
${HEADER_PATH}/Export
|
${HEADER_PATH}/Export
|
||||||
@ -291,6 +292,7 @@ SET(TARGET_SRC
|
|||||||
DisplaySettings.cpp
|
DisplaySettings.cpp
|
||||||
Drawable.cpp
|
Drawable.cpp
|
||||||
DrawMeshTasks.cpp
|
DrawMeshTasks.cpp
|
||||||
|
DrawMeshTasksIndirect.cpp
|
||||||
DrawPixels.cpp
|
DrawPixels.cpp
|
||||||
dxtctool.cpp
|
dxtctool.cpp
|
||||||
dxtctool.h
|
dxtctool.h
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
|
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
DrawMeshTasks::DrawMeshTasks()
|
DrawMeshTasks::DrawMeshTasks():
|
||||||
|
_first(0),
|
||||||
|
_count(0)
|
||||||
{
|
{
|
||||||
// turn off display lists as they are inappropriate
|
// turn off display lists as they are inappropriate
|
||||||
setSupportsDisplayList(false);
|
setSupportsDisplayList(false);
|
||||||
|
51
src/osg/DrawMeshTasksIndirect.cpp
Normal file
51
src/osg/DrawMeshTasksIndirect.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/* -*-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/DrawMeshTasksIndirect>
|
||||||
|
|
||||||
|
using namespace osg;
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect::DrawMeshTasksIndirect() :
|
||||||
|
_offset(0)
|
||||||
|
{
|
||||||
|
// turn off display lists as they are inappropriate
|
||||||
|
setSupportsDisplayList(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect::DrawMeshTasksIndirect(GLintptr offset):
|
||||||
|
_offset(offset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect::DrawMeshTasksIndirect(const DrawMeshTasksIndirect& dmt,const CopyOp& copyop):
|
||||||
|
Drawable(dmt, copyop),
|
||||||
|
_offset(dmt._offset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMeshTasksIndirect::~DrawMeshTasksIndirect()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawMeshTasksIndirect::drawImplementation(RenderInfo& renderInfo) const
|
||||||
|
{
|
||||||
|
const GLExtensions* extensions = renderInfo.getState()->get<GLExtensions>();
|
||||||
|
if (extensions->isMeshShaderSupported && extensions->glDrawMeshTasksIndirectNV)
|
||||||
|
{
|
||||||
|
extensions->glDrawMeshTasksIndirectNV(_offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"glDrawMeshTasksIndirectNV not supported. "<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
13
src/osgWrappers/serializers/osg/DrawMeshTasksIndirect.cpp
Normal file
13
src/osgWrappers/serializers/osg/DrawMeshTasksIndirect.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <osg/DrawMeshTasksIndirect>
|
||||||
|
#include <osgDB/ObjectWrapper>
|
||||||
|
#include <osgDB/InputStream>
|
||||||
|
#include <osgDB/OutputStream>
|
||||||
|
|
||||||
|
REGISTER_OBJECT_WRAPPER( DrawMeshTasksIndirect,
|
||||||
|
new osg::DrawMeshTasksIndirect,
|
||||||
|
osg::DrawMeshTasksIndirect,
|
||||||
|
"osg::Object osg::Node osg::Drawable osg::DrawMeshTasksIndirect" )
|
||||||
|
{
|
||||||
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLintptr >( \
|
||||||
|
"Offset", 0, &MyClass::getOffset, &MyClass::setOffset), osgDB::BaseSerializer::RW_INT );
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user