Added support for new double Vec*Array classes in various functors.

This commit is contained in:
Robert Osfield 2007-12-04 14:46:46 +00:00
parent 8a4caa0a59
commit 1b1c5bbdd1
10 changed files with 396 additions and 71 deletions

View File

@ -501,6 +501,11 @@ class OSG_EXPORT Drawable : public Object
virtual void apply(AttributeType,unsigned int,Vec3*) {} virtual void apply(AttributeType,unsigned int,Vec3*) {}
virtual void apply(AttributeType,unsigned int,Vec4*) {} virtual void apply(AttributeType,unsigned int,Vec4*) {}
virtual void apply(AttributeType,unsigned int,Vec4ub*) {} virtual void apply(AttributeType,unsigned int,Vec4ub*) {}
virtual void apply(AttributeType,unsigned int,double*) {}
virtual void apply(AttributeType,unsigned int,Vec2d*) {}
virtual void apply(AttributeType,unsigned int,Vec3d*) {}
virtual void apply(AttributeType,unsigned int,Vec4d*) {}
}; };
@ -532,6 +537,11 @@ class OSG_EXPORT Drawable : public Object
virtual void apply(AttributeType,unsigned int,const Vec3*) {} virtual void apply(AttributeType,unsigned int,const Vec3*) {}
virtual void apply(AttributeType,unsigned int,const Vec4*) {} virtual void apply(AttributeType,unsigned int,const Vec4*) {}
virtual void apply(AttributeType,unsigned int,const Vec4ub*) {} virtual void apply(AttributeType,unsigned int,const Vec4ub*) {}
virtual void apply(AttributeType,unsigned int,const double*) {}
virtual void apply(AttributeType,unsigned int,const Vec2d*) {}
virtual void apply(AttributeType,unsigned int,const Vec3d*) {}
virtual void apply(AttributeType,unsigned int,const Vec4d*) {}
}; };
/** Return true if the Drawable subclass supports accept(ConstAttributeFunctor&).*/ /** Return true if the Drawable subclass supports accept(ConstAttributeFunctor&).*/
@ -608,11 +618,20 @@ class OSG_EXPORT Drawable : public Object
void glMultiTexCoord3fv(GLenum target,const GLfloat* coord) const; void glMultiTexCoord3fv(GLenum target,const GLfloat* coord) const;
void glMultiTexCoord4fv(GLenum target,const GLfloat* coord) const; void glMultiTexCoord4fv(GLenum target,const GLfloat* coord) const;
void glMultiTexCoord1d(GLenum target,GLdouble coord) const;
void glMultiTexCoord2dv(GLenum target,const GLdouble* coord) const;
void glMultiTexCoord3dv(GLenum target,const GLdouble* coord) const;
void glMultiTexCoord4dv(GLenum target,const GLdouble* coord) const;
void glVertexAttrib1s(unsigned int index, GLshort s) const; void glVertexAttrib1s(unsigned int index, GLshort s) const;
void glVertexAttrib1f(unsigned int index, GLfloat f) const; void glVertexAttrib1f(unsigned int index, GLfloat f) const;
void glVertexAttrib1d(unsigned int index, GLdouble f) const;
void glVertexAttrib2fv(unsigned int index, const GLfloat * v) const; void glVertexAttrib2fv(unsigned int index, const GLfloat * v) const;
void glVertexAttrib3fv(unsigned int index, const GLfloat * v) const; void glVertexAttrib3fv(unsigned int index, const GLfloat * v) const;
void glVertexAttrib4fv(unsigned int index, const GLfloat * v) const; void glVertexAttrib4fv(unsigned int index, const GLfloat * v) const;
void glVertexAttrib2dv(unsigned int index, const GLdouble * v) const;
void glVertexAttrib3dv(unsigned int index, const GLdouble * v) const;
void glVertexAttrib4dv(unsigned int index, const GLdouble * v) const;
void glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const; void glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const;
void glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const; void glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const;
@ -654,7 +673,9 @@ class OSG_EXPORT Drawable : public Object
typedef void (APIENTRY * VertexAttrib1sProc) (unsigned int index, GLshort s); typedef void (APIENTRY * VertexAttrib1sProc) (unsigned int index, GLshort s);
typedef void (APIENTRY * VertexAttrib1fProc) (unsigned int index, GLfloat f); typedef void (APIENTRY * VertexAttrib1fProc) (unsigned int index, GLfloat f);
typedef void (APIENTRY * VertexAttrib1dProc) (unsigned int index, GLdouble f);
typedef void (APIENTRY * VertexAttribfvProc) (unsigned int index, const GLfloat * v); typedef void (APIENTRY * VertexAttribfvProc) (unsigned int index, const GLfloat * v);
typedef void (APIENTRY * VertexAttribdvProc) (unsigned int index, const GLdouble * v);
typedef void (APIENTRY * VertexAttribubvProc) (unsigned int index, const GLubyte * v); typedef void (APIENTRY * VertexAttribubvProc) (unsigned int index, const GLubyte * v);
typedef void (APIENTRY * SecondaryColor3ubvProc) (const GLubyte* coord); typedef void (APIENTRY * SecondaryColor3ubvProc) (const GLubyte* coord);
@ -662,6 +683,8 @@ class OSG_EXPORT Drawable : public Object
typedef void (APIENTRY * MultiTexCoord1fProc) (GLenum target,GLfloat coord); typedef void (APIENTRY * MultiTexCoord1fProc) (GLenum target,GLfloat coord);
typedef void (APIENTRY * MultiTexCoordfvProc) (GLenum target,const GLfloat* coord); typedef void (APIENTRY * MultiTexCoordfvProc) (GLenum target,const GLfloat* coord);
typedef void (APIENTRY * MultiTexCoord1dProc) (GLenum target,GLdouble coord);
typedef void (APIENTRY * MultiTexCoorddvProc) (GLenum target,const GLdouble* coord);
typedef void (APIENTRY * GenBuffersProc) (GLsizei n, GLuint *buffers); typedef void (APIENTRY * GenBuffersProc) (GLsizei n, GLuint *buffers);
@ -712,9 +735,13 @@ class OSG_EXPORT Drawable : public Object
VertexAttrib1sProc _glVertexAttrib1s; VertexAttrib1sProc _glVertexAttrib1s;
VertexAttrib1fProc _glVertexAttrib1f; VertexAttrib1fProc _glVertexAttrib1f;
VertexAttrib1dProc _glVertexAttrib1d;
VertexAttribfvProc _glVertexAttrib2fv; VertexAttribfvProc _glVertexAttrib2fv;
VertexAttribfvProc _glVertexAttrib3fv; VertexAttribfvProc _glVertexAttrib3fv;
VertexAttribfvProc _glVertexAttrib4fv; VertexAttribfvProc _glVertexAttrib4fv;
VertexAttribdvProc _glVertexAttrib2dv;
VertexAttribdvProc _glVertexAttrib3dv;
VertexAttribdvProc _glVertexAttrib4dv;
VertexAttribubvProc _glVertexAttrib4ubv; VertexAttribubvProc _glVertexAttrib4ubv;
VertexAttribubvProc _glVertexAttrib4Nubv; VertexAttribubvProc _glVertexAttrib4Nubv;
@ -722,6 +749,10 @@ class OSG_EXPORT Drawable : public Object
MultiTexCoordfvProc _glMultiTexCoord2fv; MultiTexCoordfvProc _glMultiTexCoord2fv;
MultiTexCoordfvProc _glMultiTexCoord3fv; MultiTexCoordfvProc _glMultiTexCoord3fv;
MultiTexCoordfvProc _glMultiTexCoord4fv; MultiTexCoordfvProc _glMultiTexCoord4fv;
MultiTexCoord1dProc _glMultiTexCoord1d;
MultiTexCoorddvProc _glMultiTexCoord2dv;
MultiTexCoorddvProc _glMultiTexCoord3dv;
MultiTexCoorddvProc _glMultiTexCoord4dv;
GenBuffersProc _glGenBuffers; GenBuffersProc _glGenBuffers;
BindBufferProc _glBindBuffer; BindBufferProc _glBindBuffer;

