BALL 1.5.0
bufferedRenderer.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_VIEW_RENDERING_RENDERERS_BUFFEREDRENDERER_H
6#define BALL_VIEW_RENDERING_RENDERERS_BUFFEREDRENDERER_H
7
8#ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
10#endif
11
12#ifndef BALL_VIEW_RENDERING_RENDERTARGET_H
14#endif
15
16namespace BALL
17{
18 namespace VIEW
19 {
30 : public Renderer
31 {
32 public:
33
35 : offset_(0),
36 stride_(0)
37 { }
38
44 {
45 if (supports(format))
46 {
47 bufferFormat = format;
48 formatUpdated();
49
50 return true;
51 }
52
53 return false;
54 }
55
62 void renderToBuffer(RenderTarget* renderTarget, const Stage& stage)
63 {
64 prepareBufferedRendering(stage);
65
66 FrameBufferPtr buffer = renderTarget->getBuffer();
67 assert(buffer);
68
69 if (buffer->getFormat() != bufferFormat)
70 {
71 throw Exception::InvalidFormat(__FILE__, __LINE__, "Buffer with wrong framebuffer format supplied");
72 }
73
74 renderToBufferImpl( buffer );
75
76 renderTarget->releaseBuffer(buffer);
77 }
78
80 virtual bool supports(const PixelFormat &format) const = 0;
81
90 const PixelFormat &format) const = 0;
91
94 virtual void setOffset(Size offset) {offset_ = offset;}
95
98 virtual void setStride(Size stride) {stride_ = stride;}
99
100 protected:
101
107 virtual bool supports(const FrameBufferFormat &format) const = 0;
108
112 virtual void formatUpdated() = 0;
113
116 virtual void prepareBufferedRendering(const Stage& stage) = 0;
117
122 virtual void renderToBufferImpl(FrameBufferPtr buffer) = 0;
123
125 const FrameBufferFormat &getFrameBufferFormat() const { return bufferFormat; }
126
129
130 private:
131
132 FrameBufferFormat bufferFormat;
133 };
134 } //namespace VIEW
135
136} //namespace BALL
137
138
139#endif // BALL_VIEW_RENDERING_BUFFEREDRENDERER_H
Definition: constants.h:13
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: renderTarget.h:222
T max(const T &a, const T &b)
Definition: MATHS/common.h:75
T min(const T &a, const T &b)
Definition: MATHS/common.h:102
virtual bool supports(const PixelFormat &format) const =0
virtual void formatUpdated()=0
const FrameBufferFormat & getFrameBufferFormat() const
virtual bool supports(const FrameBufferFormat &format) const =0
virtual void renderToBufferImpl(FrameBufferPtr buffer)=0
bool setFrameBufferFormat(const FrameBufferFormat &format)
virtual void prepareBufferedRendering(const Stage &stage)=0
virtual void setOffset(Size offset)
virtual Resolution getSupportedResolution(const Resolution &min, const Resolution &max, const PixelFormat &format) const =0
virtual void setStride(Size stride)
void renderToBuffer(RenderTarget *renderTarget, const Stage &stage)
virtual void releaseBuffer(FrameBufferPtr buffer)=0
virtual FrameBufferPtr getBuffer()=0
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52