Equalizer  2.1.0
Parallel Rendering Framework
renderer.h
1 
2 /* Copyright (c) 2011-2017, Stefan Eilemann <eile@eyescale.ch>
3  * Daniel Nachbaur <danielnachbaur@gmail.com>
4  * Petros Kataras <petroskataras@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQSEQUEL_RENDERER_H
21 #define EQSEQUEL_RENDERER_H
22 
23 #include <co/objectFactory.h> // interface
24 
25 #include <eq/util/objectManager.h> // imported type
26 #include <seq/types.h>
27 
28 namespace seq
29 {
36 class Renderer : public co::ObjectFactory
37 {
38 public:
40  SEQ_API explicit Renderer(Application& application);
41 
43  SEQ_API virtual ~Renderer();
44 
58  SEQ_API virtual bool init(co::Object* initData LB_UNUSED) { return true; }
68  SEQ_API virtual bool exit() { return true; }
80  SEQ_API virtual bool initContext(co::Object* initData);
81 
90  SEQ_API virtual bool exitContext();
91 
99  SEQ_API virtual void clear(co::Object* frameData);
100 
108  virtual void draw(co::Object* frameData) = 0;
109 
111  SEQ_API void requestRedraw();
112 
119  SEQ_API void updateNearFar(const Vector4f& boundingSphere);
120 
127  SEQ_API void updateNearFar(const AABBf& box);
128 
139  SEQ_API void setNearFar(const float nearPlane, const float farPlane);
140 
150  SEQ_API virtual void applyRenderContext();
151 
157  SEQ_API void bindDrawFrameBuffer();
158 
160  SEQ_API const RenderContext& getRenderContext() const;
161 
171  SEQ_API virtual void applyModelMatrix();
172 
180  SEQ_API virtual void applyScreenFrustum();
181 
186  SEQ_API virtual void applyPerspectiveFrustum();
187 
192  virtual bool processEvent(EventType) { return false; }
193  virtual bool processEvent(EventType, const SizeEvent&) { return false; }
194  virtual bool processEvent(EventType, const PointerEvent&) { return false; }
195  virtual bool processEvent(EventType, const KeyEvent&) { return false; }
196  virtual bool processEvent(const AxisEvent&) { return false; }
197  virtual bool processEvent(const ButtonEvent&) { return false; }
199 
202  detail::Renderer* getImpl() { return _impl; }
203 
208  SEQ_API co::Object* getFrameData();
209 
211  Application& getApplication() { return app_; }
213  const Application& getApplication() const { return app_; }
215  SEQ_API const ObjectManager& getObjectManager() const;
216 
218  SEQ_API ObjectManager& getObjectManager();
219 
231  SEQ_API virtual ViewData* createViewData(View& view);
232 
234  SEQ_API virtual void destroyViewData(ViewData* viewData);
235 
237  SEQ_API const ViewData* getViewData() const;
238 
252  SEQ_API const GLEWContext* glewGetContext() const;
253 
255  SEQ_API const Frustumf& getFrustum() const;
256 
258  SEQ_API const Matrix4f& getViewMatrix() const;
259 
261  SEQ_API const Matrix4f& getModelMatrix() const;
262 
264  SEQ_API const PixelViewport& getPixelViewport() const;
265 
270  SEQ_API uint32_t getWindowID() const;
272 
276  SEQ_API virtual co::Object* createObject(const uint32_t type);
277 
279  SEQ_API virtual void destroyObject(co::Object* object, const uint32_t type);
280 
290  SEQ_API co::Object* mapObject(const uint128_t& identifier,
291  co::Object* instance);
292 
301  SEQ_API bool unmap(co::Object* object);
303 
304 private:
305  detail::Renderer* const _impl;
306  Application& app_;
307 };
308 }
309 #endif // EQSEQUEL_RENDERER_H
const Application & getApplication() const
Definition: renderer.h:213
virtual SEQ_API void clear(co::Object *frameData)
Clear the frame buffer.
SEQ_API void bindDrawFrameBuffer()
Bind the window draw buffer, which can be (multisampled) FBO or window buffer.
SEQ_API const Matrix4f & getModelMatrix() const
virtual void draw(co::Object *frameData)=0
Render the scene.
SEQ_API const ViewData * getViewData() const
virtual bool processEvent(EventType)
Definition: renderer.h:192
virtual SEQ_API ~Renderer()
Destruct this renderer.
The main application object.
Definition: application.h:29
SEQ_API void updateNearFar(const Vector4f &boundingSphere)
Update the near and far planes to tightly enclose the given sphere.
SEQ_API co::Object * getFrameData()
SEQ_API const Frustumf & getFrustum() const
SEQ_API void setNearFar(const float nearPlane, const float farPlane)
Set the near and far planes.
virtual SEQ_API bool initContext(co::Object *initData)
Initialize a rendering context.
SEQ_API const GLEWContext * glewGetContext() const
Get the GLEW context for this renderer.
virtual SEQ_API ViewData * createViewData(View &view)
Create a new per-view data instance.
SEQ_API bool unmap(co::Object *object)
Unmap an object from the object map.
virtual SEQ_API void applyPerspectiveFrustum()
Apply the perspective frustum matrix for the current rendering task.
A renderer instance.
Definition: renderer.h:36
Stores per-view data.
Definition: viewData.h:30
virtual SEQ_API bool init(co::Object *initData)
Initialize the renderer.
Definition: renderer.h:58
virtual SEQ_API void applyRenderContext()
Apply the current rendering parameters to the rendering context.
SEQ_API const PixelViewport & getPixelViewport() const
virtual SEQ_API co::Object * createObject(const uint32_t type)
A View is a 2D area of a Layout.
Definition: view.h:46
Application & getApplication()
Definition: renderer.h:211
SEQ_API Renderer(Application &application)
Construct a new renderer.
SEQ_API const RenderContext & getRenderContext() const
SEQ_API uint32_t getWindowID() const
Sequel - A simple interface to the Equalizer parallel rendering framework.
Definition: application.h:26
virtual SEQ_API void destroyViewData(ViewData *viewData)
Delete the given view data.
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:56
SEQ_API co::Object * mapObject(const uint128_t &identifier, co::Object *instance)
Map and return an object.
SEQ_API const Matrix4f & getViewMatrix() const
virtual SEQ_API bool exit()
De-initialize the renderer.
Definition: renderer.h:68
virtual SEQ_API void applyScreenFrustum()
Apply an orthographic frustum for pixel-based 2D operations.
virtual SEQ_API void destroyObject(co::Object *object, const uint32_t type)
virtual SEQ_API bool exitContext()
De-initialize a rendering context.
SEQ_API void requestRedraw()
Request another call to draw().
The context applied to a channel during rendering operations.
Definition: renderContext.h:37
SEQ_API const ObjectManager & getObjectManager() const
virtual SEQ_API void applyModelMatrix()
Apply the current model matrix to the rendering context.