Loading...
Searching...
No Matches
renderWindow.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_VIEW_RENDERING_RENDERINGWINDOW_H
#define BALL_VIEW_RENDERING_RENDERINGWINDOW_H
#include <BALL/COMMON/global.h>
#include <BALL/VIEW/RENDERING/renderTarget.h>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#define BALLVIEW_IS_SAME_TYPE(aTypeA, aTypeB) (boost::is_same<aTypeA, aTypeB>::value)
#define BALLVIEW_STATIC_ASSERT_TYPE_IS_CHAR_OR_FLOAT(aType) \
BOOST_STATIC_ASSERT(BALLVIEW_IS_SAME_TYPE(aType, char) || BALLVIEW_IS_SAME_TYPE(aType, float))
#define BALL_DEFAULT_PIXEL_TYPE float
namespace BALL
{
namespace VIEW
{
template<typename taPixelDatatype>
class BALL_VIEW_EXPORT TRenderWindow : public RenderTarget
{
// only int or floats are allowed as template parameters
BALLVIEW_STATIC_ASSERT_TYPE_IS_CHAR_OR_FLOAT(taPixelDatatype);
// type of the pixel buffer pointer
typedef boost::shared_array<taPixelDatatype> t_PixelPtr;
public:
TRenderWindow();
virtual ~TRenderWindow();
/* Initialize window internals. After that call, window is ready to receive \link resize \endlink call
* returns false if the initialization fails
*/
virtual bool init();
virtual bool resize(const unsigned int width, const unsigned int height);
virtual void refresh();
/* =====================
* RenderTarget methods
* ===================== */
/*
* See \link RenderTarget \endlink for general description.
* In addition there is a precondition that \link init \endlink must be called before
* getBuffer. If not, \link NoBufferAvailable \endlink exception is thrown.
* @throws BALL::Exception::NoBufferAvailable
*/
virtual FrameBufferPtr getBuffer();
/*
* See \link RenderTarget \endlink for description.
*/
virtual FrameBufferFormat getFormat() const;
/*
* See \link RenderTarget \endlink for description.
*/
virtual void releaseBuffer(FrameBufferPtr buffer);
/* Prepare the window for rendering, e.g., make it current if necessary.
*/
virtual void prepareRendering() {};
virtual bool doNotResize() const { return do_not_resize_; }
virtual void setDoNotResize(bool do_not_resize) { do_not_resize_ = do_not_resize; }
protected:
t_PixelPtr m_pixels; // raw pixel buffer
FrameBufferPtr m_framebuffer; // frame buffer given out to the wild by getBuffer method
FrameBufferFormat m_fmt; // description of the buffer format
const PixelFormat m_pfm; // pixel format of the window
bool m_bufferLocked; // pixel buffer is being accessed by another object?
const Size m_minimalWidth; // minimum with the window can have
const Size m_minimalHeight; // minimum height the window can have
bool do_not_resize_;
};
typedef TRenderWindow<BALL_DEFAULT_PIXEL_TYPE> RenderWindow;
} // namespace VIEW
} // namespace BALL
#endif // BALL_VIEW_RENDERING_RENDERINGWINDOW_H
global.h
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
BALL::VIEW::FrameBufferFormat
Definition renderTarget.h:45
BALL::VIEW::PixelFormat
Definition pixelFormat.h:61
BALL::VIEW::RenderTarget
Definition renderTarget.h:227
BALL::VIEW::TRenderWindow
Definition renderWindow.h:34
BALL::VIEW::TRenderWindow::init
virtual bool init()
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_pfm
const PixelFormat m_pfm
Definition renderWindow.h:108
BALL::VIEW::TRenderWindow::getFormat
virtual FrameBufferFormat getFormat() const
BALL::VIEW::TRenderWindow::resize
virtual bool resize(const unsigned int width, const unsigned int height)
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_fmt
FrameBufferFormat m_fmt
Definition renderWindow.h:107
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_minimalWidth
const Size m_minimalWidth
Definition renderWindow.h:110
BALL::VIEW::TRenderWindow::~TRenderWindow
virtual ~TRenderWindow()
BALL::VIEW::TRenderWindow::refresh
virtual void refresh()
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_bufferLocked
bool m_bufferLocked
Definition renderWindow.h:109
BALL::VIEW::TRenderWindow::setDoNotResize
virtual void setDoNotResize(bool do_not_resize)
Definition renderWindow.h:101
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_pixels
t_PixelPtr m_pixels
Definition renderWindow.h:105
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_minimalHeight
const Size m_minimalHeight
Definition renderWindow.h:111
BALL::VIEW::TRenderWindow::TRenderWindow
TRenderWindow()
BALL::VIEW::TRenderWindow::doNotResize
virtual bool doNotResize() const
Definition renderWindow.h:99
BALL::VIEW::TRenderWindow::getBuffer
virtual FrameBufferPtr getBuffer()
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::do_not_resize_
bool do_not_resize_
Definition renderWindow.h:112
BALL::VIEW::TRenderWindow< BALL_DEFAULT_PIXEL_TYPE >::m_framebuffer
FrameBufferPtr m_framebuffer
Definition renderWindow.h:106
BALL::VIEW::TRenderWindow::releaseBuffer
virtual void releaseBuffer(FrameBufferPtr buffer)
BALL::VIEW::TRenderWindow::prepareRendering
virtual void prepareRendering()
Definition renderWindow.h:95
BALL::VIEW::FrameBufferPtr
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition renderTarget.h:222
BALL::VIEW::RenderWindow
TRenderWindow< BALL_DEFAULT_PIXEL_TYPE > RenderWindow
Definition renderWindow.h:115
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
renderTarget.h
BALLVIEW_STATIC_ASSERT_TYPE_IS_CHAR_OR_FLOAT
#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