Commit 14832e32 authored by Andreas Neu's avatar Andreas Neu
Browse files

The case that no FrameBufferObject is bounded to State has been added.

parent e696ab13
......@@ -48,8 +48,8 @@ public:
// ==================================================================================================== \/
public:
inline StateControl& vertexBufferObject (const ConstSharedVertexBufferObject& _vertexBufferObject) { mpVertexBufferObject = _vertexBufferObject; return *this; }
inline StateControl& frameBufferObject (const ConstSharedFrameBufferObject& _frameBufferObject) { mpFrameBufferObject = _frameBufferObject; return *this; }
inline StateControl& shaderProgramObject (const ConstSharedShaderProgramObject& _shaderProgramObject) { mpShaderProgramObject = _shaderProgramObject; return *this; }
inline StateControl& frameBufferObject (const ConstSharedFrameBufferObject& _frameBufferObject) { mpFrameBufferObject = _frameBufferObject; return *this; }
inline StateControl& viewport (const ConstSharedViewport& _viewport) { mpViewport = _viewport; return *this; }
// ===================================================================================================== \/
......@@ -58,7 +58,7 @@ public:
public:
virtual SharedState create(void)
{
SharedState state(new State(mpVertexBufferObject, mpFrameBufferObject, mpShaderProgramObject, mpViewport));
SharedState state(new State(mpVertexBufferObject, mpShaderProgramObject, mpFrameBufferObject, mpViewport));
return state;
}
......
......@@ -41,19 +41,25 @@ void State::updateMappings (void)
mAttributeMappings.push_back(mapping);
}
for(Shader::FragmentDataNameVec::size_type k = 0; k < shaders[shader]->getFragmentDataNames().size(); k++)
if(mpFrameBufferObject)
{
FragmentDataMapping mapping;
mapping.shaderProgramFragmentDataLocation = mpShaderProgramObject->getShaderProgram()->getFragmentDataLocation(shaders[shader]->getFragmentDataNames()[k]);
mapping.frameBufferObjectColorAttachment = mpFrameBufferObject->getColorAttachmentIndexByName(shaders[shader]->getFragmentDataNames()[k]);
for(Shader::FragmentDataNameVec::size_type k = 0; k < shaders[shader]->getFragmentDataNames().size(); k++)
{
FragmentDataMapping mapping;
mapping.shaderProgramFragmentDataLocation = mpShaderProgramObject->getShaderProgram()->getFragmentDataLocation(shaders[shader]->getFragmentDataNames()[k]);
mapping.frameBufferObjectColorAttachment = mpFrameBufferObject->getColorAttachmentIndexByName(shaders[shader]->getFragmentDataNames()[k]);
mFragmentDataMappings.push_back(mapping);
mFragmentDataMappings.push_back(mapping);
}
}
}
mpBuffers = new GLuint[mFragmentDataMappings.size()];
for(FragmentDataMappingVec::size_type k = 0; k < mFragmentDataMappings.size(); k++)
mpBuffers[k] = GL_COLOR_ATTACHMENT0 + mFragmentDataMappings[k].frameBufferObjectColorAttachment;
if(mpFrameBufferObject)
{
mpBuffers = new GLuint[mFragmentDataMappings.size()];
for(FragmentDataMappingVec::size_type k = 0; k < mFragmentDataMappings.size(); k++)
mpBuffers[k] = GL_COLOR_ATTACHMENT0 + mFragmentDataMappings[k].frameBufferObjectColorAttachment;
}
}
void State::useViewport (void) const
......@@ -68,8 +74,15 @@ void State::useShaderProgramObject (void) const
void State::bindFrameBufferObject (void) const
{
mpFrameBufferObject->bind();
glDrawBuffers(mFragmentDataMappings.size(), mpBuffers);
if(mpFrameBufferObject)
{
mpFrameBufferObject->bind();
glDrawBuffers(mFragmentDataMappings.size(), mpBuffers);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
void State::enableVertexBufferObject (void) const
......
Markdown is supported
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