diff --git a/include/osg/Export b/include/osg/Export index 3e11db537..0852e2894 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -42,33 +42,6 @@ # define OSG_EXPORT #endif -// export template instances for basic types -#if (_MSC_VER >= 1300) && !defined( OSG_LIBRARY_STATIC ) -#include -#if defined( OSG_LIBRARY ) -template class __declspec(dllexport) std::allocator; // GLsizei -template class __declspec(dllexport) std::vector >; // GLsizei -template class __declspec(dllexport) std::allocator; // GLubyte -template class __declspec(dllexport) std::vector >; // GLubyte -template class __declspec(dllexport) std::allocator; // GLushort -template class __declspec(dllexport) std::vector >; // GLushort -template class __declspec(dllexport) std::allocator; // GLuint -template class __declspec(dllexport) std::vector >; // GLuint -#else -#pragma warning ( push ) -#pragma warning ( disable : 4231 ) -extern template class __declspec(dllimport) std::allocator; // GLsizei -extern template class __declspec(dllimport) std::vector >; // GLsizei -extern template class __declspec(dllimport) std::allocator; // GLubyte -extern template class __declspec(dllimport) std::vector >; // GLubyte -extern template class __declspec(dllimport) std::allocator; // GLushort -extern template class __declspec(dllimport) std::vector >; // GLushort -extern template class __declspec(dllimport) std::allocator; // GLuint -extern template class __declspec(dllimport) std::vector >; // GLuint -#pragma warning ( pop ) -#endif -#endif - // set up define for whether member templates are supported by VisualStudio compilers. #ifdef _MSC_VER # if (_MSC_VER >= 1300) diff --git a/include/osg/PrimitiveSet b/include/osg/PrimitiveSet index 122a26d2b..08ed74399 100644 --- a/include/osg/PrimitiveSet +++ b/include/osg/PrimitiveSet @@ -25,6 +25,60 @@ namespace osg { +// ******************************** HACK ********************************** +// Following classes are needed by VC++ in order to avoid linking errors due +// to multiply defined member functions. Classes that would normally derive +// from std::vector (and that are exported via OSG_EXPORT) should derive +// from one of these classes instead. +// +// NOTE: to keep the interface consistent and avoid breaking introspection +// wrappers, this hack was deliberately made not Microsoft-specific +// even though other compilers like GCC actually don't need that. +// +// Marco Jez, Dec 2005 + +class VectorGLsizei: public std::vector +{ + typedef std::vector vector_type; +public: + VectorGLsizei(): vector_type() {} + VectorGLsizei(const VectorGLsizei ©): vector_type(copy) {} + VectorGLsizei(GLsizei* beg, GLsizei* end): vector_type(beg, end) {} + explicit VectorGLsizei(VectorGLsizei::size_type n): vector_type(n) {} +}; + +class VectorGLubyte: public std::vector +{ + typedef std::vector vector_type; +public: + VectorGLubyte(): vector_type() {} + VectorGLubyte(const VectorGLubyte ©): vector_type(copy) {} + VectorGLubyte(GLubyte* beg, GLubyte* end): vector_type(beg, end) {} + explicit VectorGLubyte(VectorGLubyte::size_type n): vector_type(n) {} +}; + +class VectorGLushort: public std::vector +{ + typedef std::vector vector_type; +public: + VectorGLushort(): vector_type() {} + VectorGLushort(const VectorGLushort ©): vector_type(copy) {} + VectorGLushort(GLushort* beg, GLushort* end): vector_type(beg, end) {} + explicit VectorGLushort(VectorGLushort::size_type n): vector_type(n) {} +}; + +class VectorGLuint: public std::vector +{ + typedef std::vector vector_type; +public: + VectorGLuint(): vector_type() {} + VectorGLuint(const VectorGLuint ©): vector_type(copy) {} + VectorGLuint(GLuint* beg, GLuint* end): vector_type(beg, end) {} + explicit VectorGLuint(VectorGLuint::size_type n): vector_type(n) {} +}; + +// ************************************************************************** + class State; class PrimitiveFunctor { @@ -252,11 +306,11 @@ class OSG_EXPORT DrawArrays : public PrimitiveSet GLsizei _count; }; -class OSG_EXPORT DrawArrayLengths : public PrimitiveSet, public std::vector +class OSG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorGLsizei { public: - typedef std::vector vector_type; + typedef VectorGLsizei vector_type; DrawArrayLengths(GLenum mode=0): PrimitiveSet(DrawArrayLengthsPrimitiveType,mode), @@ -327,11 +381,11 @@ class OSG_EXPORT DrawArrayLengths : public PrimitiveSet, public std::vector +class OSG_EXPORT DrawElementsUByte : public PrimitiveSet, public VectorGLubyte { public: - typedef std::vector vector_type; + typedef VectorGLubyte vector_type; DrawElementsUByte(GLenum mode=0): PrimitiveSet(DrawElementsUBytePrimitiveType,mode) {} @@ -378,11 +432,11 @@ class OSG_EXPORT DrawElementsUByte : public PrimitiveSet, public std::vector +class OSG_EXPORT DrawElementsUShort : public PrimitiveSet, public VectorGLushort { public: - typedef std::vector vector_type; + typedef VectorGLushort vector_type; DrawElementsUShort(GLenum mode=0): PrimitiveSet(DrawElementsUShortPrimitiveType,mode) {} @@ -432,11 +486,11 @@ class OSG_EXPORT DrawElementsUShort : public PrimitiveSet, public std::vector +class OSG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorGLuint { public: - typedef std::vector vector_type; + typedef VectorGLuint vector_type; DrawElementsUInt(GLenum mode=0): PrimitiveSet(DrawElementsUIntPrimitiveType,mode) {} diff --git a/include/osgText/String b/include/osgText/String index b8fc08473..0a63037f6 100644 --- a/include/osgText/String +++ b/include/osgText/String @@ -23,13 +23,29 @@ namespace osgText { +// ******************************** HACK ********************************** +// Following class is needed to work around a DLL export problem. See file +// include/osg/PrimitiveSet for details. + +class VectorUInt: public std::vector +{ + typedef std::vector vector_type; +public: + VectorUInt(): vector_type() {} + VectorUInt(const VectorUInt ©): vector_type(copy) {} + VectorUInt(unsigned int* beg, unsigned int* end): vector_type(beg, end) {} + explicit VectorUInt(VectorUInt::size_type n): vector_type(n) {} +}; + +// ************************************************************************** + class Text; -class OSGTEXT_EXPORT String : public osg::Referenced, public std::vector +class OSGTEXT_EXPORT String : public osg::Referenced, public VectorUInt { public: - typedef std::vector vector_type; + typedef VectorUInt vector_type; /** * Types of string encodings supported diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 1b15e87df..68874d515 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -595,7 +595,7 @@ bool CullVisitor::updateCalculatedNearFar(const osg::Matrix& matrix,const osg::D } } - if (d_far<=0.0) // gwm if ==0 extends purely behind eye, forces far to 0 get invalid projection matrix (ratio near:far=inf) + if (d_far<0.0) { // whole object behind the eye point so discard return false; diff --git a/src/osgWrappers/osg/PrimitiveSet.cpp b/src/osgWrappers/osg/PrimitiveSet.cpp index 57294495d..d2df64206 100644 --- a/src/osgWrappers/osg/PrimitiveSet.cpp +++ b/src/osgWrappers/osg/PrimitiveSet.cpp @@ -25,10 +25,11 @@ #undef OUT #endif -TYPE_NAME_ALIAS(std::vector< GLsizei >, osg::DrawArrayLengths::vector_type); +TYPE_NAME_ALIAS(osg::VectorGLsizei, osg::DrawArrayLengths::vector_type); BEGIN_OBJECT_REFLECTOR(osg::DrawArrayLengths) I_BaseType(osg::PrimitiveSet); + I_BaseType(osg::VectorGLsizei); I_ConstructorWithDefaults1(IN, GLenum, mode, 0); I_ConstructorWithDefaults2(IN, const osg::DrawArrayLengths &, dal, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); I_Constructor4(IN, GLenum, mode, IN, GLint, first, IN, unsigned int, no, IN, GLsizei *, ptr); @@ -76,10 +77,11 @@ BEGIN_OBJECT_REFLECTOR(osg::DrawArrays) I_Property(GLint, First); END_REFLECTOR -TYPE_NAME_ALIAS(std::vector< GLubyte >, osg::DrawElementsUByte::vector_type); +TYPE_NAME_ALIAS(osg::VectorGLubyte, osg::DrawElementsUByte::vector_type); BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUByte) I_BaseType(osg::PrimitiveSet); + I_BaseType(osg::VectorGLubyte); I_ConstructorWithDefaults1(IN, GLenum, mode, 0); I_ConstructorWithDefaults2(IN, const osg::DrawElementsUByte &, array, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); I_Constructor3(IN, GLenum, mode, IN, unsigned int, no, IN, GLubyte *, ptr); @@ -103,10 +105,11 @@ BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUByte) I_ReadOnlyProperty(unsigned int, TotalDataSize); END_REFLECTOR -TYPE_NAME_ALIAS(std::vector< GLuint >, osg::DrawElementsUInt::vector_type); +TYPE_NAME_ALIAS(osg::VectorGLuint, osg::DrawElementsUInt::vector_type); BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUInt) I_BaseType(osg::PrimitiveSet); + I_BaseType(osg::VectorGLuint); I_ConstructorWithDefaults1(IN, GLenum, mode, 0); I_ConstructorWithDefaults2(IN, const osg::DrawElementsUInt &, array, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); I_Constructor3(IN, GLenum, mode, IN, unsigned int, no, IN, GLuint *, ptr); @@ -130,10 +133,11 @@ BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUInt) I_ReadOnlyProperty(unsigned int, TotalDataSize); END_REFLECTOR -TYPE_NAME_ALIAS(std::vector< GLushort >, osg::DrawElementsUShort::vector_type); +TYPE_NAME_ALIAS(osg::VectorGLushort, osg::DrawElementsUShort::vector_type); BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUShort) I_BaseType(osg::PrimitiveSet); + I_BaseType(osg::VectorGLushort); I_ConstructorWithDefaults1(IN, GLenum, mode, 0); I_ConstructorWithDefaults2(IN, const osg::DrawElementsUShort &, array, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); I_Constructor3(IN, GLenum, mode, IN, unsigned int, no, IN, GLushort *, ptr); @@ -243,11 +247,35 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::PrimitiveSet) I_ReadOnlyProperty(osg::PrimitiveSet::Type, Type); END_REFLECTOR -STD_VECTOR_REFLECTOR(std::vector< GLsizei >); +BEGIN_OBJECT_REFLECTOR(osg::VectorGLsizei) + I_BaseType(std::vector); + I_Constructor0(); + I_Constructor1(IN, const osg::VectorGLsizei &, copy); + I_Constructor2(IN, GLsizei *, beg, IN, GLsizei *, end); + I_Constructor1(IN, osg::VectorGLsizei::size_type, n); +END_REFLECTOR -STD_VECTOR_REFLECTOR(std::vector< GLubyte >); +BEGIN_OBJECT_REFLECTOR(osg::VectorGLubyte) + I_BaseType(std::vector); + I_Constructor0(); + I_Constructor1(IN, const osg::VectorGLubyte &, copy); + I_Constructor2(IN, GLubyte *, beg, IN, GLubyte *, end); + I_Constructor1(IN, osg::VectorGLubyte::size_type, n); +END_REFLECTOR -STD_VECTOR_REFLECTOR(std::vector< GLuint >); +BEGIN_OBJECT_REFLECTOR(osg::VectorGLuint) + I_BaseType(std::vector); + I_Constructor0(); + I_Constructor1(IN, const osg::VectorGLuint &, copy); + I_Constructor2(IN, GLuint *, beg, IN, GLuint *, end); + I_Constructor1(IN, osg::VectorGLuint::size_type, n); +END_REFLECTOR -STD_VECTOR_REFLECTOR(std::vector< GLushort >); +BEGIN_OBJECT_REFLECTOR(osg::VectorGLushort) + I_BaseType(std::vector); + I_Constructor0(); + I_Constructor1(IN, const osg::VectorGLushort &, copy); + I_Constructor2(IN, GLushort *, beg, IN, GLushort *, end); + I_Constructor1(IN, osg::VectorGLushort::size_type, n); +END_REFLECTOR diff --git a/src/osgWrappers/osgText/String.cpp b/src/osgWrappers/osgText/String.cpp index 3ae4d327a..ec0949eb1 100644 --- a/src/osgWrappers/osgText/String.cpp +++ b/src/osgWrappers/osgText/String.cpp @@ -19,7 +19,7 @@ #undef OUT #endif -TYPE_NAME_ALIAS(std::vector< unsigned int >, osgText::String::vector_type); +TYPE_NAME_ALIAS(osgText::VectorUInt, osgText::String::vector_type); BEGIN_ENUM_REFLECTOR(osgText::String::Encoding) I_EnumLabel(osgText::String::ENCODING_UNDEFINED); @@ -36,6 +36,7 @@ END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osgText::String) I_BaseType(osg::Referenced); + I_BaseType(osgText::VectorUInt); I_Constructor0(); I_Constructor1(IN, const osgText::String &, str); I_Constructor1(IN, const std::string &, str); @@ -48,3 +49,11 @@ BEGIN_OBJECT_REFLECTOR(osgText::String) I_WriteOnlyProperty(const wchar_t *, ); END_REFLECTOR +BEGIN_OBJECT_REFLECTOR(osgText::VectorUInt) + I_BaseType(std::vector); + I_Constructor0(); + I_Constructor1(IN, const osgText::VectorUInt &, copy); + I_Constructor2(IN, unsigned int *, beg, IN, unsigned int *, end); + I_Constructor1(IN, osgText::VectorUInt::size_type, n); +END_REFLECTOR +