From 0a3c77c3ea9a86830312dca5213a129613c70bca Mon Sep 17 00:00:00 2001 From: Lars Krecklau Date: Fri, 19 Aug 2011 15:00:59 +0200 Subject: [PATCH] - VertexBuffer and FrameBuffer renamed to VertexBufferObject and FrameBufferObject respectively. This convention is more consistent regarding the State, which now gets a FrameBufferObject (FBO), VertexBufferObject (VBO) and ShaderProgramObject (SPO) - Added controllers and objects to the Controller.hh and Objects.hh respectively - Added corresponding managers --- include/ACGL/OpenGL/Controller.hh | 14 +++-- ...Control.hh => FrameBufferObjectControl.hh} | 37 +++++------ .../Controller/ShaderProgramObjectControl.hh | 2 +- .../ACGL/OpenGL/Controller/StateControl.hh | 32 +++++----- ...ontrol.hh => VertexBufferObjectControl.hh} | 32 +++++----- ...hh => VertexBufferObjectControlFileOBJ.hh} | 22 +++---- include/ACGL/OpenGL/Managers.hh | 23 ++++--- include/ACGL/OpenGL/Objects.hh | 14 +++-- .../{FrameBuffer.hh => FrameBufferObject.hh} | 34 +++++----- .../OpenGL/Objects/ShaderProgramObject.hh | 4 +- include/ACGL/OpenGL/Objects/State.hh | 63 +++++++++++-------- ...{VertexBuffer.hh => VertexBufferObject.hh} | 24 +++---- ...Control.cc => FrameBufferObjectControl.cc} | 8 +-- ...ontrol.cc => VertexBufferObjectControl.cc} | 8 +-- ...cc => VertexBufferObjectControlFileOBJ.cc} | 14 ++--- .../{FrameBuffer.cc => FrameBufferObject.cc} | 12 ++-- src/ACGL/OpenGL/Objects/State.cc | 45 +++++++------ ...{VertexBuffer.cc => VertexBufferObject.cc} | 16 ++--- 18 files changed, 211 insertions(+), 193 deletions(-) rename include/ACGL/OpenGL/Controller/{FrameBufferControl.hh => FrameBufferObjectControl.hh} (61%) rename include/ACGL/OpenGL/Controller/{VertexBufferControl.hh => VertexBufferObjectControl.hh} (71%) rename include/ACGL/OpenGL/Controller/{VertexBufferControlFileOBJ.hh => VertexBufferObjectControlFileOBJ.hh} (62%) rename include/ACGL/OpenGL/Objects/{FrameBuffer.hh => FrameBufferObject.hh} (89%) rename include/ACGL/OpenGL/Objects/{VertexBuffer.hh => VertexBufferObject.hh} (92%) rename src/ACGL/OpenGL/Controller/{FrameBufferControl.cc => FrameBufferObjectControl.cc} (76%) rename src/ACGL/OpenGL/Controller/{VertexBufferControl.cc => VertexBufferObjectControl.cc} (80%) rename src/ACGL/OpenGL/Controller/{VertexBufferControlFileOBJ.cc => VertexBufferObjectControlFileOBJ.cc} (96%) rename src/ACGL/OpenGL/Objects/{FrameBuffer.cc => FrameBufferObject.cc} (80%) rename src/ACGL/OpenGL/Objects/{VertexBuffer.cc => VertexBufferObject.cc} (75%) diff --git a/include/ACGL/OpenGL/Controller.hh b/include/ACGL/OpenGL/Controller.hh index c755e36..cd23952 100644 --- a/include/ACGL/OpenGL/Controller.hh +++ b/include/ACGL/OpenGL/Controller.hh @@ -18,15 +18,17 @@ #include #include +#include +#include +#include +#include #include #include +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include #endif // ACGL_OPENGL_CONTROLLER_HH diff --git a/include/ACGL/OpenGL/Controller/FrameBufferControl.hh b/include/ACGL/OpenGL/Controller/FrameBufferObjectControl.hh similarity index 61% rename from include/ACGL/OpenGL/Controller/FrameBufferControl.hh rename to include/ACGL/OpenGL/Controller/FrameBufferObjectControl.hh index cba3b77..f8b0d80 100644 --- a/include/ACGL/OpenGL/Controller/FrameBufferControl.hh +++ b/include/ACGL/OpenGL/Controller/FrameBufferObjectControl.hh @@ -3,13 +3,13 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#ifndef ACGL_OPENGL_CONTROLLER_FRAMEBUFFERCONTROL_HH -#define ACGL_OPENGL_CONTROLLER_FRAMEBUFFERCONTROL_HH +#ifndef ACGL_OPENGL_CONTROLLER_FRAMEBUFFEROBJECTCONTROL_HH +#define ACGL_OPENGL_CONTROLLER_FRAMEBUFFEROBJECTCONTROL_HH #include #include -#include +#include #include #include @@ -18,41 +18,38 @@ namespace ACGL{ namespace OpenGL{ -class FrameBufferControl : public Resource::BasicCreateController +class FrameBufferObjectControl : public Resource::BasicCreateController { // ========================================================================================================= \/ // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: - FrameBufferControl(void) - : mWidth(0), - mHeight(0), - mColorAttachments(), + FrameBufferObjectControl(void) + : mColorAttachments(), mDepthAttachment() { mDepthAttachment.name = ""; mDepthAttachment.texture = SharedTexture(); mDepthAttachment.renderBuffer = SharedRenderBuffer(); } - virtual ~FrameBufferControl() {} + virtual ~FrameBufferObjectControl() {} // ==================================================================================================== \/ // ============================================================================================ METHODS \/ // ==================================================================================================== \/ public: - inline FrameBufferControl& size (GLsizei _width, GLsizei _height) { mWidth = _width; mHeight = _height; return *this; } - inline FrameBufferControl& depthTexture (const SharedTexture& _pDepthTexture) { mDepthAttachment.texture = _pDepthTexture; return *this; } - inline FrameBufferControl& depthRenderBuffer (const SharedRenderBuffer& _pDepthRenderBuffer) { mDepthAttachment.renderBuffer = _pDepthRenderBuffer; return *this; } + inline FrameBufferObjectControl& depthTexture (const SharedTexture& _pDepthTexture) { mDepthAttachment.texture = _pDepthTexture; return *this; } + inline FrameBufferObjectControl& depthRenderBuffer (const SharedRenderBuffer& _pDepthRenderBuffer) { mDepthAttachment.renderBuffer = _pDepthRenderBuffer; return *this; } - inline FrameBufferControl& colorTexture(const std::string& _name, const SharedTexture& _texture) + inline FrameBufferObjectControl& colorTexture(const std::string& _name, const SharedTexture& _texture) { - FrameBuffer::Attachment attachment = {_name, _texture, SharedRenderBuffer()}; + FrameBufferObject::Attachment attachment = {_name, _texture, SharedRenderBuffer()}; mColorAttachments.push_back(attachment); return *this; } - inline FrameBufferControl& colorRenderBuffer(const std::string& _name, const SharedRenderBuffer& _renderBuffer) + inline FrameBufferObjectControl& colorRenderBuffer(const std::string& _name, const SharedRenderBuffer& _renderBuffer) { - FrameBuffer::Attachment attachment = {_name, SharedTexture(), _renderBuffer}; + FrameBufferObject::Attachment attachment = {_name, SharedTexture(), _renderBuffer}; mColorAttachments.push_back(attachment); return *this; } @@ -61,16 +58,14 @@ public: // ============================================================================================ OVERRIDE \/ // ===================================================================================================== \/ public: - virtual SharedFrameBuffer create (void); + virtual SharedFrameBufferObject create (void); // =================================================================================================== \/ // ============================================================================================ FIELDS \/ // =================================================================================================== \/ protected: - GLsizei mWidth; - GLsizei mHeight; - FrameBuffer::AttachmentVec mColorAttachments; - FrameBuffer::Attachment mDepthAttachment; + FrameBufferObject::AttachmentVec mColorAttachments; + FrameBufferObject::Attachment mDepthAttachment; }; } // OpenGL diff --git a/include/ACGL/OpenGL/Controller/ShaderProgramObjectControl.hh b/include/ACGL/OpenGL/Controller/ShaderProgramObjectControl.hh index 9cbd323..c2a1618 100644 --- a/include/ACGL/OpenGL/Controller/ShaderProgramObjectControl.hh +++ b/include/ACGL/OpenGL/Controller/ShaderProgramObjectControl.hh @@ -92,4 +92,4 @@ protected: } // OpenGL } // ACGL -#endif // ACGL_OPENGL_CONTROLLER_ShaderProgramObjectControl_HH +#endif // ACGL_OPENGL_CONTROLLER_SHADERPROGRAMOBJECTCONTROL_HH diff --git a/include/ACGL/OpenGL/Controller/StateControl.hh b/include/ACGL/OpenGL/Controller/StateControl.hh index a745274..b24b6de 100644 --- a/include/ACGL/OpenGL/Controller/StateControl.hh +++ b/include/ACGL/OpenGL/Controller/StateControl.hh @@ -15,19 +15,19 @@ namespace ACGL{ namespace OpenGL{ -class StateControl : public Resource::BasicCreateController +class StateControl : public Resource::BasicCreateController { // ========================================================================================================= \/ // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: StateControl( - const ConstSharedVertexBuffer& _vertexBuffer, - const ConstSharedVertexBuffer& _frameBuffer, - const ConstSharedVertexBuffer& _shaderProgram, - const ConstSharedVertexBuffer& _viewport) - : mpVertexBuffer(_vertexBuffer), - mpFrameBuffer(_frameBuffer), + const ConstSharedVertexBufferObject& _vertexBufferObject, + const ConstSharedFrameBufferObject& _frameBufferObject, + const ConstSharedShaderProgram& _shaderProgram, + const ConstSharedViewport& _viewport) + : mpVertexBufferObject(_vertexBufferObject), + mpFrameBufferObject(_frameBufferObject), mpShaderProgram(_shaderProgram), mpViewport(_viewport) {} @@ -37,10 +37,10 @@ public: // ============================================================================================ GETTERS \/ // ==================================================================================================== \/ public: - inline StateControl& vertexBuffer (const ConstSharedVertexBuffer& _vertexBuffer) { mpVertexBuffer = _vertexBuffer; return *this; } - inline StateControl& frameBuffer (const ConstSharedFrameBuffer& _frameBuffer) { mpFrameBuffer = _frameBuffer; return *this; } - inline StateControl& shaderProgram (const ConstSharedShaderProgram& _shaderProgram) { mpShaderProgram = _shaderProgram; return *this; } - inline StateControl& viewport (const ConstSharedShaderProgram& _viewport) { mpViewport = _viewport; return *this; } + inline StateControl& vertexBuffer (const ConstSharedVertexBufferObject& _vertexBufferObject) { mpVertexBufferObject = _vertexBufferObject; return *this; } + inline StateControl& frameBuffer (const ConstSharedFrameBufferObject& _frameBufferObject) { mpFrameBufferObject = _frameBufferObject; return *this; } + inline StateControl& shaderProgram (const ConstSharedShaderProgram& _shaderProgram) { mpShaderProgram = _shaderProgram; return *this; } + inline StateControl& viewport (const ConstSharedViewport& _viewport) { mpViewport = _viewport; return *this; } // ===================================================================================================== \/ // ============================================================================================ OVERRIDE \/ @@ -48,7 +48,7 @@ public: public: virtual SharedState create(void) { - SharedState state(new State(mpVertexBuffer, mpFrameBuffer, mpShaderProgram, mpViewport)); + SharedState state(new State(mpVertexBufferObject, mpFrameBufferObject, mpShaderProgram, mpViewport)); return state; } @@ -57,10 +57,10 @@ public: // ============================================================================================ FIELDS \/ // =================================================================================================== \/ protected: - ConstSharedVertexBuffer mpVertexBuffer; - ConstSharedFrameBuffer mpFrameBuffer; - ConstSharedShaderProgram mpShaderProgram; - ConstSharedViewport mpViewport; + ConstSharedVertexBufferObject mpVertexBufferObject; + ConstSharedFrameBufferObject mpFrameBufferObject; + ConstSharedShaderProgram mpShaderProgram; + ConstSharedViewport mpViewport; }; } // OpenGL diff --git a/include/ACGL/OpenGL/Controller/VertexBufferControl.hh b/include/ACGL/OpenGL/Controller/VertexBufferObjectControl.hh similarity index 71% rename from include/ACGL/OpenGL/Controller/VertexBufferControl.hh rename to include/ACGL/OpenGL/Controller/VertexBufferObjectControl.hh index 1833621..d206fd5 100644 --- a/include/ACGL/OpenGL/Controller/VertexBufferControl.hh +++ b/include/ACGL/OpenGL/Controller/VertexBufferObjectControl.hh @@ -3,19 +3,19 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#ifndef ACGL_OPENGL_CONTROLLER_VERTEXBUFFERCONTROL_HH -#define ACGL_OPENGL_CONTROLLER_VERTEXBUFFERCONTROL_HH +#ifndef ACGL_OPENGL_CONTROLLER_VERTEXBUFFEROBJECTCONTROL_HH +#define ACGL_OPENGL_CONTROLLER_VERTEXBUFFEROBJECTCONTROL_HH #include #include -#include +#include #include namespace ACGL{ namespace OpenGL{ -class VertexBufferControl : public Resource::BasicCreateController +class VertexBufferObjectControl : public Resource::BasicCreateController { // ==================================================================================================== \/ // ============================================================================================ STRUCTS \/ @@ -38,29 +38,29 @@ public: // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: - VertexBufferControl(void) - : Resource::BasicCreateController(), + VertexBufferObjectControl(void) + : Resource::BasicCreateController(), mpElementArrayBuffer(), mArrayBuffers(), mAttributeDefines() {} - virtual ~VertexBufferControl() {} + virtual ~VertexBufferObjectControl() {} // ==================================================================================================== \/ // ============================================================================================ METHODS \/ // ==================================================================================================== \/ public: - inline VertexBufferControl& index (const SharedElementArrayBuffer& _elementArrayBuffer) { mpElementArrayBuffer = _elementArrayBuffer; return *this; } - inline VertexBufferControl& data (const SharedArrayBuffer& _vertexBuffer) { mArrayBuffers.push_back(_vertexBuffer); return *this; } + inline VertexBufferObjectControl& index (const SharedElementArrayBuffer& _elementArrayBuffer) { mpElementArrayBuffer = _elementArrayBuffer; return *this; } + inline VertexBufferObjectControl& data (const SharedArrayBuffer& _vertexBuffer) { mArrayBuffers.push_back(_vertexBuffer); return *this; } - inline VertexBufferControl& attribute (const std::string& _name, const std::string& _nameInArray) + inline VertexBufferObjectControl& attribute (const std::string& _name, const std::string& _nameInArray) { AttributeDefine a = {_name, mArrayBuffers.size()-1, _nameInArray}; mAttributeDefines.push_back(a); return *this; } - inline VertexBufferControl& attribute (const std::string& _name, int_t _bufferID, const std::string& _nameInArray) + inline VertexBufferObjectControl& attribute (const std::string& _name, int_t _bufferID, const std::string& _nameInArray) { AttributeDefine a = {_name, _bufferID, _nameInArray}; mAttributeDefines.push_back(a); @@ -71,18 +71,18 @@ public: // ============================================================================================ OVERRIDE \/ // ===================================================================================================== \/ public: - virtual SharedVertexBuffer create(void); + virtual SharedVertexBufferObject create(void); // =================================================================================================== \/ // ============================================================================================ FIELDS \/ // =================================================================================================== \/ protected: - SharedElementArrayBuffer mpElementArrayBuffer; - VertexBuffer::ArrayBufferVec mArrayBuffers; - AttributeDefineVec mAttributeDefines; + SharedElementArrayBuffer mpElementArrayBuffer; + VertexBufferObject::ArrayBufferVec mArrayBuffers; + AttributeDefineVec mAttributeDefines; }; } // OpenGL } // ACGL -#endif // ACGL_OPENGL_CONTROLLER_VERTEXBUFFERCONTROL_HH +#endif // ACGL_OPENGL_CONTROLLER_VERTEXBUFFEROBJECTCONTROL_HH diff --git a/include/ACGL/OpenGL/Controller/VertexBufferControlFileOBJ.hh b/include/ACGL/OpenGL/Controller/VertexBufferObjectControlFileOBJ.hh similarity index 62% rename from include/ACGL/OpenGL/Controller/VertexBufferControlFileOBJ.hh rename to include/ACGL/OpenGL/Controller/VertexBufferObjectControlFileOBJ.hh index ad452a6..3508fbd 100644 --- a/include/ACGL/OpenGL/Controller/VertexBufferControlFileOBJ.hh +++ b/include/ACGL/OpenGL/Controller/VertexBufferObjectControlFileOBJ.hh @@ -3,42 +3,42 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#ifndef ACGL_OPENGL_CONTROLLER_VERTEXBUFFERCONTROLFILEOBJ_HH -#define ACGL_OPENGL_CONTROLLER_VERTEXBUFFERCONTROLFILEOBJ_HH +#ifndef ACGL_OPENGL_CONTROLLER_VERTEXBUFFEROBJECTCONTROLFILEOBJ_HH +#define ACGL_OPENGL_CONTROLLER_VERTEXBUFFEROBJECTCONTROLFILEOBJ_HH #include #include #include -#include +#include #include namespace ACGL{ namespace OpenGL{ -class VertexBufferControlFileOBJ : public Resource::FileController +class VertexBufferObjectControlFileOBJ : public Resource::FileController { // ========================================================================================================= \/ // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: - VertexBufferControlFileOBJ(const std::string& _filename) - : Resource::FileController(_filename, Base::Settings::the()->getFullGeometryPath()) + VertexBufferObjectControlFileOBJ(const std::string& _filename) + : Resource::FileController(_filename, Base::Settings::the()->getFullGeometryPath()) {} - virtual ~VertexBufferControlFileOBJ() {} + virtual ~VertexBufferObjectControlFileOBJ() {} private: - bool loadOBJ(SharedVertexBuffer& vertexBuffer); + bool loadOBJ(SharedVertexBufferObject& vertexBuffer); // ===================================================================================================== \/ // ============================================================================================ OVERRIDE \/ // ===================================================================================================== \/ public: - virtual SharedVertexBuffer create(void); - virtual bool update(SharedVertexBuffer& vertexBuffer); + virtual SharedVertexBufferObject create(void); + virtual bool update(SharedVertexBufferObject& vertexBuffer); }; } // OpenGL } // ACGL -#endif // ACGL_OPENGL_CONTROLLER_VERTEXBUFFERCONTROLFILEOBJ_HH +#endif // ACGL_OPENGL_CONTROLLER_VERTEXBUFFEROBJECTCONTROLFILEOBJ_HH diff --git a/include/ACGL/OpenGL/Managers.hh b/include/ACGL/OpenGL/Managers.hh index b9e50c3..996d759 100644 --- a/include/ACGL/OpenGL/Managers.hh +++ b/include/ACGL/OpenGL/Managers.hh @@ -21,25 +21,30 @@ namespace ACGL{ namespace OpenGL{ +typedef Resource::NameManager ArrayBufferNameManager; + +typedef Resource::NameManager ElementArrayBufferNameManager; + +typedef Resource::NameManager FrameBufferObjectNameManager; + +typedef Resource::NameManager RenderBufferNameManager; + typedef Resource::NameManager ShaderNameManager; typedef Resource::FileManager ShaderFileManager; typedef Resource::NameManager ShaderProgramNameManager; typedef Resource::FileManager ShaderProgramFileManager; -typedef Resource::NameManager TextureNameManager; -typedef Resource::FileManager TextureFileManager; - -typedef Resource::NameManager FrameBufferNameManager; +typedef Resource::NameManager ShaderProgramObjectNameManager; -typedef Resource::NameManager RenderBufferNameManager; +typedef Resource::NameManager StateNameManager; -typedef Resource::NameManager VertexBufferNameManager; -typedef Resource::FileManager VertexBufferFileManager; +typedef Resource::NameManager TextureNameManager; +typedef Resource::FileManager TextureFileManager; -typedef Resource::NameManager ArrayBufferNameManager; +typedef Resource::NameManager VertexBufferObjectNameManager; +typedef Resource::FileManager VertexBufferObjectFileManager; -typedef Resource::NameManager ElementArrayBufferNameManager; } // OpenGL } // ACGL diff --git a/include/ACGL/OpenGL/Objects.hh b/include/ACGL/OpenGL/Objects.hh index 0769132..f533a88 100644 --- a/include/ACGL/OpenGL/Objects.hh +++ b/include/ACGL/OpenGL/Objects.hh @@ -12,14 +12,18 @@ #include +#include +#include +#include +#include #include #include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include #endif // ACGL_OPENGL_OBJECTS_HH diff --git a/include/ACGL/OpenGL/Objects/FrameBuffer.hh b/include/ACGL/OpenGL/Objects/FrameBufferObject.hh similarity index 89% rename from include/ACGL/OpenGL/Objects/FrameBuffer.hh rename to include/ACGL/OpenGL/Objects/FrameBufferObject.hh index fa997e7..9090fca 100644 --- a/include/ACGL/OpenGL/Objects/FrameBuffer.hh +++ b/include/ACGL/OpenGL/Objects/FrameBufferObject.hh @@ -3,18 +3,18 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#ifndef ACGL_OPENGL_OBJECTS_FRAMEBUFFER_HH -#define ACGL_OPENGL_OBJECTS_FRAMEBUFFER_HH +#ifndef ACGL_OPENGL_OBJECTS_FRAMEBUFFEROBJECT_HH +#define ACGL_OPENGL_OBJECTS_FRAMEBUFFEROBJECT_HH /* - * This FrameBuffer class encapsulates an OpenGL frame buffer object (FBO). - * A FrameBuffer is a target for rendering and thus consists of different "layers": + * This FrameBufferObject class encapsulates an OpenGL frame buffer object (FBO). + * A FrameBufferObject is a target for rendering and thus consists of different "layers": * * one or no depthbuffer * one or no stencilbuffer * one (OpenGL ES) to many (hardware dependent limit) colorbuffers * - * These buffers get attached to the FrameBuffer. + * These buffers get attached to the FrameBufferObject. * * There exists one system-provided frame buffer object for rendering to the screen * and optionaly multiple user defined frame buffer objects for offscreen rendering. @@ -37,9 +37,9 @@ namespace ACGL{ namespace OpenGL{ -class FrameBuffer +class FrameBufferObject { - ACGL_NOT_COPYABLE(FrameBuffer) + ACGL_NOT_COPYABLE(FrameBufferObject) // =================================================================================================== \/ // ============================================================================================ STATIC \/ @@ -69,7 +69,7 @@ public: // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: - FrameBuffer(GLsizei _width, GLsizei _height) + FrameBufferObject(void) : mContext(0), mDrawBuffers(0), mColorAttachments(), @@ -77,7 +77,7 @@ public: { glGenFramebuffers(1, &mContext); if (openGLCriticalErrorOccured() ) { - ACGL::Utils::error() << "could not generate framebuffer!" << std::endl; + ACGL::Utils::error() << "could not generate FrameBufferObject!" << std::endl; return; } mDepthAttachment.name = ""; @@ -85,7 +85,7 @@ public: mDepthAttachment.renderBuffer = SharedRenderBuffer(); } - virtual ~FrameBuffer(void) + virtual ~FrameBufferObject(void) { // buffer 0 will get ignored by OpenGL glDeleteFramebuffers(1, &mContext); @@ -105,11 +105,11 @@ public: public: int_t getColorAttachmentIndexByName(const std::string& _name) const; - void validate( void ) const; + void validate (void) const; /** - * Per default a FrameBuffer gets used for read/write operations, but we can - * bind two different FrameBuffers for these operations! + * Per default a FrameBufferObject gets used for read/write operations, but we can + * bind two different FrameBufferObjects for these operations! */ inline void bind(GLenum _type = GL_FRAMEBUFFER) const { @@ -131,11 +131,11 @@ public: openGLRareError(); } - inline bool isFrameBufferComplete(void) const + inline bool isFrameBufferObjectComplete(void) const { if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - Utils::error() << "Failed to make complete FrameBuffer object: " << (glCheckFramebufferStatus(GL_FRAMEBUFFER)) << std::endl; + Utils::error() << "Failed to make complete FrameBufferObject object: " << (glCheckFramebufferStatus(GL_FRAMEBUFFER)) << std::endl; return false; } return true; @@ -209,9 +209,9 @@ protected: Attachment mDepthAttachment; // depth and stencil are combined }; -ACGL_SHARED_TYPEDEF(FrameBuffer) +ACGL_SHARED_TYPEDEF(FrameBufferObject) } // OpenGL } // ACGL -#endif // ACGL_OPENGL_OBJECTS_FRAMEBUFFER_HH +#endif // ACGL_OPENGL_OBJECTS_FRAMEBUFFEROBJECT_HH diff --git a/include/ACGL/OpenGL/Objects/ShaderProgramObject.hh b/include/ACGL/OpenGL/Objects/ShaderProgramObject.hh index b1e9254..4f7e67c 100644 --- a/include/ACGL/OpenGL/Objects/ShaderProgramObject.hh +++ b/include/ACGL/OpenGL/Objects/ShaderProgramObject.hh @@ -61,7 +61,7 @@ public: // ============================================================================================ GETTERS \/ // ==================================================================================================== \/ public: - inline const ConstSharedShaderProgram& getShaderProgram (void) const { return mpShaderProgram; } + inline const ConstSharedShaderProgram& getShaderProgram (void) const { return mpShaderProgram; } inline const UniformAttachmentVec& getUniformAttachments (void) const { return mUniformAttachments; } inline const UniformTextureAttachmentVec& getUniformTextureAttachments (void) const { return mUniformTextureAttachments; } @@ -105,4 +105,4 @@ ACGL_SHARED_TYPEDEF(ShaderProgramObject) } // OpenGL } // ACGL -#endif // ACGL_OPENGL_OBJECTS_ShaderProgramObject_HH +#endif // ACGL_OPENGL_OBJECTS_SHADERPROGRAMOBJECT_HH diff --git a/include/ACGL/OpenGL/Objects/State.hh b/include/ACGL/OpenGL/Objects/State.hh index f54f0d7..8f3a632 100644 --- a/include/ACGL/OpenGL/Objects/State.hh +++ b/include/ACGL/OpenGL/Objects/State.hh @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -33,15 +33,15 @@ class State private: struct AttributeMapping { - int arrayBufferID; - int vertexBufferAttribute; - int shaderProgramAttribute; + int_t arrayBufferID; + int_t vertexBufferObjectAttribute; + int_t shaderProgramAttributeLocation; }; struct FragmentDataMapping { - int frameBufferColorAttachment; - int shaderProgramFragmentData; + int_t frameBufferObjectColorAttachment; + int_t shaderProgramFragmentDataLocation; }; // ===================================================================================================== \/ // ============================================================================================ TYPEDEFS \/ @@ -54,12 +54,12 @@ private: // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: - State(ConstSharedVertexBuffer _vertexBuffer, - ConstSharedFrameBuffer _frameBuffer, + State(ConstSharedVertexBufferObject _VertexBufferObject, + ConstSharedFrameBufferObject _FrameBufferObject, ConstSharedShaderProgram _shaderProgram, ConstSharedViewport _viewport) - : mpVertexBuffer(_vertexBuffer), - mpFrameBuffer(_frameBuffer), + : mpVertexBufferObject(_VertexBufferObject), + mpFrameBufferObject(_FrameBufferObject), mpShaderProgram(_shaderProgram), mpViewport(_viewport), mAttributeMappings(), @@ -79,34 +79,47 @@ public: // ============================================================================================ GETTERS \/ // ==================================================================================================== \/ public: - inline ConstSharedVertexBuffer getVertexBuffer (void) const { return mpVertexBuffer; } - inline ConstSharedFrameBuffer getFrameBuffer (void) const { return mpFrameBuffer; } - inline ConstSharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; } - inline ConstSharedViewport getViewport (void) const { return mpViewport; } + inline ConstSharedVertexBufferObject getVertexBufferObject (void) const { return mpVertexBufferObject; } + inline ConstSharedFrameBufferObject getFrameBufferObject (void) const { return mpFrameBufferObject; } + inline ConstSharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; } + inline ConstSharedViewport getViewport (void) const { return mpViewport; } // ==================================================================================================== \/ // ============================================================================================ METHODS \/ // ==================================================================================================== \/ public: + void useViewport (void); + void enableVertexBufferObject (void); + void bindFrameBufferObject (void); + void disableVertexBufferObject (void); + void updateMappings (void); + inline void validate (void) const { - mpFrameBuffer->validate(); - mpVertexBuffer->validate(); + mpFrameBufferObject->validate(); + mpVertexBufferObject->validate(); } - void useViewport (void); - void enableVertexBuffer (void); - void bindFrameBuffer (void); - void disableVertexBuffer (void); - void updateMappings (void); - void render (void); + inline void draw(void) + { + mpVertexBufferObject->draw(); + } + + inline void render(void) + { + useViewport(); + bindFrameBufferObject(); + enableVertexBufferObject(); + draw(); + disableVertexBufferObject(); + } // =================================================================================================== \/ // ============================================================================================ FIELDS \/ // =================================================================================================== \/ protected: - ConstSharedVertexBuffer mpVertexBuffer; - ConstSharedFrameBuffer mpFrameBuffer; + ConstSharedVertexBufferObject mpVertexBufferObject; + ConstSharedFrameBufferObject mpFrameBufferObject; ConstSharedShaderProgram mpShaderProgram; ConstSharedViewport mpViewport; diff --git a/include/ACGL/OpenGL/Objects/VertexBuffer.hh b/include/ACGL/OpenGL/Objects/VertexBufferObject.hh similarity index 92% rename from include/ACGL/OpenGL/Objects/VertexBuffer.hh rename to include/ACGL/OpenGL/Objects/VertexBufferObject.hh index b2b2d3f..99c2a9c 100644 --- a/include/ACGL/OpenGL/Objects/VertexBuffer.hh +++ b/include/ACGL/OpenGL/Objects/VertexBufferObject.hh @@ -3,8 +3,8 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#ifndef ACGL_OPENGL_OBJECTS_VERTEXBUFFER_HH -#define ACGL_OPENGL_OBJECTS_VERTEXBUFFER_HH +#ifndef ACGL_OPENGL_OBJECTS_VERTEXBUFFEROBJECT_HH +#define ACGL_OPENGL_OBJECTS_VERTEXBUFFEROBJECT_HH #include @@ -19,9 +19,9 @@ namespace ACGL{ namespace OpenGL{ -class VertexBuffer +class VertexBufferObject { - ACGL_NOT_COPYABLE(VertexBuffer) + ACGL_NOT_COPYABLE(VertexBufferObject) // ==================================================================================================== \/ // ============================================================================================ STRUCTS \/ @@ -45,13 +45,13 @@ public: // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: - VertexBuffer(void) + VertexBufferObject(void) : mpElementArrayBuffer(), mArrayBuffers(), mAttributes() {} - virtual ~VertexBuffer(void) {}; + virtual ~VertexBufferObject(void) {}; // ==================================================================================================== \/ // ============================================================================================ GETTERS \/ @@ -79,7 +79,7 @@ public: _indexInShader); } - void validate( void ) const; + void validate (void) const; inline void setElementArrayBuffer(const SharedElementArrayBuffer& _elementArrayBuffer) { @@ -117,11 +117,11 @@ public: // ============================================================================================ WRAPPERS \/ // ===================================================================================================== \/ public: - void enable ( void ) const; - void disable( void ) const; + void enable (void) const; + void disable (void) const; - inline void render ( void ) const + inline void render (void) const { enable(); draw(); @@ -158,9 +158,9 @@ protected: AttributeVec mAttributes; }; -ACGL_SHARED_TYPEDEF(VertexBuffer) +ACGL_SHARED_TYPEDEF(VertexBufferObject) } // OpenGL } // ACGL -#endif // ACGL_OPENGL_OBJECTS_VERTEXBUFFER_HH +#endif // ACGL_OPENGL_OBJECTS_VERTEXBUFFEROBJECT_HH diff --git a/src/ACGL/OpenGL/Controller/FrameBufferControl.cc b/src/ACGL/OpenGL/Controller/FrameBufferObjectControl.cc similarity index 76% rename from src/ACGL/OpenGL/Controller/FrameBufferControl.cc rename to src/ACGL/OpenGL/Controller/FrameBufferObjectControl.cc index f6c1271..4048bde 100644 --- a/src/ACGL/OpenGL/Controller/FrameBufferControl.cc +++ b/src/ACGL/OpenGL/Controller/FrameBufferObjectControl.cc @@ -3,16 +3,16 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#include +#include using namespace ACGL::OpenGL; -SharedFrameBuffer FrameBufferControl::create(void) +SharedFrameBufferObject FrameBufferObjectControl::create(void) { - SharedFrameBuffer frameBuffer(new FrameBuffer(mWidth, mHeight)); + SharedFrameBufferObject frameBuffer(new FrameBufferObject()); frameBuffer->bind(); - for(FrameBuffer::AttachmentVec::size_type i = 0; i < mColorAttachments.size(); ++i) + for(FrameBufferObject::AttachmentVec::size_type i = 0; i < mColorAttachments.size(); ++i) { if(mColorAttachments[i].texture) frameBuffer->attachColorTexture(mColorAttachments[i].name, mColorAttachments[i].texture); diff --git a/src/ACGL/OpenGL/Controller/VertexBufferControl.cc b/src/ACGL/OpenGL/Controller/VertexBufferObjectControl.cc similarity index 80% rename from src/ACGL/OpenGL/Controller/VertexBufferControl.cc rename to src/ACGL/OpenGL/Controller/VertexBufferObjectControl.cc index ac2a7fe..dfd428f 100644 --- a/src/ACGL/OpenGL/Controller/VertexBufferControl.cc +++ b/src/ACGL/OpenGL/Controller/VertexBufferObjectControl.cc @@ -3,11 +3,11 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#include +#include using namespace ACGL::OpenGL; -SharedVertexBuffer VertexBufferControl::create(void) +SharedVertexBufferObject VertexBufferObjectControl::create(void) { GLenum mode = GL_TRIANGLES; GLsizei elements = 0; @@ -22,11 +22,11 @@ SharedVertexBuffer VertexBufferControl::create(void) elements = mArrayBuffers[0]->getElements(); } - SharedVertexBuffer vertexBuffer(new VertexBuffer()); + SharedVertexBufferObject vertexBuffer(new VertexBufferObject()); vertexBuffer->setElementArrayBuffer(mpElementArrayBuffer); - for(VertexBuffer::ArrayBufferVec::size_type i = 0; i < mArrayBuffers.size(); i++) + for(VertexBufferObject::ArrayBufferVec::size_type i = 0; i < mArrayBuffers.size(); i++) { vertexBuffer->attachArrayBuffer(mArrayBuffers[i]); } diff --git a/src/ACGL/OpenGL/Controller/VertexBufferControlFileOBJ.cc b/src/ACGL/OpenGL/Controller/VertexBufferObjectControlFileOBJ.cc similarity index 96% rename from src/ACGL/OpenGL/Controller/VertexBufferControlFileOBJ.cc rename to src/ACGL/OpenGL/Controller/VertexBufferObjectControlFileOBJ.cc index 2cfb94b..8a6751d 100644 --- a/src/ACGL/OpenGL/Controller/VertexBufferControlFileOBJ.cc +++ b/src/ACGL/OpenGL/Controller/VertexBufferObjectControlFileOBJ.cc @@ -3,10 +3,10 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#include +#include #include #include -#include +#include #include #include @@ -18,11 +18,11 @@ using namespace ACGL::Base; using namespace ACGL::Utils; using namespace ACGL::OpenGL; -SharedVertexBuffer VertexBufferControlFileOBJ::create(void) +SharedVertexBufferObject VertexBufferObjectControlFileOBJ::create(void) { updateFileModificationTime(); - SharedVertexBuffer vertexBuffer = VertexBufferControl(). + SharedVertexBufferObject vertexBuffer = VertexBufferObjectControl(). index(ElementArrayBufferControl(). mode(GL_TRIANGLES). usage(GL_STATIC_DRAW). @@ -36,10 +36,10 @@ SharedVertexBuffer VertexBufferControlFileOBJ::create(void) if(loadOBJ(vertexBuffer)) return vertexBuffer; - return SharedVertexBuffer(); + return SharedVertexBufferObject(); } -bool VertexBufferControlFileOBJ::update(SharedVertexBuffer& vertexBuffer) +bool VertexBufferObjectControlFileOBJ::update(SharedVertexBufferObject& vertexBuffer) { if(fileIsUpToDate()) return false; @@ -51,7 +51,7 @@ bool VertexBufferControlFileOBJ::update(SharedVertexBuffer& vertexBuffer) return true; } -bool VertexBufferControlFileOBJ::loadOBJ(SharedVertexBuffer& _vertexBuffer) +bool VertexBufferObjectControlFileOBJ::loadOBJ(SharedVertexBufferObject& _vertexBuffer) { std::string full = getFullFilePath(); diff --git a/src/ACGL/OpenGL/Objects/FrameBuffer.cc b/src/ACGL/OpenGL/Objects/FrameBufferObject.cc similarity index 80% rename from src/ACGL/OpenGL/Objects/FrameBuffer.cc rename to src/ACGL/OpenGL/Objects/FrameBufferObject.cc index fde2f23..59a4227 100644 --- a/src/ACGL/OpenGL/Objects/FrameBuffer.cc +++ b/src/ACGL/OpenGL/Objects/FrameBufferObject.cc @@ -3,7 +3,7 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#include +#include using namespace ACGL; using namespace ACGL::OpenGL; @@ -12,7 +12,7 @@ using namespace ACGL::OpenGL; * We can't use the constants GL_COLOR_ATTACHMENT1 to GL_COLOR_ATTACHMENT7 here * because OpenGL ES does not know these yet. */ - GLuint FrameBuffer::msBuffers[8] = { + GLuint FrameBufferObject::msBuffers[8] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0+1, GL_COLOR_ATTACHMENT0+2, @@ -23,7 +23,7 @@ using namespace ACGL::OpenGL; GL_COLOR_ATTACHMENT0+7}; -int_t FrameBuffer::getColorAttachmentIndexByName(const std::string& _name) const +int_t FrameBufferObject::getColorAttachmentIndexByName(const std::string& _name) const { for(AttachmentVec::size_type i = 0; i < mColorAttachments.size(); i++) { @@ -34,7 +34,7 @@ int_t FrameBuffer::getColorAttachmentIndexByName(const std::string& _name) const return -1; } -void FrameBuffer::validate(void) const +void FrameBufferObject::validate(void) const { if(mColorAttachments.size() > 0) { @@ -62,9 +62,9 @@ void FrameBuffer::validate(void) const fail = (mColorAttachments[k].renderBuffer->getWidth() != width || mColorAttachments[k].renderBuffer->getHeight() != height); if(fail) - Utils::error() << "FrameBuffer validation failed: Color attachment "<< k << " has different size." << std::endl; + Utils::error() << "FrameBufferObject validation failed: Color attachment "<< k << " has different size." << std::endl; } } else - Utils::error() << "FrameBuffer validation failed: No color attachments."<< std::endl; + Utils::error() << "FrameBufferObject validation failed: No color attachments."<< std::endl; } diff --git a/src/ACGL/OpenGL/Objects/State.cc b/src/ACGL/OpenGL/Objects/State.cc index 384e80b..f0a67a0 100644 --- a/src/ACGL/OpenGL/Objects/State.cc +++ b/src/ACGL/OpenGL/Objects/State.cc @@ -19,16 +19,16 @@ void State::useViewport() mpViewport->use(); } -void State::bindFrameBuffer() +void State::bindFrameBufferObject() { - mpFrameBuffer->bind(); + mpFrameBufferObject->bind(); glDrawBuffers(mFragmentDataMappings.size(), mpBuffers); } -void State::enableVertexBuffer() +void State::enableVertexBufferObject() { - if(mpVertexBuffer->getElementArrayBuffer()) - mpVertexBuffer->getElementArrayBuffer()->bind(); + if(mpVertexBufferObject->getElementArrayBuffer()) + mpVertexBufferObject->getElementArrayBuffer()->bind(); int currentArrayBufferID = -1; @@ -36,31 +36,30 @@ void State::enableVertexBuffer() { if(mAttributeMappings[k].arrayBufferID != currentArrayBufferID) { - mpVertexBuffer->getArrayBuffers()[mAttributeMappings[k].arrayBufferID]->bind(); + mpVertexBufferObject->getArrayBuffers()[mAttributeMappings[k].arrayBufferID]->bind(); currentArrayBufferID = mAttributeMappings[k].arrayBufferID; } - - mpVertexBuffer->setAttributePointer(mAttributeMappings[k].vertexBufferAttribute, mAttributeMappings[k].shaderProgramAttribute); - glEnableVertexAttribArray(mAttributeMappings[k].shaderProgramAttribute); + mpVertexBufferObject->setAttributePointer(mAttributeMappings[k].vertexBufferObjectAttribute, mAttributeMappings[k].shaderProgramAttributeLocation); + glEnableVertexAttribArray(mAttributeMappings[k].shaderProgramAttributeLocation); openGLRareError(); } } -void State::disableVertexBuffer() +void State::disableVertexBufferObject() { + int currentArrayBufferID = -1; for(AttributeMappingVec::size_type k = 0; k < mAttributeMappings.size(); k++) { - mpVertexBuffer->getArrayBuffers()[mAttributeMappings[k].arrayBufferID]->bind(); - glDisableVertexAttribArray(mAttributeMappings[k].shaderProgramAttribute); + if(mAttributeMappings[k].arrayBufferID != currentArrayBufferID) + { + mpVertexBufferObject->getArrayBuffers()[mAttributeMappings[k].arrayBufferID]->bind(); + currentArrayBufferID = mAttributeMappings[k].arrayBufferID; + } + glDisableVertexAttribArray(mAttributeMappings[k].shaderProgramAttributeLocation); openGLRareError(); } } -void State::render(void) -{ - mpVertexBuffer->draw(); -} - void State::updateMappings (void) { ShaderProgram::ConstSharedShaderVec shaders = mpShaderProgram->getShaders(); @@ -72,9 +71,9 @@ void State::updateMappings (void) for(Shader::AttributeVec::size_type k = 0; k < attributeVec.size(); k++) { AttributeMapping mapping; - mapping.shaderProgramAttribute = mpShaderProgram->getAttributeLocation(attributeVec[k]); - mapping.vertexBufferAttribute = mpVertexBuffer->getAttributeIndexByName(attributeVec[k]); - mapping.arrayBufferID = mpVertexBuffer->getArrayBufferIDByAttributeIndex(mapping.vertexBufferAttribute); + mapping.shaderProgramAttributeLocation = mpShaderProgram->getAttributeLocation(attributeVec[k]); + mapping.vertexBufferObjectAttribute = mpVertexBufferObject->getAttributeIndexByName(attributeVec[k]); + mapping.arrayBufferID = mpVertexBufferObject->getArrayBufferIDByAttributeIndex(mapping.vertexBufferObjectAttribute); bool inserted = false; for (AttributeMappingVec::iterator it = mAttributeMappings.begin(); it < mAttributeMappings.end() && !inserted; it++) @@ -95,8 +94,8 @@ void State::updateMappings (void) for(Shader::FragmentDataVec::size_type k = 0; k < fragmentDataVec.size(); k++) { FragmentDataMapping mapping; - mapping.shaderProgramFragmentData = mpShaderProgram->getFragmentDataLocation(fragmentDataVec[k]); - mapping.frameBufferColorAttachment = mpFrameBuffer->getColorAttachmentIndexByName(fragmentDataVec[k]); + mapping.shaderProgramFragmentDataLocation = mpShaderProgram->getFragmentDataLocation(fragmentDataVec[k]); + mapping.frameBufferObjectColorAttachment = mpFrameBufferObject->getColorAttachmentIndexByName(fragmentDataVec[k]); mFragmentDataMappings.push_back(mapping); } @@ -104,5 +103,5 @@ void State::updateMappings (void) mpBuffers = new GLuint[mFragmentDataMappings.size()]; for(FragmentDataMappingVec::size_type k = 0; k < mFragmentDataMappings.size(); k++) - mpBuffers[k] = GL_COLOR_ATTACHMENT0 + mFragmentDataMappings[k].frameBufferColorAttachment; + mpBuffers[k] = GL_COLOR_ATTACHMENT0 + mFragmentDataMappings[k].frameBufferObjectColorAttachment; } diff --git a/src/ACGL/OpenGL/Objects/VertexBuffer.cc b/src/ACGL/OpenGL/Objects/VertexBufferObject.cc similarity index 75% rename from src/ACGL/OpenGL/Objects/VertexBuffer.cc rename to src/ACGL/OpenGL/Objects/VertexBufferObject.cc index 6a3d0b2..c228336 100644 --- a/src/ACGL/OpenGL/Objects/VertexBuffer.cc +++ b/src/ACGL/OpenGL/Objects/VertexBufferObject.cc @@ -3,12 +3,12 @@ // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// -#include +#include using namespace ACGL; using namespace ACGL::OpenGL; -int_t VertexBuffer::getAttributeIndexByName(const std::string& _name) const +int_t VertexBufferObject::getAttributeIndexByName(const std::string& _name) const { for(AttributeVec::size_type i = 0; i < mAttributes.size(); ++i) if(mAttributes[i].name == _name) @@ -16,7 +16,7 @@ int_t VertexBuffer::getAttributeIndexByName(const std::string& _name) const return -1; } -void VertexBuffer::validate(void) const +void VertexBufferObject::validate(void) const { int mode = -1; int elements = -1; @@ -33,21 +33,21 @@ void VertexBuffer::validate(void) const } else { - Utils::error() << "VertexBuffer validation failed: No ArrayBuffer or ElementArrayBuffer specified."<< std::endl; + Utils::error() << "VertexBufferObject validation failed: No ArrayBuffer or ElementArrayBuffer specified."<< std::endl; return; } for(ArrayBufferVec::size_type k = 0; k < mArrayBuffers.size(); k++) { if(mArrayBuffers[k]->getMode() != mode) - Utils::error() << "VertexBuffer validation failed: ArrayBuffer "<< k << " has different mode."<< std::endl; + Utils::error() << "VertexBufferObject validation failed: ArrayBuffer "<< k << " has different mode."<< std::endl; if(mArrayBuffers[k]->getElements() != elements) - Utils::error() << "VertexBuffer validation failed: ArrayBuffer "<< k << " has different number of elements."<< std::endl; + Utils::error() << "VertexBufferObject validation failed: ArrayBuffer "<< k << " has different number of elements."<< std::endl; } } -void VertexBuffer::enable(void) const +void VertexBufferObject::enable(void) const { if(mpElementArrayBuffer) mpElementArrayBuffer->bind(); @@ -66,7 +66,7 @@ void VertexBuffer::enable(void) const } } -void VertexBuffer::disable(void) const +void VertexBufferObject::disable(void) const { int_t currentBufferID = -1; for(AttributeVec::size_type i = 0; i < mAttributes.size(); ++i) -- GitLab