BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_BUFFEREDRENDERER_H
6 #define BALL_VIEW_RENDERING_BUFFEREDRENDERER_H
7 
8 #ifndef BALL_VIEW_RENDERING_RENDERER_H
10 #endif
11 
12 #ifndef BALL_VIEW_RENDERING_RENDERTARGET_H
14 #endif
15 
16 namespace BALL
17 {
18  namespace VIEW
19  {
30  : public Renderer
31  {
32  public:
34  : Renderer(),
35  bufferFormat() { }
36 
37  virtual ~BufferedRenderer() throw() { }
38 
44  {
45  if( supports(format) )
46  {
47  bufferFormat = format;
48  formatUpdated();
49  return true;
50  }
51 
52  return false;
53  }
54 
59  void renderToBuffer(RenderTarget* renderTarget, const Stage& stage)
61  {
63 
64  FrameBufferPtr buffer = renderTarget->getBuffer();
65  assert(buffer);
66 
67  if (buffer->getFormat() != bufferFormat)
68  {
69  throw BALL::Exception::InvalidFormat(__FILE__, __LINE__, "Buffer with wrong framebuffer format supplied");
70  }
71 
72  renderToBufferImpl( buffer );
73 
74  renderTarget->releaseBuffer(buffer);
75  }
76 
78  virtual bool supports(const PixelFormat &format) const = 0;
79 
87  const Resolution &min, const Resolution &max,
88  const PixelFormat &format) const
90 
91  protected:
92 
98  virtual bool supports(const FrameBufferFormat &format) const = 0;
99 
103  virtual void formatUpdated() = 0;
104 
107  virtual void prepareBufferedRendering(const Stage& stage) = 0;
108 
113  virtual void renderToBufferImpl(FrameBufferPtr buffer) = 0;
114 
117  { return bufferFormat; }
118 
119  private:
120 
122  };
123  } //namespace VIEW
124 
125 } //namespace BALL
126 
127 
128 #endif // BALL_VIEW_RENDERING_BUFFEREDRENDERER_H