From Julien Valentin, "To sum up changes, I had:
-some extensions in GLExtensions - GL_TEXTURE_BUFFER as target in osg::StateSet - a VBO based transform feed back example " git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14651 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -1065,6 +1065,12 @@ GLExtensions::GLExtensions(unsigned int contextID)
|
||||
osg::setGLExtensionFuncPtr(glGetTransformFeedbacki_v, "glGetTransformFeedbacki_v");
|
||||
osg::setGLExtensionFuncPtr(glGetTransformFeedbacki64_v, "glGetTransformFeedbacki64_v");
|
||||
|
||||
//Vertex Array Object
|
||||
osg::setGLExtensionFuncPtr(glGenVertexArrays,"glGenVertexArrays");
|
||||
osg::setGLExtensionFuncPtr(glBindVertexArray,"glBindVertexArray");
|
||||
osg::setGLExtensionFuncPtr(glDeleteVertexArrays,"glDeleteVertexArrays");
|
||||
osg::setGLExtensionFuncPtr(glIsVertexArray,"glIsVertexArray");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ void Program::ProgramBinary::assign(unsigned int size, const unsigned char* data
|
||||
Program::Program() :
|
||||
_geometryVerticesOut(1), _geometryInputType(GL_TRIANGLES),
|
||||
_geometryOutputType(GL_TRIANGLE_STRIP),
|
||||
_numGroupsX(0), _numGroupsY(0), _numGroupsZ(0)
|
||||
_numGroupsX(0), _numGroupsY(0), _numGroupsZ(0), _feedbackmode(GL_SEPARATE_ATTRIBS)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -180,6 +180,9 @@ Program::Program(const Program& rhs, const osg::CopyOp& copyop):
|
||||
_numGroupsX = rhs._numGroupsX;
|
||||
_numGroupsY = rhs._numGroupsY;
|
||||
_numGroupsZ = rhs._numGroupsZ;
|
||||
|
||||
_feedbackmode=rhs._feedbackmode;
|
||||
_feedbackout=rhs._feedbackout;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +226,9 @@ int Program::compare(const osg::StateAttribute& sa) const
|
||||
if( _numGroupsZ < rhs._numGroupsZ ) return -1;
|
||||
if( rhs._numGroupsZ < _numGroupsZ ) return 1;
|
||||
|
||||
if(_feedbackout<rhs._feedbackout) return -1;
|
||||
if(_feedbackmode<rhs._feedbackmode) return -1;
|
||||
|
||||
ShaderList::const_iterator litr=_shaderList.begin();
|
||||
ShaderList::const_iterator ritr=rhs._shaderList.begin();
|
||||
for(;
|
||||
@@ -248,6 +254,24 @@ void Program::compileGLObjects( osg::State& state ) const
|
||||
_shaderList[i]->compileShader( state );
|
||||
}
|
||||
|
||||
if(!_feedbackout.empty())
|
||||
{
|
||||
const PerContextProgram* pcp = getPCP(contextID);
|
||||
const GLExtensions* extensions = state.get<GLExtensions>();
|
||||
|
||||
unsigned int numfeedback = _feedbackout.size();
|
||||
const char**varyings = new const char*[numfeedback];
|
||||
const char **varyingsptr = varyings;
|
||||
for(std::vector<std::string>::const_iterator it=_feedbackout.begin();
|
||||
it!=_feedbackout.end();
|
||||
it++)
|
||||
{
|
||||
*varyingsptr++=(*it).c_str();
|
||||
}
|
||||
|
||||
extensions->glTransformFeedbackVaryings( pcp->getHandle(), numfeedback, varyings, _feedbackmode);
|
||||
delete [] varyings;
|
||||
}
|
||||
getPCP( contextID )->linkProgram(state);
|
||||
}
|
||||
|
||||
@@ -437,7 +461,7 @@ void Program::removeBindUniformBlock(const std::string& name)
|
||||
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
void Program::apply( osg::State& state ) const
|
||||
{
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
@@ -50,6 +50,7 @@ class TextureGLModeSet
|
||||
_textureModeSet.insert(GL_TEXTURE_1D);
|
||||
_textureModeSet.insert(GL_TEXTURE_2D);
|
||||
_textureModeSet.insert(GL_TEXTURE_3D);
|
||||
_textureModeSet.insert(GL_TEXTURE_BUFFER_ARB);
|
||||
|
||||
_textureModeSet.insert(GL_TEXTURE_CUBE_MAP);
|
||||
_textureModeSet.insert(GL_TEXTURE_RECTANGLE_NV);
|
||||
|
||||
@@ -76,7 +76,51 @@ static bool writeShaders( osgDB::OutputStream& os, const osg::Program& attr )
|
||||
os << os.END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
// feedBackVaryings
|
||||
static bool checkFeedBackVaryingsName( const osg::Program& attr )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static bool readFeedBackVaryingsName( osgDB::InputStream& is, osg::Program& attr )
|
||||
{
|
||||
unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
std::string str;
|
||||
is>> str;
|
||||
attr.addTransformFeedBackVarying(str);
|
||||
}
|
||||
is >> is.END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
static bool writeFeedBackVaryingsName( osgDB::OutputStream& os, const osg::Program& attr )
|
||||
{
|
||||
unsigned int size = attr.getNumTransformFeedBackVaryings();
|
||||
os.writeSize(size); os << os.BEGIN_BRACKET << std::endl;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
os << attr.getTransformFeedBackVarying(i)<< std::endl;
|
||||
}
|
||||
os << os.END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
// feedBack mode
|
||||
static bool checkFeedBackMode( const osg::Program& attr )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static bool readFeedBackMode( osgDB::InputStream& is, osg::Program& attr )
|
||||
{
|
||||
unsigned int size ;
|
||||
is>>size;
|
||||
attr.setTransformFeedBackMode(size);
|
||||
return true;
|
||||
}
|
||||
static bool writeFeedBackMode( osgDB::OutputStream& os, const osg::Program& attr )
|
||||
{
|
||||
os << attr.getTransformFeedBackMode()<< std::endl;
|
||||
return true;
|
||||
}
|
||||
// _numGroupsX/Y/Z
|
||||
static bool checkComputeGroups( const osg::Program& attr )
|
||||
{
|
||||
@@ -112,8 +156,15 @@ REGISTER_OBJECT_WRAPPER( Program,
|
||||
ADD_USER_SERIALIZER( GeometryVerticesOut ); // _geometryVerticesOut
|
||||
ADD_USER_SERIALIZER( GeometryInputType ); // _geometryInputType
|
||||
ADD_USER_SERIALIZER( GeometryOutputType ); // _geometryOutputType
|
||||
|
||||
{
|
||||
UPDATE_TO_VERSION_SCOPED( 95 )
|
||||
ADD_USER_SERIALIZER( ComputeGroups ); // _numGroupsX/Y/Z
|
||||
}
|
||||
|
||||
{
|
||||
UPDATE_TO_VERSION_SCOPED( 116 )
|
||||
ADD_USER_SERIALIZER( FeedBackVaryingsName );
|
||||
ADD_USER_SERIALIZER( FeedBackMode );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user