Preliminary work on support for a texture object pool that is designed to help manage resources down the GPU more tightly.
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
#ifdef GL_FOG_COORDINATE_ARRAY_EXT
|
||||
#define GL_FOG_COORDINATE_ARRAY GL_FOG_COORDINATE_ARRAY_EXT
|
||||
#else
|
||||
#define GL_FOG_COORDINATE_ARRAY 0x8457
|
||||
#define GL_FOG_COORDINATE_ARRAY 0x8457
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
#ifdef GL_SECONDARY_COLOR_ARRAY_EXT
|
||||
#define GL_SECONDARY_COLOR_ARRAY GL_SECONDARY_COLOR_ARRAY_EXT
|
||||
#else
|
||||
#define GL_SECONDARY_COLOR_ARRAY 0x845E
|
||||
#define GL_SECONDARY_COLOR_ARRAY 0x845E
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** macro for use with osg::StateAttribute::apply methods for detecting and
|
||||
* reporting OpenGL error messages.*/
|
||||
* reporting OpenGL error messages.*/
|
||||
#define OSG_GL_DEBUG(message) \
|
||||
if (state.getFineGrainedErrorDetection()) \
|
||||
{ \
|
||||
@@ -70,37 +70,37 @@ namespace osg {
|
||||
class GraphicsContext;
|
||||
|
||||
/** Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,
|
||||
* implements lazy state updating and provides accessors for querying the current state.
|
||||
* The venerable Red Book says that "OpenGL is a state machine", and this class
|
||||
* represents the OpenGL state in OSG. Furthermore, \c State also has other
|
||||
* important features:
|
||||
* - It works as a stack of states (see \c pushStateSet() and
|
||||
* \c popStateSet()). Manipulating this stack of OpenGL states manually is
|
||||
* seldom needed, since OSG does this in the most common situations.
|
||||
* - It implements lazy state updating. This means that, if one requests a
|
||||
* state change and that particular state is already in the requested state,
|
||||
* no OpenGL call will be made. This ensures that the OpenGL pipeline is not
|
||||
* stalled by unnecessary state changes.
|
||||
* - It allows to query the current OpenGL state without calls to \c glGet*(),
|
||||
* which typically stall the graphics pipeline (see, for instance,
|
||||
* \c captureCurrentState() and \c getModelViewMatrix()).
|
||||
*/
|
||||
* implements lazy state updating and provides accessors for querying the current state.
|
||||
* The venerable Red Book says that "OpenGL is a state machine", and this class
|
||||
* represents the OpenGL state in OSG. Furthermore, \c State also has other
|
||||
* important features:
|
||||
* - It works as a stack of states (see \c pushStateSet() and
|
||||
* \c popStateSet()). Manipulating this stack of OpenGL states manually is
|
||||
* seldom needed, since OSG does this in the most common situations.
|
||||
* - It implements lazy state updating. This means that, if one requests a
|
||||
* state change and that particular state is already in the requested state,
|
||||
* no OpenGL call will be made. This ensures that the OpenGL pipeline is not
|
||||
* stalled by unnecessary state changes.
|
||||
* - It allows to query the current OpenGL state without calls to \c glGet*(),
|
||||
* which typically stall the graphics pipeline (see, for instance,
|
||||
* \c captureCurrentState() and \c getModelViewMatrix()).
|
||||
*/
|
||||
class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
public :
|
||||
|
||||
State();
|
||||
|
||||
|
||||
/** Set the graphics context associated with that owns this State object.*/
|
||||
|
||||
/** Set the graphics context associated with that owns this State object.*/
|
||||
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
|
||||
|
||||
/** Get the graphics context associated with that owns this State object.*/
|
||||
/** Get the graphics context associated with that owns this State object.*/
|
||||
GraphicsContext* getGraphicsContext() { return _graphicsContext; }
|
||||
|
||||
/** Get the const graphics context associated with that owns this State object.*/
|
||||
/** Get the const graphics context associated with that owns this State object.*/
|
||||
const GraphicsContext* getGraphicsContext() const { return _graphicsContext; }
|
||||
|
||||
|
||||
|
||||
/** Set the current OpenGL context uniqueID.
|
||||
Note, it is the application developers responsibility to
|
||||
@@ -122,9 +122,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
/** Pop stateset off state stack.*/
|
||||
void popStateSet();
|
||||
|
||||
|
||||
/** pop all statesets off state stack, ensuring it is empty ready for the next frame.
|
||||
* Note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().*/
|
||||
* Note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().*/
|
||||
void popAllStateSets();
|
||||
|
||||
/** Insert stateset onto state stack.*/
|
||||
@@ -132,10 +132,10 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
/** Pop stateset off state stack.*/
|
||||
void removeStateSet(unsigned int pos);
|
||||
|
||||
|
||||
/** Get the number of StateSet's on the StateSet stack.*/
|
||||
unsigned int getStateSetStackSize() { return static_cast<unsigned int>(_stateStateStack.size()); }
|
||||
|
||||
|
||||
/** Pop StateSet's for the StateSet stack till its size equals the specified size.*/
|
||||
void popStateSetStackToSize(unsigned int size) { while (_stateStateStack.size()>size) popStateSet(); }
|
||||
|
||||
@@ -143,7 +143,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
/** Get the StateSet stack.*/
|
||||
StateSetStack& getStateSetStack() { return _stateStateStack; }
|
||||
|
||||
|
||||
|
||||
/** Copy the modes and attributes which capture the current state.*/
|
||||
void captureCurrentState(StateSet& stateset) const;
|
||||
@@ -216,14 +216,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
void apply(const StateSet* dstate);
|
||||
|
||||
/** Updates the OpenGL state so that it matches the \c StateSet at the
|
||||
* top of the stack of <tt>StateSet</tt>s maintained internally by a
|
||||
* \c State.
|
||||
*/
|
||||
* top of the stack of <tt>StateSet</tt>s maintained internally by a
|
||||
* \c State.
|
||||
*/
|
||||
void apply();
|
||||
|
||||
|
||||
/** Set whether a particular OpenGL mode is valid in the current graphics context.
|
||||
* Use to disable OpenGL modes that are not supported by current graphics drivers/context.*/
|
||||
* Use to disable OpenGL modes that are not supported by current graphics drivers/context.*/
|
||||
inline void setModeValidity(StateAttribute::GLMode mode,bool valid)
|
||||
{
|
||||
ModeStack& ms = _modeMap[mode];
|
||||
@@ -231,7 +231,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** Get whether a particular OpenGL mode is valid in the current graphics context.
|
||||
* Use to disable OpenGL modes that are not supported by current graphics drivers/context.*/
|
||||
* Use to disable OpenGL modes that are not supported by current graphics drivers/context.*/
|
||||
inline bool getModeValidity(StateAttribute::GLMode mode)
|
||||
{
|
||||
ModeStack& ms = _modeMap[mode];
|
||||
@@ -251,13 +251,13 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** Apply an OpenGL mode if required. This is a wrapper around
|
||||
* \c glEnable() and \c glDisable(), that just actually calls these
|
||||
* functions if the \c enabled flag is different than the current
|
||||
* state.
|
||||
* @return \c true if the state was actually changed. \c false
|
||||
* otherwise. Notice that a \c false return does not indicate
|
||||
* an error, it just means that the mode was already set to the
|
||||
* same value as the \c enabled parameter.
|
||||
* \c glEnable() and \c glDisable(), that just actually calls these
|
||||
* functions if the \c enabled flag is different than the current
|
||||
* state.
|
||||
* @return \c true if the state was actually changed. \c false
|
||||
* otherwise. Notice that a \c false return does not indicate
|
||||
* an error, it just means that the mode was already set to the
|
||||
* same value as the \c enabled parameter.
|
||||
*/
|
||||
inline bool applyMode(StateAttribute::GLMode mode,bool enabled)
|
||||
{
|
||||
@@ -345,44 +345,44 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
void haveAppliedMode(StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
|
||||
|
||||
/** Mode has been set externally, therefore dirty the associated mode in osg::State
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
void haveAppliedMode(StateAttribute::GLMode mode);
|
||||
|
||||
/** Attribute has been applied externally, update state to reflect this setting.*/
|
||||
void haveAppliedAttribute(const StateAttribute* attribute);
|
||||
|
||||
/** Attribute has been applied externally,
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-applied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
* then use the have_applied(attribute) method as this will cause the osg::State to
|
||||
* track the current state more accurately and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
/** Attribute has been applied externally,
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-applied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
* then use the have_applied(attribute) method as this will cause the osg::State to
|
||||
* track the current state more accurately and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
void haveAppliedAttribute(StateAttribute::Type type, unsigned int member=0);
|
||||
|
||||
/** Get whether the current specified mode is enabled (true) or disabled (false).*/
|
||||
/** Get whether the current specified mode is enabled (true) or disabled (false).*/
|
||||
bool getLastAppliedMode(StateAttribute::GLMode mode) const;
|
||||
|
||||
/** Get the current specified attribute, return NULL if one has not yet been applied.*/
|
||||
/** Get the current specified attribute, return NULL if one has not yet been applied.*/
|
||||
const StateAttribute* getLastAppliedAttribute(StateAttribute::Type type, unsigned int member=0) const;
|
||||
|
||||
/** texture Mode has been set externally, update state to reflect this setting.*/
|
||||
void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
|
||||
|
||||
/** texture Mode has been set externally, therefore dirty the associated mode in osg::State
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode);
|
||||
|
||||
/** texture Attribute has been applied externally, update state to reflect this setting.*/
|
||||
void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute* attribute);
|
||||
|
||||
/** texture Attribute has been applied externally,
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-applied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
* then use the have_applied(attribute) method as this will the osg::State to
|
||||
* track the current state more accurately and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-applied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
* then use the have_applied(attribute) method as this will the osg::State to
|
||||
* track the current state more accurately and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0);
|
||||
|
||||
/** Get whether the current specified texture mode is enabled (true) or disabled (false).*/
|
||||
@@ -456,18 +456,18 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
inline void unbindPixelBufferObject()
|
||||
{
|
||||
if (!_currentPBO) return;
|
||||
|
||||
|
||||
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,0);
|
||||
_currentPBO = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
|
||||
{
|
||||
if (primcount>=1 && _glDrawArraysInstanced!=0) _glDrawArraysInstanced(mode, first, count, primcount);
|
||||
else glDrawArrays(mode, first, count);
|
||||
}
|
||||
|
||||
|
||||
inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount )
|
||||
{
|
||||
if (primcount>=1 && _glDrawElementsInstanced!=0) _glDrawElementsInstanced(mode, count, type, indices, primcount);
|
||||
@@ -476,8 +476,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** Wrapper around glInterleavedArrays(..).
|
||||
* also resets the internal array points and modes within osg::State to keep the other
|
||||
* vertex array operations consistent. */
|
||||
* also resets the internal array points and modes within osg::State to keep the other
|
||||
* vertex array operations consistent. */
|
||||
void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer);
|
||||
|
||||
/** Set the vertex pointer using an osg::Array, and manage any VBO that are required.*/
|
||||
@@ -487,7 +487,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
setVertexPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset());
|
||||
}
|
||||
@@ -501,9 +501,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void setVertexPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (!_vertexArray._enabled || _vertexArray._dirty)
|
||||
{
|
||||
@@ -519,7 +519,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_VERTEX_ARRAY).
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableVertexPointer()
|
||||
{
|
||||
if (_vertexArray._enabled || _vertexArray._dirty)
|
||||
@@ -544,9 +544,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
setNormalPointer(array->getDataType(),0,array->getVertexBufferObjectOffset());
|
||||
setNormalPointer(array->getDataType(),0,array->getVertexBufferObjectOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -558,9 +558,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void setNormalPointer( GLenum type, GLsizei stride,
|
||||
const GLvoid *ptr )
|
||||
const GLvoid *ptr )
|
||||
{
|
||||
if (!_normalArray._enabled || _normalArray._dirty)
|
||||
{
|
||||
@@ -576,7 +576,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_NORMAL_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableNormalPointer()
|
||||
{
|
||||
if (_normalArray._enabled || _normalArray._dirty)
|
||||
@@ -600,7 +600,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
setColorPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset());
|
||||
}
|
||||
@@ -615,9 +615,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** wrapper around glEnableClientState(GL_COLOR_ARRAY);glColorPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void setColorPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (!_colorArray._enabled || _colorArray._dirty)
|
||||
{
|
||||
@@ -633,7 +633,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_COLOR_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableColorPointer()
|
||||
{
|
||||
if (_colorArray._enabled || _colorArray._dirty)
|
||||
@@ -661,9 +661,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
#if 0
|
||||
#if 0
|
||||
setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex()));
|
||||
#else
|
||||
setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset());
|
||||
@@ -679,11 +679,11 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_SECONDARY_COLOR_ARRAY);glSecondayColorPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
void setSecondaryColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr );
|
||||
|
||||
/** wrapper around glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableSecondaryColorPointer()
|
||||
{
|
||||
if (_secondaryColorArray._enabled || _secondaryColorArray._dirty)
|
||||
@@ -701,9 +701,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_INDEX_ARRAY);glIndexPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void setIndexPointer( GLenum type, GLsizei stride,
|
||||
const GLvoid *ptr )
|
||||
const GLvoid *ptr )
|
||||
{
|
||||
if (!_indexArray._enabled || _indexArray._dirty)
|
||||
{
|
||||
@@ -719,7 +719,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_INDEX_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableIndexPointer()
|
||||
{
|
||||
if (_indexArray._enabled || _indexArray._dirty)
|
||||
@@ -747,7 +747,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
#if 0
|
||||
setFogCoordPointer(array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex()));
|
||||
@@ -766,11 +766,11 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** wrapper around glEnableClientState(GL_FOG_COORDINATE_ARRAY);glFogCoordPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
void setFogCoordPointer( GLenum type, GLsizei stride, const GLvoid *ptr );
|
||||
|
||||
/** wrapper around glDisableClientState(GL_FOG_COORDINATE_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableFogCoordPointer()
|
||||
{
|
||||
if (_fogArray._enabled || _fogArray._dirty)
|
||||
@@ -796,7 +796,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
#if 0
|
||||
setTexCoordPointer(unit, array->getDataSize(),array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex()));
|
||||
@@ -814,7 +814,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void setTexCoordPointer( unsigned int unit,
|
||||
GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
@@ -839,7 +839,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
inline void disableTexCoordPointer( unsigned int unit )
|
||||
{
|
||||
if (setClientActiveTextureUnit(unit))
|
||||
@@ -896,16 +896,16 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** Set the current texture unit, return true if selected,
|
||||
* false if selection failed such as when multi texturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
* false if selection failed such as when multi texturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
bool setActiveTextureUnit( unsigned int unit );
|
||||
|
||||
|
||||
/** Get the current texture unit.*/
|
||||
unsigned int getActiveTextureUnit() const { return _currentActiveTextureUnit; }
|
||||
|
||||
/** Set the current tex coord array texture unit, return true if selected,
|
||||
* false if selection failed such as when multi texturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
* false if selection failed such as when multi texturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
bool setClientActiveTextureUnit( unsigned int unit );
|
||||
|
||||
/** Get the current tex coord array texture unit.*/
|
||||
@@ -918,9 +918,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
const VertexBufferObject* vbo = array->getVertexBufferObject();
|
||||
if (vbo)
|
||||
{
|
||||
{
|
||||
bindVertexBufferObject(vbo);
|
||||
#if 0
|
||||
#if 0
|
||||
setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),normalized,0,vbo->getOffset(array->getVertexBufferObjectIndex()));
|
||||
#else
|
||||
setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),normalized,0,array->getVertexBufferObjectOffset());
|
||||
@@ -936,13 +936,13 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
/** wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(..);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
void setVertexAttribPointer( unsigned int index,
|
||||
GLint size, GLenum type, GLboolean normalized,
|
||||
GLsizei stride, const GLvoid *ptr );
|
||||
GLint size, GLenum type, GLboolean normalized,
|
||||
GLsizei stride, const GLvoid *ptr );
|
||||
|
||||
/** wrapper around DisableVertexAttribArrayARB(index);
|
||||
* note, only updates values that change.*/
|
||||
* note, only updates values that change.*/
|
||||
void disableVertexAttribPointer( unsigned int index );
|
||||
|
||||
void disableVertexAttribPointersAboveAndIncluding( unsigned int index );
|
||||
@@ -965,10 +965,10 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
if (_lastAppliedProgramObject!=program)
|
||||
{
|
||||
_lastAppliedProgramObject = program;
|
||||
_lastAppliedProgramObject = program;
|
||||
if (program && _appliedProgramObjectSet.count(program)==0)
|
||||
{
|
||||
_appliedProgramObjectSet.insert(program);
|
||||
_appliedProgramObjectSet.insert(program);
|
||||
program->addObserver(this);
|
||||
}
|
||||
}
|
||||
@@ -998,8 +998,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** Set the DisplaySettings. Note, nothing is applied, the visual settings are just
|
||||
* used in the State object to pass the current visual settings to Drawables
|
||||
* during rendering. */
|
||||
* used in the State object to pass the current visual settings to Drawables
|
||||
* during rendering. */
|
||||
inline void setDisplaySettings(DisplaySettings* vs) { _displaySettings = vs; }
|
||||
|
||||
/** Get the DisplaySettings */
|
||||
@@ -1011,7 +1011,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
void setAbortRenderingPtr(bool* abortPtr) { _abortRenderingPtr = abortPtr; }
|
||||
|
||||
/** Get flag for early termination of the draw traversal,
|
||||
* if true steps should be taken to complete rendering early.*/
|
||||
* if true steps should be taken to complete rendering early.*/
|
||||
bool getAbortRendering() const { return _abortRenderingPtr!=0?(*_abortRenderingPtr):false; }
|
||||
|
||||
|
||||
@@ -1019,13 +1019,13 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
virtual void completed(osg::State*) = 0;
|
||||
};
|
||||
|
||||
|
||||
/** Set the callback to be called when the dynamic object count hits 0.*/
|
||||
void setDynamicObjectRenderingCompletedCallback(DynamicObjectRenderingCompletedCallback* cb){ _completeDynamicObjectRenderingCallback = cb; }
|
||||
|
||||
|
||||
/** Get the callback to be called when the dynamic object count hits 0.*/
|
||||
DynamicObjectRenderingCompletedCallback* getDynamicObjectRenderingCompletedCallback() { return _completeDynamicObjectRenderingCallback.get(); }
|
||||
|
||||
|
||||
/** Set the number of dynamic objects that will be rendered in this graphics context this frame.*/
|
||||
void setDynamicObjectCount(unsigned int count, bool callCallbackOnZero = false)
|
||||
{
|
||||
@@ -1041,9 +1041,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
/** Get the number of dynamic objects that will be rendered in this graphics context this frame.*/
|
||||
unsigned int getDynamicObjectCount() const { return _dynamicObjectCount; }
|
||||
|
||||
/** Decrement the number of dynamic objects left to render this frame, and once the count goes to zero call the
|
||||
* DynamicObjectRenderingCompletedCallback to inform of completion.*/
|
||||
|
||||
/** Decrement the number of dynamic objects left to render this frame, and once the count goes to zero call the
|
||||
* DynamicObjectRenderingCompletedCallback to inform of completion.*/
|
||||
inline void decrementDynamicObjectCount()
|
||||
{
|
||||
--_dynamicObjectCount;
|
||||
@@ -1051,13 +1051,22 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
{
|
||||
_completeDynamicObjectRenderingCallback->completed(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setMaxTexturePoolSize(unsigned int size);
|
||||
unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
|
||||
|
||||
void setMaxVBOPoolSize(unsigned int size);
|
||||
unsigned int getMaxVBOPoolSize() const { return _maxVBOPoolSize; }
|
||||
|
||||
void setMaxFBOPoolSize(unsigned int size);
|
||||
unsigned int getMaxFBOPoolSize() const { return _maxFBOPoolSize; }
|
||||
|
||||
|
||||
|
||||
enum CheckForGLErrors
|
||||
{
|
||||
/** NEVER_CHECK_GL_ERRORS hints that OpenGL need not be checked for, this
|
||||
/** NEVER_CHECK_GL_ERRORS hints that OpenGL need not be checked for, this
|
||||
is the fastest option since checking for errors does incurr a small overhead.*/
|
||||
NEVER_CHECK_GL_ERRORS,
|
||||
/** ONCE_PER_FRAME means that OpenGl errors will be checked for once per
|
||||
@@ -1154,13 +1163,13 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
|
||||
/** Apply an OpenGL mode if required, passing in mode, enable flag and
|
||||
* appropriate mode stack. This is a wrapper around \c glEnable() and
|
||||
* \c glDisable(), that just actually calls these functions if the
|
||||
* \c enabled flag is different than the current state.
|
||||
* @return \c true if the state was actually changed. \c false
|
||||
* otherwise. Notice that a \c false return does not indicate
|
||||
* an error, it just means that the mode was already set to the
|
||||
* same value as the \c enabled parameter.
|
||||
* appropriate mode stack. This is a wrapper around \c glEnable() and
|
||||
* \c glDisable(), that just actually calls these functions if the
|
||||
* \c enabled flag is different than the current state.
|
||||
* @return \c true if the state was actually changed. \c false
|
||||
* otherwise. Notice that a \c false return does not indicate
|
||||
* an error, it just means that the mode was already set to the
|
||||
* same value as the \c enabled parameter.
|
||||
*/
|
||||
inline bool applyMode(StateAttribute::GLMode mode,bool enabled,ModeStack& ms)
|
||||
{
|
||||
@@ -1224,7 +1233,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
typedef std::map<std::string,UniformStack> UniformMap;
|
||||
|
||||
typedef std::vector<ref_ptr<const Matrix> > MatrixStack;
|
||||
|
||||
|
||||
typedef std::set<const Program::PerContextProgram* > AppliedProgramObjectSet;
|
||||
|
||||
ModeMap _modeMap;
|
||||
@@ -1239,6 +1248,11 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
StateSetStack _stateStateStack;
|
||||
|
||||
unsigned int _maxTexturePoolSize;
|
||||
unsigned int _maxVBOPoolSize;
|
||||
unsigned int _maxFBOPoolSize;
|
||||
|
||||
|
||||
struct EnabledArrayPair
|
||||
{
|
||||
EnabledArrayPair():_dirty(true),_enabled(false),_normalized(0),_pointer(0) {}
|
||||
@@ -1326,7 +1340,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
typedef void (APIENTRY * EnableVertexAttribProc) (unsigned int);
|
||||
typedef void (APIENTRY * DisableVertexAttribProc) (unsigned int);
|
||||
typedef void (APIENTRY * BindBufferProc) (GLenum target, GLuint buffer);
|
||||
|
||||
|
||||
typedef void (APIENTRY * DrawArraysInstancedProc)( GLenum mode, GLint first, GLsizei count, GLsizei primcount );
|
||||
typedef void (APIENTRY * DrawElementsInstancedProc)( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount );
|
||||
|
||||
@@ -1346,7 +1360,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
unsigned int _dynamicObjectCount;
|
||||
osg::ref_ptr<DynamicObjectRenderingCompletedCallback> _completeDynamicObjectRenderingCallback;
|
||||
|
||||
|
||||
};
|
||||
|
||||
inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
|
||||
|
||||
Reference in New Issue
Block a user