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>
// ========================================================================================================= \/
public:
RenderObjectControl(
const ConstSharedShaderProgramObject& _shaderProgramObject)
:
mpShaderProgramObject(_shaderProgramObject),
mpFrameBufferObject()
{}
RenderObjectControl(
const ConstSharedVertexArrayObject& _vertexArrayObject,
const ConstSharedShaderProgramObject& _shaderProgramObject,
const ConstSharedFrameBufferObject& _frameBufferObject)
const ConstSharedFrameBufferObject& _frameBufferObject = ConstSharedFrameBufferObject(),
const ConstSharedViewport& _viewport = ConstSharedViewport())
:
mpVertexArrayObject(_vertexArrayObject),
mpShaderProgramObject(_shaderProgramObject),
mpFrameBufferObject(_frameBufferObject)
mpFrameBufferObject(_frameBufferObject),
mpViewport(_viewport)
{}
virtual ~RenderObjectControl(void) {}
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline RenderObjectControl& vertexArrayObject (const ConstSharedVertexArrayObject& _vertexArrayObject) { mpVertexArrayObject = _vertexArrayObject; return *this; }
inline RenderObjectControl& shaderProgramObject (const ConstSharedShaderProgramObject& _shaderProgramObject) { mpShaderProgramObject = _shaderProgramObject; return *this; }
inline RenderObjectControl& frameBufferObject (const ConstSharedFrameBufferObject& _frameBufferObject) { mpFrameBufferObject = _frameBufferObject; return *this; }
inline RenderObjectControl& viewport (const ConstSharedViewport& _viewport) { mpViewport = _viewport; return *this; }
// ===================================================================================================== \/
// ============================================================================================ OVERRIDE \/
// ===================================================================================================== \/
public:
virtual SharedRenderObject create(void)
{
// TODO: reimplement
return SharedRenderObject();
}
virtual SharedRenderObject create();
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
ConstSharedVertexArrayObject mpVertexArrayObject;
ConstSharedShaderProgramObject mpShaderProgramObject;
ConstSharedFrameBufferObject mpFrameBufferObject;
ConstSharedViewport mpViewport;
};
} // OpenGL
......
......@@ -46,7 +46,7 @@ public:
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
ShaderProgramObjectControl(const SharedShaderProgram& _shaderProgram)
ShaderProgramObjectControl(const ConstSharedShaderProgram& _shaderProgram)
: Resource::BasicCreateController<ShaderProgramObject>(),
mShaderProgram(_shaderProgram),
mUniformAttachmentDefines(),
......@@ -58,7 +58,7 @@ public:
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
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)
{
......@@ -84,7 +84,7 @@ public:
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
SharedShaderProgram mShaderProgram;
ConstSharedShaderProgram mShaderProgram;
UniformAttachmentDefineVec mUniformAttachmentDefines;
UniformTextureAttachmentDefineVec mUniformTextureAttachmentDefines;
};
......
......@@ -41,8 +41,8 @@ class RenderObject
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
RenderObject( SharedVertexArrayObject _vertexArrayObject,
SharedShaderProgramObject _shaderProgramObject,
RenderObject(ConstSharedVertexArrayObject _vertexArrayObject,
ConstSharedShaderProgramObject _shaderProgramObject,
ConstSharedFrameBufferObject _frameBufferObject = ConstSharedFrameBufferObject(),
ConstSharedViewport _viewport = ConstSharedViewport())
: mpVertexArrayObject(_vertexArrayObject),
......@@ -57,9 +57,9 @@ public:
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline SharedVertexArrayObject getVertexArrayObject() const { return mpVertexArrayObject; }
inline ConstSharedVertexArrayObject getVertexArrayObject() const { return mpVertexArrayObject; }
inline ConstSharedFrameBufferObject getFrameBufferObject() const { return mpFrameBufferObject; }
inline SharedShaderProgramObject getShaderProgramObject() const { return mpShaderProgramObject; }
inline ConstSharedShaderProgramObject getShaderProgramObject() const { return mpShaderProgramObject; }
inline ConstSharedViewport getViewport() const { return mpViewport; }
// ==================================================================================================== \/
......@@ -70,7 +70,7 @@ public:
void updateMappings();
//! setup everything for drawing and store old states
inline void enable()
inline void enable() const
{
enableFrameBufferObject();
enableShaderProgramObject();
......@@ -79,7 +79,7 @@ public:
}
//! restore old states
inline void disable()
inline void disable() const
{
disableViewport();
disableVertexArrayObject();
......@@ -94,7 +94,7 @@ public:
}
//! draws the VAO, everything needed for drawing is performed by this call
inline void render()
inline void render() const
{
enable();
draw();
......@@ -150,32 +150,32 @@ public:
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
private:
void enableFrameBufferObject();
void disableFrameBufferObject();
void enableFrameBufferObject() const;
void disableFrameBufferObject() const;
void enableShaderProgramObject();
void disableShaderProgramObject();
void enableShaderProgramObject() const;
void disableShaderProgramObject() const;
void enableViewport();
void disableViewport();
void enableViewport() const;
void disableViewport() const;
void enableVertexArrayObject();
void disableVertexArrayObject();
void enableVertexArrayObject() const;
void disableVertexArrayObject() const;
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
SharedVertexArrayObject mpVertexArrayObject; // mandatory
SharedShaderProgramObject mpShaderProgramObject; // mandatory
ConstSharedVertexArrayObject mpVertexArrayObject; // mandatory
ConstSharedShaderProgramObject mpShaderProgramObject; // mandatory
ConstSharedFrameBufferObject mpFrameBufferObject; // optional
ConstSharedViewport mpViewport; // optional
//! old states so render() can be side-effect free
Viewport mLastViewport;
GLint mLastShaderProgram;
GLint mLastFBO;
GLint mLastVAO;
mutable Viewport mLastViewport;
mutable GLint mLastShaderProgram;
mutable GLint mLastFBO;
mutable GLint mLastVAO;
};
ACGL_SMARTPOINTER_TYPEDEFS(RenderObject)
......
......@@ -62,7 +62,7 @@ public:
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
ShaderProgramObject(const SharedShaderProgram& _shaderProgram)
ShaderProgramObject(const ConstSharedShaderProgram& _shaderProgram)
: mpShaderProgram(_shaderProgram)
{}
......@@ -72,7 +72,7 @@ public:
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline SharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; }
inline ConstSharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; }
inline UniformAttachmentVec getUniformAttachments (void) const { return mUniformAttachments; }
inline UniformTextureAttachmentVec getUniformTextureAttachments (void) const { return mUniformTextureAttachments; }
......@@ -103,7 +103,7 @@ public:
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
SharedShaderProgram mpShaderProgram;
ConstSharedShaderProgram mpShaderProgram;
UniformAttachmentVec mUniformAttachments;
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;
void RenderObject::updateMappings()
{
/*
if (mpFrameBufferObject) {
// set ShaderProgram out-mappings by the definition of the FBO
mpShaderProgramObject->getShaderProgram()->setFragmentDataLocations( mpFrameBufferObject->getAttachmentLocations() );
......@@ -26,9 +27,10 @@ void RenderObject::updateMappings()
mpVertexArrayObject->setAttributeLocations( mpShaderProgramObject->getShaderProgram()->getAttributeLocations() );
openGLRareError();
*/
}
void RenderObject::enableFrameBufferObject()
void RenderObject::enableFrameBufferObject() const
{
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &mLastFBO );
......@@ -43,27 +45,27 @@ void RenderObject::enableFrameBufferObject()
openGLRareError();
}
void RenderObject::disableFrameBufferObject()
void RenderObject::disableFrameBufferObject() const
{
glBindFramebuffer( GL_FRAMEBUFFER, mLastFBO );
openGLRareError();
}
void RenderObject::enableShaderProgramObject()
void RenderObject::enableShaderProgramObject() const
{
glGetIntegerv( GL_CURRENT_PROGRAM, &mLastShaderProgram );
mpShaderProgramObject->use();
openGLRareError();
}
void RenderObject::disableShaderProgramObject()
void RenderObject::disableShaderProgramObject() const
{
glUseProgram( mLastShaderProgram );
openGLRareError();
}
void RenderObject::enableVertexArrayObject()
void RenderObject::enableVertexArrayObject() const
{
// remember old VAO
glGetIntegerv( GL_VERTEX_ARRAY_BINDING, &mLastVAO );
......@@ -72,13 +74,13 @@ void RenderObject::enableVertexArrayObject()
openGLRareError();
}
void RenderObject::disableVertexArrayObject()
void RenderObject::disableVertexArrayObject() const
{
glBindVertexArray( mLastVAO );
openGLRareError();
}
void RenderObject::enableViewport()
void RenderObject::enableViewport() const
{
mLastViewport.setFromGLContext();
......@@ -92,7 +94,7 @@ void RenderObject::enableViewport()
}
}
void RenderObject::disableViewport()
void RenderObject::disableViewport() const
{
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