Commit c4db7ab1 authored by Janis Born's avatar Janis Born
Browse files

* RenderObject no longer performs automatic mapping updates

* most members of RenderObject are now const (compatibility with resources loaded from FileManagers)
parent 16a302ba
...@@ -23,45 +23,42 @@ class RenderObjectControl : public Resource::BasicCreateController<RenderObject> ...@@ -23,45 +23,42 @@ class RenderObjectControl : public Resource::BasicCreateController<RenderObject>
// ========================================================================================================= \/ // ========================================================================================================= \/
public: public:
RenderObjectControl( RenderObjectControl(
const ConstSharedShaderProgramObject& _shaderProgramObject) const ConstSharedVertexArrayObject& _vertexArrayObject,
:
mpShaderProgramObject(_shaderProgramObject),
mpFrameBufferObject()
{}
RenderObjectControl(
const ConstSharedShaderProgramObject& _shaderProgramObject, const ConstSharedShaderProgramObject& _shaderProgramObject,
const ConstSharedFrameBufferObject& _frameBufferObject) const ConstSharedFrameBufferObject& _frameBufferObject = ConstSharedFrameBufferObject(),
const ConstSharedViewport& _viewport = ConstSharedViewport())
: :
mpVertexArrayObject(_vertexArrayObject),
mpShaderProgramObject(_shaderProgramObject), mpShaderProgramObject(_shaderProgramObject),
mpFrameBufferObject(_frameBufferObject) mpFrameBufferObject(_frameBufferObject),
mpViewport(_viewport)
{} {}
virtual ~RenderObjectControl(void) {} virtual ~RenderObjectControl(void) {}
// ==================================================================================================== \/ // ==================================================================================================== \/
// ============================================================================================ GETTERS \/ // ============================================================================================ GETTERS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
public: public:
inline RenderObjectControl& vertexArrayObject (const ConstSharedVertexArrayObject& _vertexArrayObject) { mpVertexArrayObject = _vertexArrayObject; return *this; }
inline RenderObjectControl& shaderProgramObject (const ConstSharedShaderProgramObject& _shaderProgramObject) { mpShaderProgramObject = _shaderProgramObject; return *this; } inline RenderObjectControl& shaderProgramObject (const ConstSharedShaderProgramObject& _shaderProgramObject) { mpShaderProgramObject = _shaderProgramObject; return *this; }
inline RenderObjectControl& frameBufferObject (const ConstSharedFrameBufferObject& _frameBufferObject) { mpFrameBufferObject = _frameBufferObject; return *this; } inline RenderObjectControl& frameBufferObject (const ConstSharedFrameBufferObject& _frameBufferObject) { mpFrameBufferObject = _frameBufferObject; return *this; }
inline RenderObjectControl& viewport (const ConstSharedViewport& _viewport) { mpViewport = _viewport; return *this; }
// ===================================================================================================== \/ // ===================================================================================================== \/
// ============================================================================================ OVERRIDE \/ // ============================================================================================ OVERRIDE \/
// ===================================================================================================== \/ // ===================================================================================================== \/
public: public:
virtual SharedRenderObject create(void) virtual SharedRenderObject create();
{
// TODO: reimplement
return SharedRenderObject();
}
// =================================================================================================== \/ // =================================================================================================== \/
// ============================================================================================ FIELDS \/ // ============================================================================================ FIELDS \/
// =================================================================================================== \/ // =================================================================================================== \/
protected: protected:
ConstSharedVertexArrayObject mpVertexArrayObject;
ConstSharedShaderProgramObject mpShaderProgramObject; ConstSharedShaderProgramObject mpShaderProgramObject;
ConstSharedFrameBufferObject mpFrameBufferObject; ConstSharedFrameBufferObject mpFrameBufferObject;
ConstSharedViewport mpViewport;
}; };
} // OpenGL } // OpenGL
......
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
// ============================================================================================ CONSTRUCTORS \/ // ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/ // ========================================================================================================= \/
public: public:
ShaderProgramObjectControl(const SharedShaderProgram& _shaderProgram) ShaderProgramObjectControl(const ConstSharedShaderProgram& _shaderProgram)
: Resource::BasicCreateController<ShaderProgramObject>(), : Resource::BasicCreateController<ShaderProgramObject>(),
mShaderProgram(_shaderProgram), mShaderProgram(_shaderProgram),
mUniformAttachmentDefines(), mUniformAttachmentDefines(),
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
// ============================================================================================ METHODS \/ // ============================================================================================ METHODS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
public: public:
inline ShaderProgramObjectControl& shaderProgram (const SharedShaderProgram& _shaderProgram) { mShaderProgram = _shaderProgram; return *this; } inline ShaderProgramObjectControl& shaderProgram (const ConstSharedShaderProgram& _shaderProgram) { mShaderProgram = _shaderProgram; return *this; }
inline ShaderProgramObjectControl& uniform (const std::string& _name, const ConstSharedUniform& _uniform) inline ShaderProgramObjectControl& uniform (const std::string& _name, const ConstSharedUniform& _uniform)
{ {
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
// ============================================================================================ FIELDS \/ // ============================================================================================ FIELDS \/
// =================================================================================================== \/ // =================================================================================================== \/
protected: protected:
SharedShaderProgram mShaderProgram; ConstSharedShaderProgram mShaderProgram;
UniformAttachmentDefineVec mUniformAttachmentDefines; UniformAttachmentDefineVec mUniformAttachmentDefines;
UniformTextureAttachmentDefineVec mUniformTextureAttachmentDefines; UniformTextureAttachmentDefineVec mUniformTextureAttachmentDefines;
}; };
......
...@@ -41,8 +41,8 @@ class RenderObject ...@@ -41,8 +41,8 @@ class RenderObject
// ============================================================================================ CONSTRUCTORS \/ // ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/ // ========================================================================================================= \/
public: public:
RenderObject( SharedVertexArrayObject _vertexArrayObject, RenderObject(ConstSharedVertexArrayObject _vertexArrayObject,
SharedShaderProgramObject _shaderProgramObject, ConstSharedShaderProgramObject _shaderProgramObject,
ConstSharedFrameBufferObject _frameBufferObject = ConstSharedFrameBufferObject(), ConstSharedFrameBufferObject _frameBufferObject = ConstSharedFrameBufferObject(),
ConstSharedViewport _viewport = ConstSharedViewport()) ConstSharedViewport _viewport = ConstSharedViewport())
: mpVertexArrayObject(_vertexArrayObject), : mpVertexArrayObject(_vertexArrayObject),
...@@ -57,9 +57,9 @@ public: ...@@ -57,9 +57,9 @@ public:
// ============================================================================================ GETTERS \/ // ============================================================================================ GETTERS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
public: public:
inline SharedVertexArrayObject getVertexArrayObject() const { return mpVertexArrayObject; } inline ConstSharedVertexArrayObject getVertexArrayObject() const { return mpVertexArrayObject; }
inline ConstSharedFrameBufferObject getFrameBufferObject() const { return mpFrameBufferObject; } inline ConstSharedFrameBufferObject getFrameBufferObject() const { return mpFrameBufferObject; }
inline SharedShaderProgramObject getShaderProgramObject() const { return mpShaderProgramObject; } inline ConstSharedShaderProgramObject getShaderProgramObject() const { return mpShaderProgramObject; }
inline ConstSharedViewport getViewport() const { return mpViewport; } inline ConstSharedViewport getViewport() const { return mpViewport; }
// ==================================================================================================== \/ // ==================================================================================================== \/
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
void updateMappings(); void updateMappings();
//! setup everything for drawing and store old states //! setup everything for drawing and store old states
inline void enable() inline void enable() const
{ {
enableFrameBufferObject(); enableFrameBufferObject();
enableShaderProgramObject(); enableShaderProgramObject();
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
} }
//! restore old states //! restore old states
inline void disable() inline void disable() const
{ {
disableViewport(); disableViewport();
disableVertexArrayObject(); disableVertexArrayObject();
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
} }
//! draws the VAO, everything needed for drawing is performed by this call //! draws the VAO, everything needed for drawing is performed by this call
inline void render() inline void render() const
{ {
enable(); enable();
draw(); draw();
...@@ -150,32 +150,32 @@ public: ...@@ -150,32 +150,32 @@ public:
// ============================================================================================ METHODS \/ // ============================================================================================ METHODS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
private: private:
void enableFrameBufferObject(); void enableFrameBufferObject() const;
void disableFrameBufferObject(); void disableFrameBufferObject() const;
void enableShaderProgramObject(); void enableShaderProgramObject() const;
void disableShaderProgramObject(); void disableShaderProgramObject() const;
void enableViewport(); void enableViewport() const;
void disableViewport(); void disableViewport() const;
void enableVertexArrayObject(); void enableVertexArrayObject() const;
void disableVertexArrayObject(); void disableVertexArrayObject() const;
// =================================================================================================== \/ // =================================================================================================== \/
// ============================================================================================ FIELDS \/ // ============================================================================================ FIELDS \/
// =================================================================================================== \/ // =================================================================================================== \/
protected: protected:
SharedVertexArrayObject mpVertexArrayObject; // mandatory ConstSharedVertexArrayObject mpVertexArrayObject; // mandatory
SharedShaderProgramObject mpShaderProgramObject; // mandatory ConstSharedShaderProgramObject mpShaderProgramObject; // mandatory
ConstSharedFrameBufferObject mpFrameBufferObject; // optional ConstSharedFrameBufferObject mpFrameBufferObject; // optional
ConstSharedViewport mpViewport; // optional ConstSharedViewport mpViewport; // optional
//! old states so render() can be side-effect free //! old states so render() can be side-effect free
Viewport mLastViewport; mutable Viewport mLastViewport;
GLint mLastShaderProgram; mutable GLint mLastShaderProgram;
GLint mLastFBO; mutable GLint mLastFBO;
GLint mLastVAO; mutable GLint mLastVAO;
}; };
ACGL_SMARTPOINTER_TYPEDEFS(RenderObject) ACGL_SMARTPOINTER_TYPEDEFS(RenderObject)
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
// ============================================================================================ CONSTRUCTORS \/ // ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/ // ========================================================================================================= \/
public: public:
ShaderProgramObject(const SharedShaderProgram& _shaderProgram) ShaderProgramObject(const ConstSharedShaderProgram& _shaderProgram)
: mpShaderProgram(_shaderProgram) : mpShaderProgram(_shaderProgram)
{} {}
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
// ============================================================================================ GETTERS \/ // ============================================================================================ GETTERS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
public: public:
inline SharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; } inline ConstSharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; }
inline UniformAttachmentVec getUniformAttachments (void) const { return mUniformAttachments; } inline UniformAttachmentVec getUniformAttachments (void) const { return mUniformAttachments; }
inline UniformTextureAttachmentVec getUniformTextureAttachments (void) const { return mUniformTextureAttachments; } inline UniformTextureAttachmentVec getUniformTextureAttachments (void) const { return mUniformTextureAttachments; }
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
// ============================================================================================ FIELDS \/ // ============================================================================================ FIELDS \/
// =================================================================================================== \/ // =================================================================================================== \/
protected: protected:
SharedShaderProgram mpShaderProgram; ConstSharedShaderProgram mpShaderProgram;
UniformAttachmentVec mUniformAttachments; UniformAttachmentVec mUniformAttachments;
UniformTextureAttachmentVec mUniformTextureAttachments; UniformTextureAttachmentVec mUniformTextureAttachments;
}; };
......
#include <ACGL/OpenGL/Controller/RenderObjectControl.hh>
using namespace ACGL::OpenGL;
SharedRenderObject RenderObjectControl::create()
{
return SharedRenderObject(new RenderObject(
mpVertexArrayObject,
mpShaderProgramObject,
mpFrameBufferObject,
mpViewport
));
}
...@@ -19,6 +19,7 @@ using namespace ACGL::OpenGL; ...@@ -19,6 +19,7 @@ using namespace ACGL::OpenGL;
void RenderObject::updateMappings() void RenderObject::updateMappings()
{ {
/*
if (mpFrameBufferObject) { if (mpFrameBufferObject) {
// set ShaderProgram out-mappings by the definition of the FBO // set ShaderProgram out-mappings by the definition of the FBO
mpShaderProgramObject->getShaderProgram()->setFragmentDataLocations( mpFrameBufferObject->getAttachmentLocations() ); mpShaderProgramObject->getShaderProgram()->setFragmentDataLocations( mpFrameBufferObject->getAttachmentLocations() );
...@@ -26,9 +27,10 @@ void RenderObject::updateMappings() ...@@ -26,9 +27,10 @@ void RenderObject::updateMappings()
mpVertexArrayObject->setAttributeLocations( mpShaderProgramObject->getShaderProgram()->getAttributeLocations() ); mpVertexArrayObject->setAttributeLocations( mpShaderProgramObject->getShaderProgram()->getAttributeLocations() );
openGLRareError(); openGLRareError();
*/
} }
void RenderObject::enableFrameBufferObject() void RenderObject::enableFrameBufferObject() const
{ {
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &mLastFBO ); glGetIntegerv( GL_FRAMEBUFFER_BINDING, &mLastFBO );
...@@ -43,27 +45,27 @@ void RenderObject::enableFrameBufferObject() ...@@ -43,27 +45,27 @@ void RenderObject::enableFrameBufferObject()
openGLRareError(); openGLRareError();
} }
void RenderObject::disableFrameBufferObject() void RenderObject::disableFrameBufferObject() const
{ {
glBindFramebuffer( GL_FRAMEBUFFER, mLastFBO ); glBindFramebuffer( GL_FRAMEBUFFER, mLastFBO );
openGLRareError(); openGLRareError();
} }
void RenderObject::enableShaderProgramObject() void RenderObject::enableShaderProgramObject() const
{ {
glGetIntegerv( GL_CURRENT_PROGRAM, &mLastShaderProgram ); glGetIntegerv( GL_CURRENT_PROGRAM, &mLastShaderProgram );
mpShaderProgramObject->use(); mpShaderProgramObject->use();
openGLRareError(); openGLRareError();
} }
void RenderObject::disableShaderProgramObject() void RenderObject::disableShaderProgramObject() const
{ {
glUseProgram( mLastShaderProgram ); glUseProgram( mLastShaderProgram );
openGLRareError(); openGLRareError();
} }
void RenderObject::enableVertexArrayObject() void RenderObject::enableVertexArrayObject() const
{ {
// remember old VAO // remember old VAO
glGetIntegerv( GL_VERTEX_ARRAY_BINDING, &mLastVAO ); glGetIntegerv( GL_VERTEX_ARRAY_BINDING, &mLastVAO );
...@@ -72,13 +74,13 @@ void RenderObject::enableVertexArrayObject() ...@@ -72,13 +74,13 @@ void RenderObject::enableVertexArrayObject()
openGLRareError(); openGLRareError();
} }
void RenderObject::disableVertexArrayObject() void RenderObject::disableVertexArrayObject() const
{ {
glBindVertexArray( mLastVAO ); glBindVertexArray( mLastVAO );
openGLRareError(); openGLRareError();
} }
void RenderObject::enableViewport() void RenderObject::enableViewport() const
{ {
mLastViewport.setFromGLContext(); mLastViewport.setFromGLContext();
...@@ -92,7 +94,7 @@ void RenderObject::enableViewport() ...@@ -92,7 +94,7 @@ void RenderObject::enableViewport()
} }
} }
void RenderObject::disableViewport() void RenderObject::disableViewport() const
{ {
mLastViewport.use(); mLastViewport.use();
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment