Removed deprecated code paths and moved implementations into headers

This commit is contained in:
Robert Osfield
2016-08-05 21:59:34 +01:00
parent bf28e2d037
commit e3c663bb02
6 changed files with 185 additions and 2012 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -38,10 +38,14 @@ public:
virtual void enable_and_dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/, const osg::GLBufferObject* /*vbo*/) {} // = 0;
virtual void enable_and_dispatch(osg::State& /*state*/, GLint /*size*/, GLenum /*type*/, GLsizei /*stride*/, const GLvoid * /*ptr*/, GLboolean /*normalized*/) {} // = 0;
virtual void dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/) {} // = 0;
virtual void dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/, const osg::GLBufferObject* /*vbo*/) {} // = 0;
virtual void dispatch(osg::State& /*state*/, GLint /*size*/, GLenum /*type*/, GLsizei /*stride*/, const GLvoid * /*ptr*/, GLboolean /*normalized*/) {} // = 0;
virtual void disable(osg::State& /*state*/) {} // = 0;
const osg::Array* array;
@@ -103,16 +107,22 @@ public:
inline bool isVertexBufferObjectSupported() const { return true; }
void setArray(ArrayDispatch* vad, osg::State& state, const osg::Array* new_array);
void setArray(ArrayDispatch* vad, osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized);
void disable(ArrayDispatch* vad, osg::State& state) { vad->disable(state); vad->array=0; vad->modifiedCount=0xffffffff; vad->active=false; }
inline void disable(ArrayDispatch* vad, osg::State& state) { vad->disable(state); vad->array=0; vad->modifiedCount=0xffffffff; vad->active=false; }
void setInterleavedArrays( osg::State& state, GLenum format, GLsizei stride, const GLvoid* pointer);
inline void setVertexArray(osg::State& state, const osg::Array* array) { setArray(_vertexArray.get(), state, array); }
inline void setVertexArray(osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE) { setArray(_vertexArray.get(), state, size, type, stride, ptr, normalized); }
inline void disableVertexArray(osg::State& state) { disable(_vertexArray.get(), state); }
inline void setNormalArray(osg::State& state, const osg::Array* array) { setArray(_normalArray.get(), state, array); }
inline void setNormalArray(osg::State& state, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE ) { setArray(_normalArray.get(), state, 3, type, stride, ptr, normalized); }
inline void disableNormalArray(osg::State& state) { disable(_normalArray.get(), state); }
inline void setColorArray(osg::State& state, const osg::Array* array) { setArray(_colorArray.get(), state, array); }
inline void setColorArray(osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE ) { setArray(_colorArray.get(), state, size, type, stride, ptr, normalized); }
inline void disableColorArray(osg::State& state) { disable(_colorArray.get(), state); }
inline void setSecondaryColorArray(osg::State& state, const osg::Array* array) { setArray(_secondaryColorArray.get(), state, array); }
@@ -122,6 +132,7 @@ public:
inline void disableFogCoordArray(osg::State& state) { disable(_fogCoordArray.get(), state); }
inline void setTexCoordArray(osg::State& state, unsigned int unit, const osg::Array* array) { setArray(_texCoordArrays[unit].get(), state, array); }
inline void setTexCoordArray(osg::State& state, unsigned int unit, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE ) { setArray(_texCoordArrays[unit].get(), state, size, type, stride, ptr, normalized); }
inline void disableTexCoordArray(osg::State& state, unsigned int unit) { disable(_texCoordArrays[unit].get(),state); }
inline void disableTexCoordArrayAboveAndIncluding(osg::State& state, unsigned int index);
@@ -136,7 +147,7 @@ public:
inline void applyDisablingOfVertexAttributes(osg::State& state);
// Verex Array Object methods.
void generateVretexArrayObject();
void generateVertexArrayObject();
void deleteVertexArrayObject();

View File

