Commit 737844de authored by Jan Möbius's avatar Jan Möbius
Browse files

Switch from pointer to instance in rendererObject to make sure the copy...

Switch from pointer to instance in rendererObject to make sure the copy constructor is used. closes #1746

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17560 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 70ab46fc
...@@ -109,12 +109,11 @@ void IRenderer::collectRenderObjects( ACG::GLState* _glState, ACG::SceneGraph::D ...@@ -109,12 +109,11 @@ void IRenderer::collectRenderObjects( ACG::GLState* _glState, ACG::SceneGraph::D
// collectLightNodes(_sceneGraphRoot); // collectLightNodes(_sceneGraphRoot);
numLights_ = 0; // reset light counter numLights_ = 0; // reset light counter
// flush render objects // // flush render objects
for (size_t i = 0; i < renderObjects_.size(); ++i) // for (size_t i = 0; i < renderObjects_.size(); ++i)
{ // {
delete renderObjects_[i].uniformPool_; // renderObjects_[i].uniformPool_.clear();
renderObjects_[i].uniformPool_ = 0; // }
}
renderObjects_.resize(0); renderObjects_.resize(0);
...@@ -318,8 +317,8 @@ void IRenderer::bindObjectUniforms( ACG::RenderObject* _obj, GLSL::Program* _pro ...@@ -318,8 +317,8 @@ void IRenderer::bindObjectUniforms( ACG::RenderObject* _obj, GLSL::Program* _pro
// Additional Uniforms defined in the render Object // Additional Uniforms defined in the render Object
if ( _obj->uniformPool_ ) if ( !_obj->uniformPool_.empty() )
_obj->uniformPool_->bind(_prog); _obj->uniformPool_.bind(_prog);
// texture // texture
for (std::map<size_t,RenderObject::Texture>::const_iterator iter = _obj->textures().begin(); for (std::map<size_t,RenderObject::Texture>::const_iterator iter = _obj->textures().begin();
......
...@@ -181,9 +181,7 @@ RenderObject::RenderObject() ...@@ -181,9 +181,7 @@ RenderObject::RenderObject()
alpha(1.0f), shininess(100.0f), alpha(1.0f), shininess(100.0f),
debugID(0), debugName(0), debugID(0), debugName(0),
internalFlags_(0), internalFlags_(0)
uniformPool_(0)
{ {
// set modelview and proj to identity // set modelview and proj to identity
...@@ -198,6 +196,10 @@ RenderObject::RenderObject() ...@@ -198,6 +196,10 @@ RenderObject::RenderObject()
colorWriteMask[0] = colorWriteMask[1] = colorWriteMask[2] = colorWriteMask[3] = 1; colorWriteMask[0] = colorWriteMask[1] = colorWriteMask[2] = colorWriteMask[3] = 1;
} }
RenderObject::~RenderObject() {
uniformPool_.clear();
}
void RenderObject::executeImmediateMode() void RenderObject::executeImmediateMode()
{ {
// implemented by deriving class // implemented by deriving class
...@@ -366,74 +368,47 @@ void RenderObject::setGeometryShaderInputFromDrawCall(GLenum _mode) { ...@@ -366,74 +368,47 @@ void RenderObject::setGeometryShaderInputFromDrawCall(GLenum _mode) {
void RenderObject::setUniform( const char *_name, GLint _value ) void RenderObject::setUniform( const char *_name, GLint _value )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value);
} }
void RenderObject::setUniform( const char *_name, GLfloat _value ) void RenderObject::setUniform( const char *_name, GLfloat _value )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value);
} }
void RenderObject::setUniform( const char *_name, const ACG::Vec2f &_value ) void RenderObject::setUniform( const char *_name, const ACG::Vec2f &_value )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value);
} }
void RenderObject::setUniform( const char *_name, const ACG::Vec3f &_value ) void RenderObject::setUniform( const char *_name, const ACG::Vec3f &_value )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value);
} }
void RenderObject::setUniform( const char *_name, const ACG::Vec4f &_value ) void RenderObject::setUniform( const char *_name, const ACG::Vec4f &_value )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value);
} }
void RenderObject::setUniform( const char *_name, const ACG::GLMatrixf &_value, bool _transposed /*= false*/ ) void RenderObject::setUniform( const char *_name, const ACG::GLMatrixf &_value, bool _transposed /*= false*/ )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value, _transposed);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value, _transposed);
} }
void RenderObject::setUniformMat3( const char *_name, const ACG::GLMatrixf &_value, bool _transposed /*= false*/ ) void RenderObject::setUniformMat3( const char *_name, const ACG::GLMatrixf &_value, bool _transposed /*= false*/ )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _value, _transposed);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _value, _transposed);
} }
void RenderObject::setUniform( const char *_name, GLint *_values, int _count ) void RenderObject::setUniform( const char *_name, GLint *_values, int _count )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _values, _count);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _values, _count);
} }
void RenderObject::setUniform( const char *_name, GLfloat *_values, int _count ) void RenderObject::setUniform( const char *_name, GLfloat *_values, int _count )
{ {
if (!uniformPool_) uniformPool_.setUniform(_name, _values, _count);
uniformPool_ = new GLSL::UniformPool();
uniformPool_->setUniform(_name, _values, _count);
} }
......
...@@ -108,6 +108,8 @@ struct ACGDLLEXPORT RenderObject ...@@ -108,6 +108,8 @@ struct ACGDLLEXPORT RenderObject
*/ */
RenderObject(); RenderObject();
virtual ~RenderObject();
/** \brief Priority to allow sorting of objects /** \brief Priority to allow sorting of objects
* *
...@@ -369,7 +371,7 @@ public: ...@@ -369,7 +371,7 @@ public:
void setUniform(const char *_name, GLfloat *_values, int _count); void setUniform(const char *_name, GLfloat *_values, int _count);
private: private:
GLSL::UniformPool* uniformPool_; GLSL::UniformPool uniformPool_;
}; };
//============================================================================= //=============================================================================
......
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