BALL  1.4.2
 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_INT_OR_FLOAT(aType) \
19  BOOST_STATIC_ASSERT(BALLVIEW_IS_SAME_TYPE(aType, int) || BALLVIEW_IS_SAME_TYPE(aType, float))
20 
21 namespace BALL
22 {
23  namespace VIEW
24  {
30  template<typename taPixelDatatype>
32  {
33  // only int or floats are allowed as template parameters
35 
36  // type of the pixel buffer pointer
37  typedef boost::shared_array<taPixelDatatype> t_PixelPtr;
38 
39  public:
40 
41  RenderWindow();
42 
43  virtual ~RenderWindow();
44 
45  /* Initialize window internals. After that call, window is ready to receive \link resize \endlink call
46  * returns false if the initialization fails
47  */
48  virtual bool init();
49 
56  virtual bool resize(const unsigned int width, const unsigned int height);
57 
66  virtual void refresh();
67 
68 
69  /* =====================
70  * RenderTarget methods
71  * ===================== */
72 
73  /*
74  * See \link RenderTarget \endlink for general description.
75  * In addition there is a precondition that \link init \endlink must be called before
76  * getBuffer. If not, \link NoBufferAvailable \endlink exception is thrown.
77  */
78  virtual FrameBufferPtr getBuffer() throw(BALL::Exception::NoBufferAvailable);
79 
80  /*
81  * See \link RenderTarget \endlink for description.
82  */
83  virtual FrameBufferFormat getFormat() const;
84 
85  /*
86  * See \link RenderTarget \endlink for description.
87  */
88  virtual void releaseBuffer(FrameBufferPtr buffer);
89 
90  /* Prepare the window for rendering, e.g., make it current if necessary.
91  */
92  virtual void prepareRendering() {};
93 
94  protected:
95  t_PixelPtr m_pixels; // raw pixel buffer
96  FrameBufferPtr m_framebuffer; // frame buffer given out to the wild by getBuffer method
97  FrameBufferFormat m_fmt; // description of the buffer format
98  const PixelFormat m_pfm; // pixel format of the window
99  bool m_bufferLocked; // pixel buffer is being accessed by another object?
100  const unsigned int m_minimalWidth; // minimum with the window can have
101  const unsigned int m_minimalHeight; // minimum height the window can have
102  };
103 
105 
106  } // namespace VIEW
107 
108 } // namespace BALL
109 
110 #endif // BALL_VIEW_RENDERING_RENDERINGWINDOW_H