BALL  1.5.0
renderWindow.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_RENDERINGWINDOW_H
6 #define BALL_VIEW_RENDERING_RENDERINGWINDOW_H
7 
8 #include <BALL/COMMON/global.h>
10 
11 #include <boost/static_assert.hpp>
12 #include <boost/type_traits/is_same.hpp>
13 
15 #define BALLVIEW_IS_SAME_TYPE(aTypeA, aTypeB) (boost::is_same<aTypeA, aTypeB>::value)
16 
18 #define BALLVIEW_STATIC_ASSERT_TYPE_IS_CHAR_OR_FLOAT(aType) \
19  BOOST_STATIC_ASSERT(BALLVIEW_IS_SAME_TYPE(aType, char) || BALLVIEW_IS_SAME_TYPE(aType, float))
20 
21 #define BALL_DEFAULT_PIXEL_TYPE float
22 
23 namespace BALL
24 {
25  namespace VIEW
26  {
32  template<typename taPixelDatatype>
34  {
35  // only int or floats are allowed as template parameters
37 
38  // type of the pixel buffer pointer
39  typedef boost::shared_array<taPixelDatatype> t_PixelPtr;
40 
41  public:
42 
43  TRenderWindow();
44 
45  virtual ~TRenderWindow();
46 
47  /* Initialize window internals. After that call, window is ready to receive \link resize \endlink call
48  * returns false if the initialization fails
49  */
50  virtual bool init();
51 
58  virtual bool resize(const unsigned int width, const unsigned int height);
59 
68  virtual void refresh();
69 
70 
71  /* =====================
72  * RenderTarget methods
73  * ===================== */
74 
75  /*
76  * See \link RenderTarget \endlink for general description.
77  * In addition there is a precondition that \link init \endlink must be called before
78  * getBuffer. If not, \link NoBufferAvailable \endlink exception is thrown.
79  * @throws BALL::Exception::NoBufferAvailable
80  */
81  virtual FrameBufferPtr getBuffer();
82 
83  /*
84  * See \link RenderTarget \endlink for description.
85  */
86  virtual FrameBufferFormat getFormat() const;
87 
88  /*
89  * See \link RenderTarget \endlink for description.
90  */
91  virtual void releaseBuffer(FrameBufferPtr buffer);
92 
93  /* Prepare the window for rendering, e.g., make it current if necessary.
94  */
95  virtual void prepareRendering() {};
96 
99  virtual bool doNotResize() const { return do_not_resize_; }
100 
101  virtual void setDoNotResize(bool do_not_resize) { do_not_resize_ = do_not_resize; }
102 
103 
104  protected:
105  t_PixelPtr m_pixels; // raw pixel buffer
106  FrameBufferPtr m_framebuffer; // frame buffer given out to the wild by getBuffer method
107  FrameBufferFormat m_fmt; // description of the buffer format
108  const PixelFormat m_pfm; // pixel format of the window
109  bool m_bufferLocked; // pixel buffer is being accessed by another object?
110  const Size m_minimalWidth; // minimum with the window can have
111  const Size m_minimalHeight; // minimum height the window can have
113  };
114 
116 
117  } // namespace VIEW
118 
119 } // namespace BALL
120 
121 #endif // BALL_VIEW_RENDERING_RENDERINGWINDOW_H
const PixelFormat m_pfm
Definition: renderWindow.h:108
TRenderWindow< BALL_DEFAULT_PIXEL_TYPE > RenderWindow
Definition: renderWindow.h:115
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
FrameBufferFormat m_fmt
Definition: renderWindow.h:107
virtual void setDoNotResize(bool do_not_resize)
Definition: renderWindow.h:101
virtual void prepareRendering()
Definition: renderWindow.h:95
virtual bool doNotResize() const
Definition: renderWindow.h:99
Definition: constants.h:12
#define BALLVIEW_STATIC_ASSERT_TYPE_IS_CHAR_OR_FLOAT(aType)
Macro checks at compile time, whether aType is int or float.
Definition: renderWindow.h:18
FrameBufferPtr m_framebuffer
Definition: renderWindow.h:106
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: renderTarget.h:222