@@ -686,7 +686,7 @@ VertexArrayState* Geometry::createVertexArrayState(RenderInfo& renderInfo, bool
{
OSG_NOTICE<<" Setup VertexArrayState to use VAO"<<std::endl;
vas->generateVretexArrayObject();
vas->generateVertexArrayObject();
}
else
{

File diff suppressed because it is too large Load Diff

View File

@@ -132,6 +132,12 @@ struct VertexArrayDispatch : public VertexArrayState::ArrayDispatch
glVertexPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void enable_and_dispatch(osg::State& /*state*/, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(size, type, stride, ptr);
}
virtual void dispatch(osg::State& state, const osg::Array* new_array)
{
VAS_NOTICE<<" VertexArrayDispatch::dispatch("<<new_array->getNumElements()<<")"<<std::endl;
@@ -144,6 +150,11 @@ struct VertexArrayDispatch : public VertexArrayState::ArrayDispatch
glVertexPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void dispatch(osg::State& /*state*/, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
glVertexPointer(size, type, stride, ptr);
}
virtual void disable(osg::State& state)
{
VAS_NOTICE<<" VertexArrayDispatch::disable()"<<std::endl;
@@ -167,6 +178,12 @@ struct ColorArrayDispatch : public VertexArrayState::ArrayDispatch
glColorPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer());
}
virtual void enable_and_dispatch(osg::State& /*state*/, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(size, type, stride, ptr);
}
virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array, const osg::GLBufferObject* vbo)
{
VAS_NOTICE<<" ColorArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<", vbo="<<vbo<<")"<<std::endl;
@@ -187,6 +204,11 @@ struct ColorArrayDispatch : public VertexArrayState::ArrayDispatch
glColorPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void dispatch(osg::State& /*state*/, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
glColorPointer(size, type, stride, ptr);
}
virtual void disable(osg::State& state)
{
VAS_NOTICE<<" ColorArrayDispatch::disable()"<<std::endl;
@@ -216,6 +238,12 @@ struct NormalArrayDispatch : public VertexArrayState::ArrayDispatch
glNormalPointer(new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void enable_and_dispatch(osg::State& /*state*/, GLint /*size*/, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(type, stride, ptr);
}
virtual void dispatch(osg::State& state, const osg::Array* new_array)
{
VAS_NOTICE<<" NormalArrayDispatch::dispatch("<<new_array->getNumElements()<<")"<<std::endl;
@@ -228,6 +256,11 @@ struct NormalArrayDispatch : public VertexArrayState::ArrayDispatch
glNormalPointer(new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void dispatch(osg::State& /*state*/, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
glNormalPointer(type, stride, ptr);
}
virtual void disable(osg::State& state)
{
VAS_NOTICE<<" NormalArrayDispatch::disable()"<<std::endl;
@@ -319,8 +352,7 @@ struct TexCoordArrayDispatch : public VertexArrayState::ArrayDispatch
{
VAS_NOTICE<<" TexCoordArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<") unit="<<unit<<std::endl;
glClientActiveTexture(static_cast<GLenum>(GL_TEXTURE0+unit));
//state.setClientActiveTextureUnit(unit);
state.setClientActiveTextureUnit(unit);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer());
}
@@ -329,17 +361,22 @@ struct TexCoordArrayDispatch : public VertexArrayState::ArrayDispatch
{
VAS_NOTICE<<" TexCoordArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<", vbo="<<vbo<<") unit="<<unit<<std::endl;
//glClientActiveTexture(static_cast<GLenum>(GL_TEXTURE0+unit));
state.setClientActiveTextureUnit(unit);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void enable_and_dispatch(osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
state.setClientActiveTextureUnit(unit);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(size, type, stride, ptr);
}
virtual void dispatch(osg::State& state, const osg::Array* new_array)
{
VAS_NOTICE<<" TexCoordArrayDispatch::dispatch("<<new_array->getNumElements()<<") unit="<<unit<<std::endl;
//glClientActiveTexture(static_cast<GLenum>(GL_TEXTURE0+unit));
state.setClientActiveTextureUnit(unit);
glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer());
}
@@ -348,11 +385,16 @@ struct TexCoordArrayDispatch : public VertexArrayState::ArrayDispatch
{
VAS_NOTICE<<" TexCoordArrayDispatch::dispatch("<<new_array->getNumElements()<<", vbo="<<vbo<<") unit="<<unit<<std::endl;
//glClientActiveTexture(static_cast<GLenum>(GL_TEXTURE0+unit));
state.setClientActiveTextureUnit(unit);
glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
virtual void dispatch(osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean /*normalized*/)
{
state.setClientActiveTextureUnit(unit);
glTexCoordPointer(size, type, stride, ptr);
}
virtual void disable(osg::State& state)
{
VAS_NOTICE<<" TexCoordArrayDispatch::disable() unit="<<unit<<std::endl;
@@ -437,7 +479,7 @@ VertexArrayState::VertexArrayState(osg::State* state):
_ext = _state->get<GLExtensions>();
}
void VertexArrayState::generateVretexArrayObject()
void VertexArrayState::generateVertexArrayObject()
{
_ext->glGenVertexArrays(1, &_vertexArrayObject);
}
@@ -455,8 +497,6 @@ void VertexArrayState::deleteVertexArrayObject()
void VertexArrayState::assignVertexArrayDispatcher()
{
OSG_NOTICE<<"VertexArrayState::assignVertexArrayDispatcher() _state->getUseVertexAttributeAliasing()="<<_state->getUseVertexAttributeAliasing()<<std::endl;
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
if (!_state->getUseVertexAttributeAliasing())
{
@@ -629,3 +669,53 @@ void VertexArrayState::setArray(ArrayDispatch* vad, osg::State& state, const osg
disable(vad, state);
}
}
void VertexArrayState::setArray(ArrayDispatch* vad, osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized)
{
if (ptr)
{
if (!vad->active)
{
vad->active = true;
_activeDispatchers.push_back(vad);
}
if (vad->array==0)
{
unbindVertexBufferObject();
vad->enable_and_dispatch(state, size, type, stride, ptr, normalized);
}
else
{
unbindVertexBufferObject();
vad->dispatch(state, size, type, stride, ptr, normalized);
}
vad->array = 0;
vad->modifiedCount = 0xffffffff;
}
else if (vad->array)
{
disable(vad, state);
}
}
void VertexArrayState::setInterleavedArrays( osg::State& state, GLenum format, GLsizei stride, const GLvoid* pointer)
{
OSG_NOTICE<<"Warning: VertexArrayState::setInterleavedArrays() NOT IMPLEMENTATED YET"<<std::endl;
#if 0
disableAllVertexArrays();
#if defined(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
glInterleavedArrays( format, stride, pointer);
#else
OSG_NOTICE<<"Warning: State::setInterleavedArrays(..) not implemented."<<std::endl;
#endif
// the crude way, assume that all arrays have been affected so dirty them and
// disable them...
dirtyAllVertexArrays();
#endif
}

View File

@@ -725,13 +725,13 @@ void Text::computePositions(unsigned int contextID) const
GlyphQuads& glyphquad = titr->second;
//OSG_NOTICE<<"Text::computePositions("<<contextID<<") glyphquad= "<<&glyphquad<<std::endl;
GlyphQuads::Coords2& coords2 = glyphquad._coords;
if (contextID>=glyphquad._transformedCoords.size())
{
// contextID exceeds one setup for glyphquad._transformedCoords, ignore this request.
continue;
}
GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
if (!transformedCoords) transformedCoords = new osg::Vec3Array;
@@ -812,15 +812,15 @@ void Text::computeBackdropPositions(unsigned int contextID) const
}
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
{
if (contextID >= glyphquad._transformedBackdropCoords[backdrop_index].size())
if (contextID >= glyphquad._transformedBackdropCoords[backdrop_index].size())
{
// contextID exceeds one setup for glyphquad._transformedBackdropCoords, ignore this request.
continue;
}
GlyphQuads::Coords3& transformedCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
if (!transformedCoords) transformedCoords = new osg::Vec3Array();
unsigned int numCoords = coords2->size();
if (numCoords!=transformedCoords->size())
{
@@ -1485,7 +1485,7 @@ void Text::accept(osg::Drawable::ConstAttributeFunctor& af) const
af.apply(osg::Drawable::VERTICES, glyphquad._transformedCoords[0]->size(), &(glyphquad._transformedCoords[0]->front()));
af.apply(osg::Drawable::TEXTURE_COORDS_0, glyphquad._texcoords->size(), &(glyphquad._texcoords->front()));
}
}
}
@@ -1519,13 +1519,13 @@ void Text::resizeGLObjectBuffers(unsigned int maxSize)
TextBase::resizeGLObjectBuffers(maxSize);
getActiveFont()->resizeGLObjectBuffers(maxSize);
for(TextureGlyphQuadMap::iterator itr = _textureGlyphQuadMap.begin();
itr != _textureGlyphQuadMap.end();
++itr)
{
itr->second.resizeGLObjectBuffers(maxSize);
}
}
}
@@ -1540,7 +1540,7 @@ void Text::releaseGLObjects(osg::State* state) const
++itr)
{
itr->second.releaseGLObjects(state);
}
}
}
@@ -1759,7 +1759,7 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
max_backdrop_index = _backdropType+1;
}
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, &(glyphquad._texcoords->front()));
state.setTexCoordPointer( 0, glyphquad._texcoords.get());
state.disableColorPointer();
state.Color(_backdropColor.r(),_backdropColor.g(),_backdropColor.b(),_backdropColor.a());
@@ -1768,7 +1768,7 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
{
state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords->front()));
state.setVertexPointer( transformedBackdropCoords.get());
glPolygonOffset(0.1f * osg::PolygonOffset::getFactorMultiplier(),
osg::PolygonOffset::getUnitsMultiplier() * (max_backdrop_index-backdrop_index) );
state.drawQuads(0,transformedBackdropCoords->size());
@@ -1818,7 +1818,7 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
max_backdrop_index = _backdropType+1;
}
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, &(glyphquad._texcoords->front()));
state.setTexCoordPointer( 0, glyphquad._texcoords.get());
state.disableColorPointer();
state.Color(_backdropColor.r(),_backdropColor.g(),_backdropColor.b(),_backdropColor.a());
@@ -1827,7 +1827,7 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
{
state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords->front()));
state.setVertexPointer( transformedBackdropCoords.get());
state.drawQuads(0,transformedBackdropCoords->size());
}
}
@@ -1874,7 +1874,7 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
max_backdrop_index = _backdropType+1;
}
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, &(glyphquad._texcoords->front()));
state.setTexCoordPointer( 0, glyphquad._texcoords.get());
state.disableColorPointer();
state.Color(_backdropColor.r(),_backdropColor.g(),_backdropColor.b(),_backdropColor.a());
@@ -1883,7 +1883,7 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
{
state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords->front()));
state.setVertexPointer( transformedBackdropCoords.get());
double offset = double(max_backdrop_index-backdrop_index)*0.0001;
glDepthRange( offset, 1.0+offset);
@@ -1973,7 +1973,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
max_backdrop_index = _backdropType+1;
}
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, &(glyphquad._texcoords->front()));
state.setTexCoordPointer( 0, glyphquad._texcoords.get());
state.disableColorPointer();
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
@@ -1981,7 +1981,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
{
state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords->front()));
state.setVertexPointer( transformedBackdropCoords.get());
state.drawQuads(0,transformedBackdropCoords->size());
}
}
@@ -1990,8 +1990,8 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
const GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
if (transformedCoords.valid() && !transformedCoords->empty())
{
state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedCoords->front()));
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, &(glyphquad._texcoords->front()));
state.setVertexPointer( transformedCoords.get());
state.setTexCoordPointer( 0, glyphquad._texcoords.get());
state.drawQuads(0, transformedCoords->size());
}
}
@@ -2040,7 +2040,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
max_backdrop_index = _backdropType+1;
}
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, &(glyphquad._texcoords->front()));
state.setTexCoordPointer( 0, glyphquad._texcoords.get());
state.disableColorPointer();
state.Color(_backdropColor.r(),_backdropColor.g(),_backdropColor.b(),_backdropColor.a());
@@ -2049,7 +2049,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
{
state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords->front()));
state.setVertexPointer( transformedBackdropCoords.get());
state.drawQuads(0,transformedBackdropCoords->size());
}
}
@@ -2078,7 +2078,7 @@ void Text::GlyphQuads::initGlyphQuads()
_coords = new osg::Vec2Array();
_texcoords = new osg::Vec2Array();
_colorCoords = new osg::Vec4Array();
for (size_t i = 0; i < _transformedCoords.size(); i++)
{
_transformedCoords[i] = new osg::Vec3Array();
@@ -2101,7 +2101,7 @@ void Text::GlyphQuads::updateQuadIndices()
{
OSG_WARN << "size of _coords is not divisible by 4.";
}
for (unsigned short i = 0; i < (unsigned short)_coords->size(); i += 4)
{
_quadIndices->push_back(i);
@@ -2161,9 +2161,9 @@ void Text::GlyphQuads::resizeGLObjectBuffers(unsigned int maxSize)
}
}
}
_quadIndices->resizeGLObjectBuffers(maxSize);
initGPUBufferObjects();
}
@@ -2180,5 +2180,5 @@ void Text::GlyphQuads::releaseGLObjects(osg::State* state) const
}
}
_quadIndices->releaseGLObjects(state);
_quadIndices->releaseGLObjects(state);
}