BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  */
80  virtual FrameBufferPtr getBuffer() throw(BALL::Exception::NoBufferAvailable);
81 
82  /*
83  * See \link RenderTarget \endlink for description.
84  */
85  virtual FrameBufferFormat getFormat() const;
86 
87  /*
88  * See \link RenderTarget \endlink for description.
89  */
90  virtual void releaseBuffer(FrameBufferPtr buffer);
91 
92  /* Prepare the window for rendering, e.g., make it current if necessary.
93  */
94  virtual void prepareRendering() {};
95 
98  virtual bool doNotResize() const { return do_not_resize_; }
99 
100  virtual void setDoNotResize(bool do_not_resize) { do_not_resize_ = do_not_resize; }
101 
102 
103  protected:
104  t_PixelPtr m_pixels; // raw pixel buffer
105  FrameBufferPtr m_framebuffer; // frame buffer given out to the wild by getBuffer method
106  FrameBufferFormat m_fmt; // description of the buffer format
107  const PixelFormat m_pfm; // pixel format of the window
108  bool m_bufferLocked; // pixel buffer is being accessed by another object?
109  const Size m_minimalWidth; // minimum with the window can have
110  const Size m_minimalHeight; // minimum height the window can have
112  };
113 
115 
116  } // namespace VIEW
117 
118 } // namespace BALL
119 
120 #endif // BALL_VIEW_RENDERING_RENDERINGWINDOW_H
virtual void prepareRendering()
Definition: renderWindow.h:94
virtual void setDoNotResize(bool do_not_resize)
Definition: renderWindow.h:100
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: renderTarget.h:222
TRenderWindow< BALL_DEFAULT_PIXEL_TYPE > RenderWindow
Definition: renderWindow.h:114
FrameBufferFormat m_fmt
Definition: renderWindow.h:106
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
FrameBufferPtr m_framebuffer
Definition: renderWindow.h:105
#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
const PixelFormat m_pfm
Definition: renderWindow.h:107
virtual bool doNotResize() const
Definition: renderWindow.h:98