Loading...
Searching...
No Matches
bufferedRenderer.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_VIEW_RENDERING_RENDERERS_BUFFEREDRENDERER_H
#define BALL_VIEW_RENDERING_RENDERERS_BUFFEREDRENDERER_H
#ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
# include <BALL/VIEW/RENDERING/RENDERERS/renderer.h>
#endif
#ifndef BALL_VIEW_RENDERING_RENDERTARGET_H
# include <BALL/VIEW/RENDERING/renderTarget.h>
#endif
namespace BALL
{
namespace VIEW
{
class BALL_VIEW_EXPORT BufferedRenderer
: public Renderer
{
public:
BufferedRenderer()
: offset_(0),
stride_(0)
{ }
bool setFrameBufferFormat(const FrameBufferFormat &format)
{
if (supports(format))
{
bufferFormat = format;
formatUpdated();
return true;
}
return false;
}
void renderToBuffer(RenderTarget* renderTarget, const Stage& stage)
{
prepareBufferedRendering(stage);
FrameBufferPtr buffer = renderTarget->getBuffer();
assert(buffer);
if (buffer->getFormat() != bufferFormat)
{
throw Exception::InvalidFormat(__FILE__, __LINE__, "Buffer with wrong framebuffer format supplied");
}
renderToBufferImpl( buffer );
renderTarget->releaseBuffer(buffer);
}
virtual bool supports(const PixelFormat &format) const = 0;
virtual Resolution getSupportedResolution(const Resolution &min, const Resolution &max,
const PixelFormat &format) const = 0;
virtual void setOffset(Size offset) {offset_ = offset;}
virtual void setStride(Size stride) {stride_ = stride;}
protected:
virtual bool supports(const FrameBufferFormat &format) const = 0;
virtual void formatUpdated() = 0;
virtual void prepareBufferedRendering(const Stage& stage) = 0;
virtual void renderToBufferImpl(FrameBufferPtr buffer) = 0;
const FrameBufferFormat &getFrameBufferFormat() const { return bufferFormat; }
Size offset_;
Size stride_;
private:
FrameBufferFormat bufferFormat;
};
} //namespace VIEW
} //namespace BALL
#endif // BALL_VIEW_RENDERING_BUFFEREDRENDERER_H
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
BALL::Exception::InvalidFormat
Definition COMMON/exception.h:231
BALL::VIEW::BufferedRenderer::supports
virtual bool supports(const PixelFormat &format) const =0
BALL::VIEW::BufferedRenderer::formatUpdated
virtual void formatUpdated()=0
BALL::VIEW::BufferedRenderer::offset_
Size offset_
Definition bufferedRenderer.h:127
BALL::VIEW::BufferedRenderer::BufferedRenderer
BufferedRenderer()
Definition bufferedRenderer.h:34
BALL::VIEW::BufferedRenderer::stride_
Size stride_
Definition bufferedRenderer.h:128
BALL::VIEW::BufferedRenderer::getFrameBufferFormat
const FrameBufferFormat & getFrameBufferFormat() const
Definition bufferedRenderer.h:125
BALL::VIEW::BufferedRenderer::supports
virtual bool supports(const FrameBufferFormat &format) const =0
BALL::VIEW::BufferedRenderer::renderToBufferImpl
virtual void renderToBufferImpl(FrameBufferPtr buffer)=0
BALL::VIEW::BufferedRenderer::setFrameBufferFormat
bool setFrameBufferFormat(const FrameBufferFormat &format)
Definition bufferedRenderer.h:43
BALL::VIEW::BufferedRenderer::prepareBufferedRendering
virtual void prepareBufferedRendering(const Stage &stage)=0
BALL::VIEW::BufferedRenderer::setOffset
virtual void setOffset(Size offset)
Definition bufferedRenderer.h:94
BALL::VIEW::BufferedRenderer::getSupportedResolution
virtual Resolution getSupportedResolution(const Resolution &min, const Resolution &max, const PixelFormat &format) const =0
BALL::VIEW::BufferedRenderer::setStride
virtual void setStride(Size stride)
Definition bufferedRenderer.h:98
BALL::VIEW::BufferedRenderer::renderToBuffer
void renderToBuffer(RenderTarget *renderTarget, const Stage &stage)
Definition bufferedRenderer.h:62
BALL::VIEW::FrameBufferFormat
Definition renderTarget.h:45
BALL::VIEW::PixelFormat
Definition pixelFormat.h:61
BALL::VIEW::RenderTarget
Definition renderTarget.h:227
BALL::VIEW::RenderTarget::releaseBuffer
virtual void releaseBuffer(FrameBufferPtr buffer)=0
BALL::VIEW::RenderTarget::getBuffer
virtual FrameBufferPtr getBuffer()=0
BALL::VIEW::Renderer::Renderer
Renderer()
BALL::VIEW::Stage
Definition stage.h:239
BALL::VIEW
Definition constraints.h:35
BALL::VIEW::FrameBufferPtr
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition renderTarget.h:222
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
renderTarget.h
renderer.h
BALL::VIEW::Resolution
Definition renderTarget.h:25