From 37acc0146a1390522180e88d9ecf8e5ba57d5cdd Mon Sep 17 00:00:00 2001 From: dibenedetto Date: Mon, 7 May 2012 19:21:47 +0000 Subject: [PATCH] changed NoBase to NoType in glw and resolved conflict with Type enum. --- wrap/glw/bookkeeping.h | 22 +++++++------- wrap/glw/context.h | 66 ++++++++++++++++++++++++++++++++---------- wrap/glw/object.h | 16 +++++----- wrap/glw/type.h | 2 +- 4 files changed, 71 insertions(+), 35 deletions(-) diff --git a/wrap/glw/bookkeeping.h b/wrap/glw/bookkeeping.h index 833f7167..26bc6ac2 100644 --- a/wrap/glw/bookkeeping.h +++ b/wrap/glw/bookkeeping.h @@ -9,17 +9,17 @@ namespace glw namespace detail { - struct NoBase { }; + struct NoType { }; template struct DefaultDeleter { void operator () (T * t) { delete t; } }; -template struct BaseOf { typedef NoBase Type; }; +template struct BaseOf { typedef NoType Type; }; template struct RootOfType { typedef typename RootOfType::Type>::Type Type; }; -template struct RootOfType { typedef T Type; }; +template struct RootOfType { typedef T Type; }; template struct RootOf { typedef typename RootOfType::Type>::Type Type; }; template struct DeleterOfType { typedef typename DeleterOfType::Type>::Type Type; }; -template struct DeleterOfType { typedef DefaultDeleter Type; }; +template struct DeleterOfType { typedef DefaultDeleter Type; }; template struct DeleterOf { typedef typename DeleterOfType::Type>::Type Type; }; template @@ -51,15 +51,15 @@ class RefCountedObject : public RefCountedObject -class RefCountedObject +class RefCountedObject { public: typedef void BaseType; - typedef RefCountedObject ThisType; + typedef RefCountedObject ThisType; typedef TObject ObjectType; typedef TDeleter DeleterType; - typedef NoBase BaseObjectType; + typedef NoType BaseObjectType; RefCountedObject(ObjectType * object, const DeleterType & deleter) : m_object (object) @@ -216,16 +216,16 @@ class ObjectSharedPointer : public ObjectSharedPointer -class ObjectSharedPointer +class ObjectSharedPointer { public: typedef void BaseType; - typedef ObjectSharedPointer ThisType; + typedef ObjectSharedPointer ThisType; typedef TObject ObjectType; typedef TDeleter DeleterType; - typedef NoBase BaseObjectType; - typedef RefCountedObject RefCountedObjectType; + typedef NoType BaseObjectType; + typedef RefCountedObject RefCountedObjectType; ObjectSharedPointer(void) : m_refObject(0) diff --git a/wrap/glw/context.h b/wrap/glw/context.h index dbdf65c9..515b5cbe 100644 --- a/wrap/glw/context.h +++ b/wrap/glw/context.h @@ -29,8 +29,10 @@ class Context : public detail::NonCopyable typedef Context ThisType; Context(void) - : m_acquired (false) - , m_textureUnits (0) + : m_acquired (false) + , m_maxUniformBuffers (0) + , m_maxFeedbackBuffers (0) + , m_maxTextureUnits (0) { ; } @@ -387,7 +389,9 @@ class Context : public detail::NonCopyable typedef RefCountedBindingPtrMap::value_type RefCountedBindingPtrMapValue; bool m_acquired; - int m_textureUnits; + int m_maxUniformBuffers; + int m_maxFeedbackBuffers; + int m_maxTextureUnits; RefCountedPtrPtrMap m_objects; RefCountedBindingPtrMap m_bindings; @@ -418,8 +422,6 @@ class Context : public detail::NonCopyable this->initializeTarget(IndexBufferBindingParams () ); this->initializeTarget(PixelPackBufferBindingParams () ); this->initializeTarget(PixelUnpackBufferBindingParams () ); - this->initializeTarget(UniformBufferBindingParams (0, 0, 0)); - this->initializeTarget(FeedbackBufferBindingParams (0, 0, 0)); this->initializeTarget(RenderbufferBindingParams () ); this->initializeTarget(VertexShaderBindingParams () ); this->initializeTarget(GeometryShaderBindingParams () ); @@ -430,14 +432,33 @@ class Context : public detail::NonCopyable this->initializeTarget(ReadDrawFramebufferBindingParams () ); { - GLint texUnits = 0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texUnits); - this->m_textureUnits = int(texUnits); + GLint uniformBuffers = 0; + glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &uniformBuffers); + this->m_maxUniformBuffers = int(uniformBuffers); + for (int i=0; im_maxUniformBuffers; ++i) + { + this->initializeTarget(UniformBufferBindingParams(GLuint(i), 0, 0)); + } } - for (int i=0; im_textureUnits; ++i) { - this->initializeTarget(Texture2DBindingParams(GLint(i))); + GLint feedbackBuffers = 0; + glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &feedbackBuffers); + this->m_maxFeedbackBuffers = int(feedbackBuffers); + for (int i=0; im_maxFeedbackBuffers; ++i) + { + this->initializeTarget(FeedbackBufferBindingParams(GLuint(i), 0, 0)); + } + } + + { + GLint texUnits = 0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texUnits); + this->m_maxTextureUnits = int(texUnits); + for (int i=0; im_maxTextureUnits; ++i) + { + this->initializeTarget(Texture2DBindingParams(GLint(i))); + } } } @@ -447,8 +468,6 @@ class Context : public detail::NonCopyable this->terminateTarget(IndexBufferBindingParams () ); this->terminateTarget(PixelPackBufferBindingParams () ); this->terminateTarget(PixelUnpackBufferBindingParams () ); - this->terminateTarget(UniformBufferBindingParams (0, 0, 0)); - this->terminateTarget(FeedbackBufferBindingParams (0, 0, 0)); this->terminateTarget(RenderbufferBindingParams () ); this->terminateTarget(VertexShaderBindingParams () ); this->terminateTarget(GeometryShaderBindingParams () ); @@ -458,12 +477,29 @@ class Context : public detail::NonCopyable this->terminateTarget(DrawFramebufferBindingParams () ); this->terminateTarget(ReadDrawFramebufferBindingParams () ); - for (int i=0; im_textureUnits; ++i) { - this->terminateTarget(Texture2DBindingParams(GLint(i))); + for (int i=0; im_maxUniformBuffers; ++i) + { + this->terminateTarget(UniformBufferBindingParams(GLuint(i), 0, 0)); + } + this->m_maxUniformBuffers = 0; } - this->m_textureUnits = 0; + { + for (int i=0; im_maxFeedbackBuffers; ++i) + { + this->terminateTarget(FeedbackBufferBindingParams(GLuint(i), 0, 0)); + } + this->m_maxFeedbackBuffers = 0; + } + + { + for (int i=0; im_maxTextureUnits; ++i) + { + this->terminateTarget(Texture2DBindingParams(GLint(i))); + } + this->m_maxTextureUnits = 0; + } } template diff --git a/wrap/glw/object.h b/wrap/glw/object.h index 492108ac..7a5a802b 100644 --- a/wrap/glw/object.h +++ b/wrap/glw/object.h @@ -90,11 +90,11 @@ class Object : public detail::NonCopyable virtual bool doIsValid(void) const = 0; }; -namespace detail { template struct ObjectBase { typedef NoBase Type; }; }; -namespace detail { template struct ObjectSafe { typedef NoBase Type; }; }; -namespace detail { template struct ObjectBound { typedef NoBase Type; }; }; +namespace detail { template struct ObjectBase { typedef NoType Type; }; }; +namespace detail { template struct ObjectSafe { typedef NoType Type; }; }; +namespace detail { template struct ObjectBound { typedef NoType Type; }; }; -namespace detail { template <> struct BaseOf { typedef NoBase Type; }; }; +namespace detail { template <> struct BaseOf { typedef NoType Type; }; }; namespace detail { template <> struct DeleterOf { typedef ObjectDeleter Type; }; }; typedef detail::ObjectSharedPointerTraits ::Type ObjectPtr; @@ -149,7 +149,7 @@ class SafeObject : public detail::NonCopyable Type type(void) const { - if (this->isNull()) return NoType; + if (this->isNull()) return InvalidType; return this->m_object->type(); } @@ -176,7 +176,7 @@ class SafeObject : public detail::NonCopyable ObjectPtr m_object; }; -namespace detail { template <> struct BaseOf { typedef NoBase Type; }; }; +namespace detail { template <> struct BaseOf { typedef NoType Type; }; }; namespace detail { template <> struct DeleterOf { typedef DefaultDeleter Type; }; }; namespace detail { template <> struct ObjectBase { typedef Object Type; }; }; namespace detail { template <> struct ObjectSafe { typedef SafeObject Type; }; }; @@ -282,10 +282,10 @@ class BoundObject : public detail::NonCopyable virtual void unbind (void) = 0; }; -namespace detail { template struct ParamsOf { typedef NoBase Type; }; }; +namespace detail { template struct ParamsOf { typedef NoType Type; }; }; namespace detail { template <> struct ParamsOf { typedef ObjectBindingParams Type; }; }; -namespace detail { template <> struct BaseOf { typedef NoBase Type; }; }; +namespace detail { template <> struct BaseOf { typedef NoType Type; }; }; namespace detail { template <> struct DeleterOf { typedef DefaultDeleter Type; }; }; namespace detail { template <> struct ObjectBase { typedef Object Type; }; }; namespace detail { template <> struct ObjectBound { typedef BoundObject Type; }; }; diff --git a/wrap/glw/type.h b/wrap/glw/type.h index ccd936c5..c0dc799d 100644 --- a/wrap/glw/type.h +++ b/wrap/glw/type.h @@ -8,7 +8,7 @@ namespace glw enum Type { - NoType = 0, + InvalidType = 0, BufferType, RenderbufferType, VertexShaderType,