View File

@ -20,6 +20,9 @@
#include <osg/Vec2> #include <osg/Vec2>
#include <osg/Vec3> #include <osg/Vec3>
#include <osg/Vec4> #include <osg/Vec4>
#include <osg/Vec2d>
#include <osg/Vec3d>
#include <osg/Vec4d>
#include <osg/BufferObject> #include <osg/BufferObject>
@ -114,6 +117,21 @@ public:
*/ */
virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0; virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
/** Sets the array of vertices used to describe the primitives. Somehow
* mimics the OpenGL \c glVertexPointer() function.
*/
virtual void setVertexArray(unsigned int count,const Vec2d* vertices) = 0;
/** Sets the array of vertices used to describe the primitives. Somehow
* mimics the OpenGL \c glVertexPointer() function.
*/
virtual void setVertexArray(unsigned int count,const Vec3d* vertices) = 0;
/** Sets the array of vertices used to describe the primitives. Somehow
* mimics the OpenGL \c glVertexPointer() function.
*/
virtual void setVertexArray(unsigned int count,const Vec4d* vertices) = 0;
/// Mimics the OpenGL \c glDrawArrays() function. /// Mimics the OpenGL \c glDrawArrays() function.
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0; virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
@ -161,6 +179,10 @@ public:
virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0; virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0; virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
virtual void setVertexArray(unsigned int count,const Vec2d* vertices) = 0;
virtual void setVertexArray(unsigned int count,const Vec3d* vertices) = 0;
virtual void setVertexArray(unsigned int count,const Vec4d* vertices) = 0;
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0; virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0; virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0; virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;

View File

