Merge remote-tracking branch 'upstream/master' into MDI7

This commit is contained in:
Julien Valentin
2017-08-24 11:26:23 +02:00
108 changed files with 2569 additions and 415 deletions

View File

@@ -1,6 +1,7 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
* Copyright (C) 2010 Tim Moore
* Copyright (C) 2012 David Callu
* Copyright (C) 2017 Julien Valentin
*
* 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
@@ -40,53 +41,67 @@ class OSG_EXPORT BufferIndexBinding : public StateAttribute
{
protected:
BufferIndexBinding(GLenum target, GLuint index);
BufferIndexBinding(GLenum target, GLuint index, BufferObject* bo, GLintptr offset,
GLsizeiptr size);
BufferIndexBinding(GLenum target, GLuint index, BufferData* bd, GLintptr offset=0, GLsizeiptr size=0);
BufferIndexBinding(const BufferIndexBinding& rhs, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
public:
// The member value is part of the key to this state attribute in
// the State class. Using the index target, we can separately
// track the bindings for many different index targets.
virtual unsigned getMember() const { return static_cast<unsigned int>(_index); }
GLenum getTarget() const { return _target; }
///enable arbitrary BufferBinding (user is responsible for _target mismatch with bufferdata
/// what can be done is setting wrong _target and use the one of bd if not subclassed
void setTarget(GLenum t){_target=t;}
/** Set the renderbuffer index of the BlendEquationi. */
void setIndex(unsigned int index);
inline void setBufferData(BufferData *bufferdata) {
if (_bufferData.valid())
{
_bufferData->removeClient(this);
}
_bufferData=bufferdata;
if (_bufferData.valid())
{
if(!_bufferData->getBufferObject())
_bufferData->setBufferObject(new VertexBufferObject());
if(_size==0)
_size=_bufferData->getTotalDataSize();
}
}
/** Get the buffer data to be bound.
*/
inline const BufferData* getBufferData() const { return _bufferData.get(); }
inline BufferData* getBufferData(){ return _bufferData.get(); }
/** Get the index target.
*/
unsigned int getIndex() const { return _index; }
/** Set the buffer object that will be bound to the index target.
inline GLuint getIndex() const { return _index; }
/** Set the index target. (and update parents StateSets)
*/
void setBufferObject(BufferObject *bo) { _bufferObject = bo; }
void setIndex(GLuint index);
/** Get the buffer object to be bound.
*/
const BufferObject* getBufferObject() const { return _bufferObject.get(); }
BufferObject* getBufferObject(){ return _bufferObject.get(); }
/** Set the starting offset into the buffer object for data for
/** Set the starting offset into the buffer data for
the indexed target. Note: the required alignment on the offset
may be quite large (e.g., 256 bytes on NVidia 8600M). This
should be checked with glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT...).
*/
void setOffset(GLintptr offset) { _offset = offset; }
GLintptr getOffset() const { return _offset; }
inline void setOffset(GLintptr offset) { _offset = offset; }
inline GLintptr getOffset() const { return _offset; }
/** Set the size of data for the indexed target.
/** Set the size override of bufferdata binded for the indexed target.
*/
void setSize(GLsizeiptr size) { _size = size; }
GLsizeiptr getSize() const { return _size; }
inline void setSize(GLsizeiptr size) { _size = size; }
inline GLsizeiptr getSize() const { return _size; }
virtual void apply(State& state) const;
protected:
virtual ~BufferIndexBinding();
const GLenum _target;
/*const*/ GLenum _target;
ref_ptr<BufferData> _bufferData;
GLuint _index;
ref_ptr<BufferObject> _bufferObject;
GLintptr _offset;
GLsizeiptr _size;
};
@@ -100,21 +115,20 @@ class OSG_EXPORT UniformBufferBinding : public BufferIndexBinding
UniformBufferBinding(GLuint index);
/** Create a binding for a uniform buffer index target.
* @param index the index target
* @param bo associated buffer object
* @param offset offset into buffer object
* @param size size of data in buffer object
* @param bd associated buffer data
* @param offset offset into buffer data
* @param size size of data in buffer data
*/
UniformBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
UniformBufferBinding(GLuint index, BufferData* bd, GLintptr offset=0, GLsizeiptr size=0);
UniformBufferBinding(const UniformBufferBinding& rhs, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, UniformBufferBinding, UNIFORMBUFFERBINDING);
virtual int compare(const StateAttribute& bb) const
{
COMPARE_StateAttribute_Types(UniformBufferBinding, bb)
COMPARE_StateAttribute_Parameter(_target)
COMPARE_StateAttribute_Parameter(_index)
COMPARE_StateAttribute_Parameter(_bufferObject)
COMPARE_StateAttribute_Parameter(_bufferData)
COMPARE_StateAttribute_Parameter(_offset)
COMPARE_StateAttribute_Parameter(_size)
return 0;
@@ -127,17 +141,16 @@ class OSG_EXPORT TransformFeedbackBufferBinding : public BufferIndexBinding
{
public:
TransformFeedbackBufferBinding(GLuint index = 0);
TransformFeedbackBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
TransformFeedbackBufferBinding(GLuint index, BufferData* bd, GLintptr offset=0, GLsizeiptr size=0);
TransformFeedbackBufferBinding(const TransformFeedbackBufferBinding& rhs, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, TransformFeedbackBufferBinding, TRANSFORMFEEDBACKBUFFERBINDING);
virtual int compare(const StateAttribute& bb) const
{
COMPARE_StateAttribute_Types(TransformFeedbackBufferBinding, bb)
COMPARE_StateAttribute_Parameter(_target)
COMPARE_StateAttribute_Parameter(_index)
COMPARE_StateAttribute_Parameter(_bufferObject)
COMPARE_StateAttribute_Parameter(_bufferData)
COMPARE_StateAttribute_Parameter(_offset)
COMPARE_StateAttribute_Parameter(_size)
return 0;
@@ -152,11 +165,11 @@ class OSG_EXPORT AtomicCounterBufferBinding : public BufferIndexBinding
AtomicCounterBufferBinding(GLuint index=0);
/** Create a binding for a atomic counter buffer index target.
* @param index the index target
* @param bo associated buffer object
* @param offset offset into buffer object
* @param size size of data in buffer object
* @param bd associated buffer data
* @param offset offset into buffer data
* @param size size of data in buffer data
*/
AtomicCounterBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
AtomicCounterBufferBinding(GLuint index, BufferData* bd, GLintptr offset=0, GLsizeiptr size=0);
AtomicCounterBufferBinding(const AtomicCounterBufferBinding& rhs, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, AtomicCounterBufferBinding, ATOMICCOUNTERBUFFERBINDING);
@@ -165,10 +178,9 @@ class OSG_EXPORT AtomicCounterBufferBinding : public BufferIndexBinding
virtual int compare(const StateAttribute& bb) const
{
COMPARE_StateAttribute_Types(AtomicCounterBufferBinding, bb)
COMPARE_StateAttribute_Parameter(_target)
COMPARE_StateAttribute_Parameter(_index)
COMPARE_StateAttribute_Parameter(_bufferObject)
COMPARE_StateAttribute_Parameter(_bufferData)
COMPARE_StateAttribute_Parameter(_offset)
COMPARE_StateAttribute_Parameter(_size)
return 0;
@@ -181,11 +193,11 @@ class OSG_EXPORT ShaderStorageBufferBinding : public BufferIndexBinding
ShaderStorageBufferBinding(GLuint index=0);
/** Create a binding for a shader storage buffer index target.
* @param index the index target
* @param bo associated buffer object
* @param offset offset into buffer object
* @param size size of data in buffer object
* @param bd associated buffer data
* @param offset offset into buffer data
* @param size size of data in buffer data
*/
ShaderStorageBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
ShaderStorageBufferBinding(GLuint index, BufferData* bd, GLintptr offset=0, GLsizeiptr size=0);
ShaderStorageBufferBinding(const ShaderStorageBufferBinding& rhs, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, ShaderStorageBufferBinding, SHADERSTORAGEBUFFERBINDING);
@@ -194,7 +206,7 @@ class OSG_EXPORT ShaderStorageBufferBinding : public BufferIndexBinding
COMPARE_StateAttribute_Types(ShaderStorageBufferBinding, bb)
COMPARE_StateAttribute_Parameter(_target)
COMPARE_StateAttribute_Parameter(_index)
COMPARE_StateAttribute_Parameter(_bufferObject)
COMPARE_StateAttribute_Parameter(_bufferData)
COMPARE_StateAttribute_Parameter(_offset)
COMPARE_StateAttribute_Parameter(_size)
return 0;

View File

@@ -72,7 +72,7 @@ class OSG_EXPORT Callback : public virtual Object {
/** Invoke the callback, first parameter is the Object that the callback is attached to,
* the second parameter, the data, is typically the NodeVisitor that is invoking the callback.
* The run(..) method may be overriden by users directly, or if the user is using one of the old
* The run(..) method may be overridden by users directly, or if the user is using one of the old
* style callbacks such as NodeCallback or Drawable::UpdateCallback then you can just override
* the appropriate callback method on those callback subclasses.
* If you are implementing your own callback then one should call traverse() to make sure nested callbacks

View File

@@ -692,10 +692,6 @@ namespace osg
#endif
#endif
#endif
#if defined(OSG_GLES1_FEATURES) || defined(OSG_GLES2_FEATURES)|| defined(OSG_GLES3_FEATURES)
typedef double GLclampd;
#endif
}
#endif

View File

@@ -557,7 +557,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
bool isSGIXMinMaxSupported;
bool isLogicOpSupported;
void (GL_APIENTRY * glBlendColor) (GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha);
void (GL_APIENTRY * glBlendColor) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void (GL_APIENTRY * glBlendEquation)(GLenum mode);
void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
void (GL_APIENTRY * glBlendEquationi)(GLuint buf, GLenum mode);
@@ -599,7 +599,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
bool isMultisampleSupported;
bool isMultisampleFilterHintSupported;
void (GL_APIENTRY * glSampleCoverage) (GLclampf value, GLboolean invert);
void (GL_APIENTRY * glSampleCoverage) (GLfloat value, GLboolean invert);
// Point
@@ -725,8 +725,9 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
void (GL_APIENTRY * glScissorArrayv) (GLuint first, GLsizei count, const GLint * v);
void (GL_APIENTRY * glScissorIndexed) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
void (GL_APIENTRY * glScissorIndexedv) (GLuint index, const GLint * v);
void (GL_APIENTRY * glDepthRangeArrayv) (GLuint first, GLsizei count, const GLclampd * v);
void (GL_APIENTRY * glDepthRangeIndexed) (GLuint index, GLclampd n, GLclampd f);
void (GL_APIENTRY * glDepthRangeArrayv) (GLuint first, GLsizei count, const GLdouble * v);
void (GL_APIENTRY * glDepthRangeIndexed) (GLuint index, GLdouble n, GLdouble f);
void (GL_APIENTRY * glDepthRangeIndexedf) (GLuint index, GLfloat n, GLfloat f);
void (GL_APIENTRY * glGetFloati_v) (GLenum target, GLuint index, GLfloat *data);
void (GL_APIENTRY * glGetDoublei_v) (GLenum target, GLuint index, GLdouble *data);
@@ -747,7 +748,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
// debug extensions
void (GL_APIENTRY * glObjectLabel) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label);
/** convinience wrapper around glObjectLabel that calls glObjectLabel if it's supported and using std::string as a label parameter.*/
/** convenience wrapper around glObjectLabel that calls glObjectLabel if it's supported and using std::string as a label parameter.*/
void debugObjectLabel(GLenum identifier, GLuint name, const std::string& label) const { if (glObjectLabel && !label.empty()) glObjectLabel(identifier, name, label.size(), label.c_str()); }
};

View File

@@ -129,7 +129,7 @@ class OSG_EXPORT Geometry : public Drawable
unsigned int getPrimitiveSetIndex(const PrimitiveSet* primitiveset) const;
/** Convinience method that checks all the vertex arrays to make sure that the buffer objects are all assigned appropriate.*/
/** Convenience method that checks all the vertex arrays to make sure that the buffer objects are all assigned appropriate.*/
void configureBufferObjects();
/** return true if any arrays are shared.*/
@@ -279,7 +279,7 @@ class OSG_EXPORT Geometry : public Drawable
#endif
};
/** Convinience visitor for making sure that any BufferObjects that might be required are set up in the scene graph.*/
/** Convenience visitor for making sure that any BufferObjects that might be required are set up in the scene graph.*/
class ConfigureBufferObjectsVisitor : public osg::NodeVisitor
{
public:

View File

@@ -242,6 +242,12 @@ class OSG_EXPORT Matrixd
/** full 4x4 matrix invert. */
bool invert_4x4( const Matrixd& rhs);
/** transpose a matrix */
bool transpose(const Matrixd&rhs);
/** transpose orthogonal part of the matrix **/
bool transpose3x3(const Matrixd&rhs);
/** ortho-normalize the 3x3 rotation & scale matrix */
void orthoNormalize(const Matrixd& rhs);

View File

@@ -242,6 +242,12 @@ class OSG_EXPORT Matrixf
/** full 4x4 matrix invert. */
bool invert_4x4( const Matrixf& rhs);
/** transpose matrix **/
bool transpose(const Matrixf&rhs);
/** transpose orthogonal part of the matrix **/
bool transpose3x3(const Matrixf&rhs);
/** ortho-normalize the 3x3 rotation & scale matrix */
void orthoNormalize(const Matrixf& rhs);

View File

@@ -747,7 +747,7 @@ class TessellationHints : public Object
// forward declare;
class Geometry;
/** Convinience class for populating an Geomtry with vertex, normals, texture coords and primitives that can render a Shape. */
/** Convenience class for populating an Geomtry with vertex, normals, texture coords and primitives that can render a Shape. */
class OSG_EXPORT BuildShapeGeometryVisitor : public ConstShapeVisitor
{
public:

View File

@@ -1502,7 +1502,7 @@ inline void State::pushDefineList(DefineMap& defineMap,const StateSet::DefineLis
dv.push_back(StateSet::DefinePair(aitr->second.first,aitr->second.second));
// if the back of the stack has changed since the last then mark it as changed.
bool changed = (dv[dv.size()-2].first==dv[dv.size()-1].first);
bool changed = (dv[dv.size()-2] != dv.back());
if (changed)
{
ds.changed = true;
@@ -1571,7 +1571,7 @@ inline void State::popDefineList(DefineMap& defineMap,const StateSet::DefineList
if (!dv.empty())
{
// if the stack has less than 2 entries or new back vs old back are different then mark the DefineStack as changed
if ((dv.size()<2) || (dv[dv.size()-2].first!=dv.back().first))
if ((dv.size() < 2) || (dv[dv.size()-2] != dv.back()))
{
ds.changed = true;
defineMap.changed = true;

View File

@@ -56,7 +56,7 @@ class OSG_EXPORT Timer {
inline double time_n() const { return delta_n(_startTick, tick()); }
/** Get the time in seconds between timer ticks t1 and t2.*/
inline double delta_s( Timer_t t1, Timer_t t2 ) const { return (double)(t2 - t1)*_secsPerTick; }
inline double delta_s( Timer_t t1, Timer_t t2 ) const { return (t2>t1) ? (double)(t2 - t1)*_secsPerTick : -(double)(t1 - t2)*_secsPerTick; }
/** Get the time in milliseconds between timer ticks t1 and t2.*/
inline double delta_m( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e3; }

View File

@@ -39,7 +39,7 @@ namespace osgParticle
virtual const char* className() const { return "Interpolator"; }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Interpolator* >(obj) != 0; }
/// Interpolate between floats. Must be overriden in descendant classes.
/// Interpolate between floats. Must be overridden in descendant classes.
virtual float interpolate(float t, float y1, float y2) const = 0;
/// Interpolate between 2-dimensional vectors. Default behavior is to interpolate each component separately.

View File

@@ -50,7 +50,7 @@ namespace osgParticle
/// Implementation of <CODE>ParticleProcessor::process()</CODE>. Do not call this method by yourself.
inline void process(double dt);
/// Execute the program on the particle system. Must be overriden in descendant classes.
/// Execute the program on the particle system. Must be overridden in descendant classes.
virtual void execute(double dt) = 0;
private:

View File

@@ -36,7 +36,7 @@ namespace osgParticle
virtual const char* className() const { return "Shooter"; }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Shooter *>(obj) != 0; }
/** Shoot a particle. Must be overriden by descendants.
/** Shoot a particle. Must be overridden by descendants.
This method should only set the velocity vector of particle <CODE>P</CODE>, leaving other
attributes unchanged.
*/

View File

@@ -28,12 +28,12 @@
namespace osgShadow {
/**
Class used as a layer for debuging resources used by derived xxxShadowMap classes.
Class used as a layer for debugging resources used by derived xxxShadowMap classes.
As designed by its base ViewDepndentShadowTechnique, DebugShadowMap serves mainly as container of
DebugShadowMap::ViewData objects. Most of the debuging support work is done by these objects.
DebugShadowMap::ViewData objects. Most of the debugging support work is done by these objects.
DebugShadowMap technique only initializes them in initViewDependentData method.
Debuging outputs present:
Debugging outputs present:
Shadow maps (pseudo colored to improve readability)
Shadow and related volumes (represented as convex polyhedra)
*/
@@ -65,16 +65,16 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
/** Declaration of standard OSG object methods */
META_Object( osgShadow, DebugShadowMap );
/** Turn on/off debuging hud & rendering of debug volumes in main view */
/** Turn on/off debugging hud & rendering of debug volumes in main view */
void setDebugDraw( bool draw ) { _doDebugDraw = draw; }
/** Tell if debuging hud & rendering of debug volumes is active */
/** Tell if debugging hud & rendering of debug volumes is active */
bool getDebugDraw( void ) const { return _doDebugDraw; }
/** Get the file name of debuging dump */
/** Get the file name of debugging dump */
std::string getDebugDump( void ) const { return _debugDump; }
/** Set the file name of debuging dump */
/** Set the file name of debugging dump */
void setDebugDump( const std::string & debugDumpFile ) { _debugDump = debugDumpFile; }

View File

@@ -111,7 +111,7 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
class OSGSHADOW_EXPORT FragmentShaderGenerator : public osg::Referenced {
public:
/**
* generate the GLSL fragement shader
* generate the GLSL fragment shader
*/
virtual std::string generateGLSL_FragmentShader_BaseTex(bool debug, unsigned int splitCount,double textureRes, bool filtered, unsigned int nbrSplits,unsigned int textureOffset);
};

View File

@@ -82,13 +82,13 @@ class OSGTEXT_EXPORT Text3D : public osgText::TextBase
/** return true, osgText::Text does support accept(ConstAttributeFunctor&).*/
virtual bool supports(const osg::Drawable::ConstAttributeFunctor&) const { return false; }
/** accept an ConstAttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
/** accept an ConstAttributeFunctor and call its methods to tell it about the internal attributes that this Drawable has.*/
virtual void accept(osg::Drawable::ConstAttributeFunctor& af) const;
/** return true, osgText::Text does support accept(PrimitiveFunctor&) .*/
virtual bool supports(const osg::PrimitiveFunctor&) const { return false; }
/** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
/** accept a PrimtiveFunctor and call its methods to tell it about the internal primtives that this Drawable has.*/
virtual void accept(osg::PrimitiveFunctor& pf) const;
/** Resize any per context GLObject buffers to specified size. */

View File

@@ -325,12 +325,12 @@ protected:
osg::Vec4 _textBBColor;
KerningType _kerningType;
unsigned int _lineCount;
bool _glyphNormalized;
osg::Vec3 _offset;
osg::Vec3 _normal;
osg::BoundingBox _textBB;
mutable osg::Matrix _matrix;
Primitives _decorationPrimitives;

View File

@@ -31,7 +31,7 @@ class OSGUTIL_EXPORT DrawElementTypeSimplifier
class OSGUTIL_EXPORT DrawElementTypeSimplifierVisitor : public osg::NodeVisitor
{
public:
DrawElementTypeSimplifierVisitor(): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ) {}
META_NodeVisitor(osgUtil, DrawElementTypeSimplifierVisitor);
void apply(osg::Geometry& geom);

View File

@@ -460,8 +460,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
/** Do init traversal of the attached scene graph using Init NodeVisitor.
* The init traversal is called once for each SceneView, and should
* be used to compile display lists, texture objects and intialize data
* not otherwise intialized during scene graph loading. Note, is
* be used to compile display lists, texture objects and initialize data
* not otherwise initialized during scene graph loading. Note, is
* called automatically by update & cull if it hasn't already been called
* elsewhere. Also init() should only ever be called within a valid
* graphics context.*/

View File

@@ -37,6 +37,7 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow, pub
_parent(0),
_window(0),
_visualInfo(0),
_fbConfig(0),
#ifdef OSG_USE_EGL
_eglDisplay(0),
_eglSurface(0),
@@ -176,6 +177,7 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow, pub
Window _parent;
Window _window;
XVisualInfo* _visualInfo;
GLXFBConfig _fbConfig;
#ifdef OSG_USE_EGL
EGLDisplay _eglDisplay;