@ -71,6 +71,21 @@ namespace osg {
notify(WARN)<<"Triangle Functor does not support Vec4* vertex arrays"<<std::endl; notify(WARN)<<"Triangle Functor does not support Vec4* vertex arrays"<<std::endl;
} }
virtual void setVertexArray(unsigned int,const Vec2d*)
{
notify(WARN)<<"Triangle Functor does not support Vec2d* vertex arrays"<<std::endl;
}
virtual void setVertexArray(unsigned int count,const Vec3d* vertices)
{
notify(WARN)<<"Triangle Functor does not support Vec3d* vertex arrays"<<std::endl;
}
virtual void setVertexArray(unsigned int,const Vec4d* )
{
notify(WARN)<<"Triangle Functor does not support Vec4d* vertex arrays"<<std::endl;
}
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
{ {

View File

@ -68,6 +68,20 @@ public:
notify(WARN)<<"Triangle Functor does not support Vec4* vertex arrays"<<std::endl; notify(WARN)<<"Triangle Functor does not support Vec4* vertex arrays"<<std::endl;
} }
virtual void setVertexArray(unsigned int,const Vec2d*)
{
notify(WARN)<<"Triangle Functor does not support Vec2d* vertex arrays"<<std::endl;
}
virtual void setVertexArray(unsigned int,const Vec3d*)
{
notify(WARN)<<"Triangle Functor does not support Vec3d* vertex arrays"<<std::endl;
}
virtual void setVertexArray(unsigned int,const Vec4d* )
{
notify(WARN)<<"Triangle Functor does not support Vec4d* vertex arrays"<<std::endl;
}
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
{ {

View File

@ -37,6 +37,18 @@ public:
{ {
} }
virtual void setVertexArray(unsigned int,const Vec2d*)
{
}
virtual void setVertexArray(unsigned int ,const Vec3d* )
{
}
virtual void setVertexArray(unsigned int,const Vec4d* )
{
}
virtual void begin(GLenum mode) virtual void begin(GLenum mode)
{ {
_modeCache = mode; _modeCache = mode;

View File

@ -74,6 +74,9 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
virtual void setVertexArray(unsigned int count,const osg::Vec3*) { _vertexCount += count; } virtual void setVertexArray(unsigned int count,const osg::Vec3*) { _vertexCount += count; }
virtual void setVertexArray(unsigned int count,const osg::Vec2*) { _vertexCount += count; } virtual void setVertexArray(unsigned int count,const osg::Vec2*) { _vertexCount += count; }
virtual void setVertexArray(unsigned int count,const osg::Vec4*) { _vertexCount += count; } virtual void setVertexArray(unsigned int count,const osg::Vec4*) { _vertexCount += count; }
virtual void setVertexArray(unsigned int count,const osg::Vec3d*) { _vertexCount += count; }
virtual void setVertexArray(unsigned int count,const osg::Vec2d*) { _vertexCount += count; }
virtual void setVertexArray(unsigned int count,const osg::Vec4d*) { _vertexCount += count; }
virtual void drawArrays(GLenum mode,GLint,GLsizei count); virtual void drawArrays(GLenum mode,GLint,GLsizei count);
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte*); virtual void drawElements(GLenum mode,GLsizei count,const GLubyte*);

View File

@ -21,6 +21,7 @@
#include <osg/GLExtensions> #include <osg/GLExtensions>
#include <osg/Timer> #include <osg/Timer>
#include <osg/TriangleFunctor> #include <osg/TriangleFunctor>
#include <osg/io_utils>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@ -700,105 +701,104 @@ void Drawable::setEventCallback(EventCallback* ac)
struct ComputeBound : public PrimitiveFunctor struct ComputeBound : public PrimitiveFunctor
{ {
ComputeBound() { _vertices = 0; _vertices4 = 0;} ComputeBound()
virtual void setVertexArray(unsigned int,const Vec2*)
{ {
notify(WARN)<<"ComputeBound does not support Vec2* vertex arrays"<<std::endl; _vertices2f = 0;
_vertices3f = 0;
_vertices4f = 0;
_vertices2d = 0;
_vertices3d = 0;
_vertices4d = 0;
} }
virtual void setVertexArray(unsigned int,const Vec3* vertices) { _vertices = vertices; } virtual void setVertexArray(unsigned int,const Vec2* vertices) { _vertices2f = vertices; }
virtual void setVertexArray(unsigned int,const Vec4* vertices) { _vertices4 = vertices; } virtual void setVertexArray(unsigned int,const Vec3* vertices) { _vertices3f = vertices; }
virtual void setVertexArray(unsigned int,const Vec4* vertices) { _vertices4f = vertices; }
virtual void setVertexArray(unsigned int,const Vec2d* vertices) { _vertices2d = vertices; }
virtual void setVertexArray(unsigned int,const Vec3d* vertices) { _vertices3d = vertices; }
virtual void setVertexArray(unsigned int,const Vec4d* vertices) { _vertices4d = vertices; }
template<typename T>
void _drawArrays(T* vert, T* end)
{
for(;vert<end;++vert)
{
vertex(*vert);
}
}
template<typename T, typename I>
void _drawElements(T* vert, I* indices, I* end)
{
for(;indices<end;++indices)
{
vertex(vert[*indices]);
}
}
virtual void drawArrays(GLenum,GLint first,GLsizei count) virtual void drawArrays(GLenum,GLint first,GLsizei count)
{ {
if (_vertices) if (_vertices3f) _drawArrays(_vertices3f+first, _vertices3f+(first+count));
{ else if (_vertices2f) _drawArrays(_vertices2f+first, _vertices2f+(first+count));
const osg::Vec3* vert = _vertices+first; else if (_vertices4f) _drawArrays(_vertices4f+first, _vertices4f+(first+count));
for(;count>0;--count,++vert) else if (_vertices2d) _drawArrays(_vertices2d+first, _vertices2d+(first+count));
{ else if (_vertices3d) _drawArrays(_vertices3d+first, _vertices3d+(first+count));
_bb.expandBy(*vert); else if (_vertices4d) _drawArrays(_vertices4d+first, _vertices4d+(first+count));
}
}
if (_vertices4)
{
const osg::Vec4* vert = _vertices4+first;
for(;count>0;--count,++vert)
{
_bb.expandBy(*((Vec3*) vert));
}
}
} }
virtual void drawElements(GLenum,GLsizei count,const GLubyte* indices) virtual void drawElements(GLenum,GLsizei count,const GLubyte* indices)
{ {
if (_vertices) if (_vertices3f) _drawElements(_vertices3f, indices, indices + count);
{ else if (_vertices2f) _drawElements(_vertices2f, indices, indices + count);
for(;count>0;--count,++indices) else if (_vertices4f) _drawElements(_vertices4f, indices, indices + count);
{ else if (_vertices2d) _drawElements(_vertices2d, indices, indices + count);
_bb.expandBy(_vertices[*indices]); else if (_vertices3d) _drawElements(_vertices3d, indices, indices + count);
} else if (_vertices4d) _drawElements(_vertices4d, indices, indices + count);
}
if (_vertices4)
{
for(;count>0;--count,++indices)
{
_bb.expandBy(*((Vec3*)&_vertices4[*indices]));
}
}
} }
virtual void drawElements(GLenum,GLsizei count,const GLushort* indices) virtual void drawElements(GLenum,GLsizei count,const GLushort* indices)
{ {
if (_vertices) if (_vertices3f) _drawElements(_vertices3f, indices, indices + count);
{ else if (_vertices2f) _drawElements(_vertices2f, indices, indices + count);
for(;count>0;--count,++indices) else if (_vertices4f) _drawElements(_vertices4f, indices, indices + count);
{ else if (_vertices2d) _drawElements(_vertices2d, indices, indices + count);
_bb.expandBy(_vertices[*indices]); else if (_vertices3d) _drawElements(_vertices3d, indices, indices + count);
} else if (_vertices4d) _drawElements(_vertices4d, indices, indices + count);
}
if (_vertices4)
{
for(;count>0;--count,++indices)
{
_bb.expandBy(*((Vec3*)&_vertices4[*indices]));
}
}
} }
virtual void drawElements(GLenum,GLsizei count,const GLuint* indices) virtual void drawElements(GLenum,GLsizei count,const GLuint* indices)
{ {
if (_vertices) if (_vertices3f) _drawElements(_vertices3f, indices, indices + count);
{ else if (_vertices2f) _drawElements(_vertices2f, indices, indices + count);
for(;count>0;--count,++indices) else if (_vertices4f) _drawElements(_vertices4f, indices, indices + count);
{ else if (_vertices2d) _drawElements(_vertices2d, indices, indices + count);
_bb.expandBy(_vertices[*indices]); else if (_vertices3d) _drawElements(_vertices3d, indices, indices + count);
} else if (_vertices4d) _drawElements(_vertices4d, indices, indices + count);
}
if (_vertices4)
{
for(;count>0;--count,++indices)
{
_bb.expandBy(*((Vec3*)&_vertices4[*indices]));
}
}
} }
virtual void begin(GLenum) {} virtual void begin(GLenum) {}
virtual void vertex(const Vec2& vert) { _bb.expandBy(osg::Vec3(vert[0],vert[1],0.0f)); } virtual void vertex(const Vec2& vert) { _bb.expandBy(osg::Vec3(vert[0],vert[1],0.0f)); }
virtual void vertex(const Vec3& vert) { _bb.expandBy(vert); } virtual void vertex(const Vec3& vert) { _bb.expandBy(vert); }
virtual void vertex(const Vec4& vert) { if (vert[3]!=0.0f) _bb.expandBy(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); } virtual void vertex(const Vec4& vert) { if (vert[3]!=0.0f) _bb.expandBy(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); }
virtual void vertex(const Vec2d& vert) { _bb.expandBy(osg::Vec3(vert[0],vert[1],0.0f)); }
virtual void vertex(const Vec3d& vert) { _bb.expandBy(vert); }
virtual void vertex(const Vec4d& vert) { if (vert[3]!=0.0f) _bb.expandBy(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); }
virtual void vertex(float x,float y) { _bb.expandBy(x,y,1.0f); } virtual void vertex(float x,float y) { _bb.expandBy(x,y,1.0f); }
virtual void vertex(float x,float y,float z) { _bb.expandBy(x,y,z); } virtual void vertex(float x,float y,float z) { _bb.expandBy(x,y,z); }
virtual void vertex(float x,float y,float z,float w) { if (w!=0.0f) _bb.expandBy(x/w,y/w,z/w); } virtual void vertex(float x,float y,float z,float w) { if (w!=0.0f) _bb.expandBy(x/w,y/w,z/w); }
virtual void vertex(double x,double y) { _bb.expandBy(x,y,1.0f); }
virtual void vertex(double x,double y,double z) { _bb.expandBy(x,y,z); }
virtual void vertex(double x,double y,double z,double w) { if (w!=0.0f) _bb.expandBy(x/w,y/w,z/w); }
virtual void end() {} virtual void end() {}
const Vec3* _vertices; const Vec2* _vertices2f;
const Vec4* _vertices4; const Vec3* _vertices3f;
const Vec4* _vertices4f;
const Vec2d* _vertices2d;
const Vec3d* _vertices3d;
const Vec4d* _vertices4d;
BoundingBox _bb; BoundingBox _bb;
}; };
@ -809,6 +809,12 @@ BoundingBox Drawable::computeBound() const
Drawable* non_const_this = const_cast<Drawable*>(this); Drawable* non_const_this = const_cast<Drawable*>(this);
non_const_this->accept(cb); non_const_this->accept(cb);
#if 0
osg::notify(osg::NOTICE)<<"computeBound() "<<cb._bb.xMin()<<", "<<cb._bb.xMax()<<", "<<std::endl;
osg::notify(osg::NOTICE)<<" "<<cb._bb.yMin()<<", "<<cb._bb.yMax()<<", "<<std::endl;
osg::notify(osg::NOTICE)<<" "<<cb._bb.zMin()<<", "<<cb._bb.zMax()<<", "<<std::endl;
#endif
return cb._bb; return cb._bb;
} }
@ -968,12 +974,20 @@ void Drawable::Extensions::setupGLExtensions(unsigned int contextID)
setGLExtensionFuncPtr(_glMultiTexCoord2fv, "glMultiTexCoord2fv","glMultiTexCoord2fvARB"); setGLExtensionFuncPtr(_glMultiTexCoord2fv, "glMultiTexCoord2fv","glMultiTexCoord2fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord3fv, "glMultiTexCoord3fv","glMultiTexCoord3fvARB"); setGLExtensionFuncPtr(_glMultiTexCoord3fv, "glMultiTexCoord3fv","glMultiTexCoord3fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord4fv, "glMultiTexCoord4fv","glMultiTexCoord4fvARB"); setGLExtensionFuncPtr(_glMultiTexCoord4fv, "glMultiTexCoord4fv","glMultiTexCoord4fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord1d, "glMultiTexCoord1d","glMultiTexCoorddfARB");
setGLExtensionFuncPtr(_glMultiTexCoord2dv, "glMultiTexCoord2dv","glMultiTexCoord2dvARB");
setGLExtensionFuncPtr(_glMultiTexCoord3dv, "glMultiTexCoord3dv","glMultiTexCoord3dvARB");
setGLExtensionFuncPtr(_glMultiTexCoord4dv, "glMultiTexCoord4dv","glMultiTexCoord4dvARB");
setGLExtensionFuncPtr(_glVertexAttrib1s, "glVertexAttrib1s","glVertexAttrib1sARB"); setGLExtensionFuncPtr(_glVertexAttrib1s, "glVertexAttrib1s","glVertexAttrib1sARB");
setGLExtensionFuncPtr(_glVertexAttrib1f, "glVertexAttrib1f","glVertexAttrib1fARB"); setGLExtensionFuncPtr(_glVertexAttrib1f, "glVertexAttrib1f","glVertexAttrib1fARB");
setGLExtensionFuncPtr(_glVertexAttrib1d, "glVertexAttrib1d","glVertexAttrib1dARB");
setGLExtensionFuncPtr(_glVertexAttrib2fv, "glVertexAttrib2fv","glVertexAttrib2fvARB"); setGLExtensionFuncPtr(_glVertexAttrib2fv, "glVertexAttrib2fv","glVertexAttrib2fvARB");
setGLExtensionFuncPtr(_glVertexAttrib3fv, "glVertexAttrib3fv","glVertexAttrib3fvARB"); setGLExtensionFuncPtr(_glVertexAttrib3fv, "glVertexAttrib3fv","glVertexAttrib3fvARB");
setGLExtensionFuncPtr(_glVertexAttrib4fv, "glVertexAttrib4fv","glVertexAttrib4fvARB"); setGLExtensionFuncPtr(_glVertexAttrib4fv, "glVertexAttrib4fv","glVertexAttrib4fvARB");
setGLExtensionFuncPtr(_glVertexAttrib2dv, "glVertexAttrib2dv","glVertexAttrib2dvARB");
setGLExtensionFuncPtr(_glVertexAttrib3dv, "glVertexAttrib3dv","glVertexAttrib3dvARB");
setGLExtensionFuncPtr(_glVertexAttrib4dv, "glVertexAttrib4dv","glVertexAttrib4dvARB");
setGLExtensionFuncPtr(_glVertexAttrib4ubv, "glVertexAttrib4ubv","glVertexAttrib4ubvARB"); setGLExtensionFuncPtr(_glVertexAttrib4ubv, "glVertexAttrib4ubv","glVertexAttrib4ubvARB");
setGLExtensionFuncPtr(_glVertexAttrib4Nubv, "glVertexAttrib4Nubv","glVertexAttrib4NubvARB"); setGLExtensionFuncPtr(_glVertexAttrib4Nubv, "glVertexAttrib4Nubv","glVertexAttrib4NubvARB");
@ -1092,6 +1106,54 @@ void Drawable::Extensions::glMultiTexCoord4fv(GLenum target,const GLfloat* coord
} }
} }
void Drawable::Extensions::glMultiTexCoord1d(GLenum target,GLdouble coord) const
{
if (_glMultiTexCoord1d)
{
_glMultiTexCoord1d(target,coord);
}
else
{
notify(WARN)<<"Error: glMultiTexCoord1d not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord2dv(GLenum target,const GLdouble* coord) const
{
if (_glMultiTexCoord2dv)
{
_glMultiTexCoord2dv(target,coord);
}
else
{
notify(WARN)<<"Error: glMultiTexCoord2dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord3dv(GLenum target,const GLdouble* coord) const
{
if (_glMultiTexCoord3dv)
{
_glMultiTexCoord3dv(target,coord);
}
else
{
notify(WARN)<<"Error: _glMultiTexCoord3dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord4dv(GLenum target,const GLdouble* coord) const
{
if (_glMultiTexCoord4dv)
{
_glMultiTexCoord4dv(target,coord);
}
else
{
notify(WARN)<<"Error: glMultiTexCoord4dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib1s(unsigned int index, GLshort s) const void Drawable::Extensions::glVertexAttrib1s(unsigned int index, GLshort s) const
{ {
if (_glVertexAttrib1s) if (_glVertexAttrib1s)
@ -1116,6 +1178,18 @@ void Drawable::Extensions::glVertexAttrib1f(unsigned int index, GLfloat f) const
} }
} }
void Drawable::Extensions::glVertexAttrib1d(unsigned int index, GLdouble f) const
{
if (_glVertexAttrib1d)
{
_glVertexAttrib1d(index,f);
}
else
{
notify(WARN)<<"Error: glVertexAttrib1d not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib2fv(unsigned int index, const GLfloat * v) const void Drawable::Extensions::glVertexAttrib2fv(unsigned int index, const GLfloat * v) const
{ {
if (_glVertexAttrib2fv) if (_glVertexAttrib2fv)
@ -1152,6 +1226,42 @@ void Drawable::Extensions::glVertexAttrib4fv(unsigned int index, const GLfloat *
} }
} }
void Drawable::Extensions::glVertexAttrib2dv(unsigned int index, const GLdouble * v) const
{
if (_glVertexAttrib2dv)
{
_glVertexAttrib2dv(index,v);
}
else
{
notify(WARN)<<"Error: glVertexAttrib2dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib3dv(unsigned int index, const GLdouble * v) const
{
if (_glVertexAttrib3dv)
{
_glVertexAttrib3dv(index,v);
}
else
{
notify(WARN)<<"Error: glVertexAttrib3dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib4dv(unsigned int index, const GLdouble * v) const
{
if (_glVertexAttrib4dv)
{
_glVertexAttrib4dv(index,v);
}
else
{
notify(WARN)<<"Error: glVertexAttrib4dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const void Drawable::Extensions::glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const
{ {
if (_glVertexAttrib4ubv) if (_glVertexAttrib4ubv)

View File

@ -60,6 +60,15 @@ class DrawVertex
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
apply((*(static_cast<const Vec4Array*>(_vertices)))[pos]); apply((*(static_cast<const Vec4Array*>(_vertices)))[pos]);
break; break;
case(Array::Vec3dArrayType):
apply((*(static_cast<const Vec3dArray*>(_vertices)))[pos]);
break;
case(Array::Vec2dArrayType):
apply((*(static_cast<const Vec2dArray*>(_vertices)))[pos]);
break;
case(Array::Vec4dArrayType):
apply((*(static_cast<const Vec4dArray*>(_vertices)))[pos]);
break;
default: default:
break; break;
} }
@ -69,6 +78,9 @@ class DrawVertex
inline void apply(const Vec2& v) { glVertex2fv(v.ptr()); } inline void apply(const Vec2& v) { glVertex2fv(v.ptr()); }
inline void apply(const Vec3& v) { glVertex3fv(v.ptr()); } inline void apply(const Vec3& v) { glVertex3fv(v.ptr()); }
inline void apply(const Vec4& v) { glVertex4fv(v.ptr()); } inline void apply(const Vec4& v) { glVertex4fv(v.ptr()); }
inline void apply(const Vec2d& v) { glVertex2dv(v.ptr()); }
inline void apply(const Vec3d& v) { glVertex3dv(v.ptr()); }
inline void apply(const Vec4d& v) { glVertex4dv(v.ptr()); }
const Array* _vertices; const Array* _vertices;
const IndexArray* _indices; const IndexArray* _indices;
@ -244,6 +256,18 @@ public:
{ {
_extensions->glVertexAttrib4fv( _vertAttribIndex, v.ptr() ); _extensions->glVertexAttrib4fv( _vertAttribIndex, v.ptr() );
} }
virtual void apply(const Vec2d& v)
{
_extensions->glVertexAttrib2dv( _vertAttribIndex, v.ptr() );
}
virtual void apply(const Vec3d& v)
{
_extensions->glVertexAttrib3dv( _vertAttribIndex, v.ptr() );
}
virtual void apply(const Vec4d& v)
{
_extensions->glVertexAttrib4dv( _vertAttribIndex, v.ptr() );
}
unsigned int _vertAttribIndex; unsigned int _vertAttribIndex;
GLboolean _normalized; GLboolean _normalized;
@ -2056,6 +2080,10 @@ class AttributeFunctorArrayVisitor : public ArrayVisitor
virtual void apply(Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(Vec4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(Vec4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(DoubleArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(Vec2dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(Vec3dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(Vec4dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
inline void applyArray(Drawable::AttributeType type,Array* array) inline void applyArray(Drawable::AttributeType type,Array* array)
@ -2112,6 +2140,10 @@ class ConstAttributeFunctorArrayVisitor : public ConstArrayVisitor
virtual void apply(const Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(const Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(const Vec4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const Vec4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(const DoubleArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(const Vec2dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(const Vec3dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
virtual void apply(const Vec4dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
inline void applyArray(Drawable::AttributeType type,const Array* array) inline void applyArray(Drawable::AttributeType type,const Array* array)
@ -2165,6 +2197,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec4*>(_vertexData.array->getDataPointer())); functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec4*>(_vertexData.array->getDataPointer()));
break; break;
case(Array::Vec2dArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec2d*>(_vertexData.array->getDataPointer()));
break;
case(Array::Vec3dArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec3d*>(_vertexData.array->getDataPointer()));
break;
case(Array::Vec4dArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec4d*>(_vertexData.array->getDataPointer()));
break;
default: default:
notify(WARN)<<"Warning: Geometry::accept(PrimtiveFunctor&) cannot handle Vertex Array type"<<_vertexData.array->getType()<<std::endl; notify(WARN)<<"Warning: Geometry::accept(PrimtiveFunctor&) cannot handle Vertex Array type"<<_vertexData.array->getType()<<std::endl;
return; return;
@ -2182,6 +2223,9 @@ void Geometry::accept(PrimitiveFunctor& functor) const
const Vec2Array* vec2Array = 0; const Vec2Array* vec2Array = 0;
const Vec3Array* vec3Array = 0; const Vec3Array* vec3Array = 0;
const Vec4Array* vec4Array = 0; const Vec4Array* vec4Array = 0;
const Vec2dArray* vec2dArray = 0;
const Vec3dArray* vec3dArray = 0;
const Vec4dArray* vec4dArray = 0;
Array::Type type = _vertexData.array->getType(); Array::Type type = _vertexData.array->getType();
switch(type) switch(type)
{ {
@ -2194,6 +2238,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
vec4Array = static_cast<const Vec4Array*>(_vertexData.array.get()); vec4Array = static_cast<const Vec4Array*>(_vertexData.array.get());
break; break;
case(Array::Vec2dArrayType):
vec2dArray = static_cast<const Vec2dArray*>(_vertexData.array.get());
break;
case(Array::Vec3dArrayType):
vec3dArray = static_cast<const Vec3dArray*>(_vertexData.array.get());
break;
case(Array::Vec4dArrayType):
vec4dArray = static_cast<const Vec4dArray*>(_vertexData.array.get());
break;
default: default:
notify(WARN)<<"Warning: Geometry::accept(PrimtiveFunctor&) cannot handle Vertex Array type"<<_vertexData.array->getType()<<std::endl; notify(WARN)<<"Warning: Geometry::accept(PrimtiveFunctor&) cannot handle Vertex Array type"<<_vertexData.array->getType()<<std::endl;
return; return;
@ -2229,6 +2282,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]); functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break; break;
case(Array::Vec2dArrayType):
functor.vertex((*vec2Array)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec3dArrayType):
functor.vertex((*vec3Array)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec4dArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break;
default: default:
break; break;
} }
@ -2263,6 +2325,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]); functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break; break;
case(Array::Vec2dArrayType):
functor.vertex((*vec2Array)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec3dArrayType):
functor.vertex((*vec3Array)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec4dArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break;
default: default:
break; break;
} }
@ -2296,6 +2367,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]); functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break; break;
case(Array::Vec2dArrayType):
functor.vertex((*vec2dArray)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec3dArrayType):
functor.vertex((*vec3dArray)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec4dArrayType):
functor.vertex((*vec4dArray)[_vertexData.indices->index(vindex)]);
break;
default: default:
break; break;
} }
@ -2325,6 +2405,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]); functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break; break;
case(Array::Vec2dArrayType):
functor.vertex((*vec2dArray)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec3dArrayType):
functor.vertex((*vec3dArray)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec4dArrayType):
functor.vertex((*vec4dArray)[_vertexData.indices->index(vindex)]);
break;
default: default:
break; break;
} }
@ -2354,6 +2443,15 @@ void Geometry::accept(PrimitiveFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]); functor.vertex((*vec4Array)[_vertexData.indices->index(vindex)]);
break; break;
case(Array::Vec2dArrayType):
functor.vertex((*vec2dArray)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec3dArrayType):
functor.vertex((*vec3dArray)[_vertexData.indices->index(vindex)]);
break;
case(Array::Vec4dArrayType):
functor.vertex((*vec4dArray)[_vertexData.indices->index(vindex)]);
break;
default: default:
break; break;
} }
@ -2387,6 +2485,15 @@ void Geometry::accept(PrimitiveIndexFunctor& functor) const
case(Array::Vec4ArrayType): case(Array::Vec4ArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec4*>(_vertexData.array->getDataPointer())); functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec4*>(_vertexData.array->getDataPointer()));
break; break;
case(Array::Vec2dArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec2d*>(_vertexData.array->getDataPointer()));
break;
case(Array::Vec3dArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec3d*>(_vertexData.array->getDataPointer()));
break;
case(Array::Vec4dArrayType):
functor.setVertexArray(_vertexData.array->getNumElements(),static_cast<const Vec4d*>(_vertexData.array->getDataPointer()));
break;
default: default:
notify(WARN)<<"Warning: Geometry::accept(PrimtiveIndexFunctor&) cannot handle Vertex Array type"<<_vertexData.array->getType()<<std::endl; notify(WARN)<<"Warning: Geometry::accept(PrimtiveIndexFunctor&) cannot handle Vertex Array type"<<_vertexData.array->getType()<<std::endl;
return; return;

View File

@ -99,6 +99,12 @@ class PrimitiveIndexWriter : public osg::PrimitiveIndexFunctor {
virtual void setVertexArray(unsigned int,const osg::Vec4* ) {} virtual void setVertexArray(unsigned int,const osg::Vec4* ) {}
virtual void setVertexArray(unsigned int,const osg::Vec2d*) {}
virtual void setVertexArray(unsigned int ,const osg::Vec3d* ) {}
virtual void setVertexArray(unsigned int,const osg::Vec4d* ) {}
void write(unsigned int i) void write(unsigned int i)
{ {
_fout << (i + _lastVertexIndex) << "/"; _fout << (i + _lastVertexIndex) << "/";

View File

@ -2234,6 +2234,11 @@ class MergeArrayVisitor : public osg::ArrayVisitor
virtual void apply(osg::Vec3Array& rhs) { _merge(rhs); } virtual void apply(osg::Vec3Array& rhs) { _merge(rhs); }
virtual void apply(osg::Vec4Array& rhs) { _merge(rhs); } virtual void apply(osg::Vec4Array& rhs) { _merge(rhs); }
virtual void apply(osg::DoubleArray& rhs) { _merge(rhs); }
virtual void apply(osg::Vec2dArray& rhs) { _merge(rhs); }
virtual void apply(osg::Vec3dArray& rhs) { _merge(rhs); }
virtual void apply(osg::Vec4dArray& rhs) { _merge(rhs); }
virtual void apply(osg::Vec2bArray& rhs) { _merge(rhs); } virtual void apply(osg::Vec2bArray& rhs) { _merge(rhs); }
virtual void apply(osg::Vec3bArray& rhs) { _merge(rhs); } virtual void apply(osg::Vec3bArray& rhs) { _merge(rhs); }
virtual void apply(osg::Vec4bArray& rhs) { _merge(rhs); } virtual void apply(osg::Vec4bArray& rhs) { _merge(rhs); }