| GL Studio C++ Runtime API

gls_render_view_change_manager.h
Go to the documentation of this file.
1/*! \file
2 \brief RenderViewChangeManager to smooth updating of the render view
3
4 \par Copyright Information
5
6 Copyright (c) 2016 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<br>
9 USA<br>
10 <br>
11 All rights reserved.<br>
12
13 This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America. Use, distribution,
38 duplication, or disclosure by the U. S. Government is subject to
39"Restricted Rights" as set forth in DFARS 252.227-7014(c)(1)(ii).
40
41*/
42
43#ifndef GLS_RENDER_VIEW_CHANGE_MANAGER_H
44#define GLS_RENDER_VIEW_CHANGE_MANAGER_H
45
46#include "dynamic_array.h"
47#include "gls_include.h"
48#include "gls_matrix.h"
49
50 namespace disti
51{
52/** Interface for listeners that need to perform specific actions once per frame for each "camera" rendering a view. */
53 class GlsRenderViewChangeListener
54{
55 public:
56 /** Called whenever a new view has been applied to OpenGL.
57 * \param modelViewMatrix the matrix of the new view
58 */
59 GLS_EXPORT virtual void OnViewChanged( const GlsMatrixType& modelViewMatrix ) = 0;
60
61 protected:
62 /** Protected destructor -- no polymorphic deletion */
63 virtual ~GlsRenderViewChangeListener() {}
64};
65
66/** Singleton to keep a list of all listeners for changes in the render view. */
67 class GlsRenderViewChangeManager
68{
69 public:
70 /** Add a listener to the notification list for render views changing
71 * Note: Does not take ownership of the listener
72 * \param listener the listener to add
73 */
74 GLS_EXPORT static void AddRenderViewChangeListener( GlsRenderViewChangeListener* listener )
75 {
76 GetListeners().PushBack( listener );
77 }
78
79 /** Remove a listener from the notification list for render views changing
80 * \param listener the listener to remove
81 */
82 GLS_EXPORT static void RemoveRenderViewChangeListener( GlsRenderViewChangeListener* listener )
83 {
84 GetListeners().Erase( listener );
85 }
86
87 /** Notify all listeners that a new view has been applied to OpenGL
88 * \param modelViewMatrix the matrix of the new view
89 */
90 GLS_EXPORT static void NotifyRenderViewChanged( const GlsMatrixType& modelViewMatrix )
91 {
92 Listeners& listeners = GetListeners();
93 for( unsigned int i = 0; i < listeners.Count(); ++i )
94 {
95 listeners[ i ]->OnViewChanged( modelViewMatrix );
96 }
97 }
98
99 private:
100 // Member types
101 typedef DynamicArray<GlsRenderViewChangeListener*> Listeners;
102
103 // Disable construction for static class
104 GlsRenderViewChangeManager(); // = delete
105
106 static Listeners& GetListeners()
107 {
108 static Listeners s_renderViewChangeListeners;
109 return s_renderViewChangeListeners;
110 }
111};
112
113} // namespace disti
114
115#endif
disti::DynamicArray
Definition: dynamic_array.h:79
disti::DynamicArray::Erase
bool Erase(const T &object)
Definition: dynamic_array.h:414
disti::DynamicArray::Count
unsigned Count() const
Definition: dynamic_array.h:218
disti::DynamicArray::PushBack
unsigned PushBack(const T &object)
Definition: dynamic_array.h:340
disti::GlsMatrixAffine< double >
disti::GlsRenderViewChangeListener
Definition: gls_render_view_change_manager.h:54
disti::GlsRenderViewChangeListener::~GlsRenderViewChangeListener
virtual ~GlsRenderViewChangeListener()
Definition: gls_render_view_change_manager.h:63
disti::GlsRenderViewChangeListener::OnViewChanged
virtual void OnViewChanged(const GlsMatrixType &modelViewMatrix)=0
disti::GlsRenderViewChangeManager
Definition: gls_render_view_change_manager.h:68
disti::GlsRenderViewChangeManager::RemoveRenderViewChangeListener
static void RemoveRenderViewChangeListener(GlsRenderViewChangeListener *listener)
Definition: gls_render_view_change_manager.h:82
disti::GlsRenderViewChangeManager::AddRenderViewChangeListener
static void AddRenderViewChangeListener(GlsRenderViewChangeListener *listener)
Definition: gls_render_view_change_manager.h:74
disti::GlsRenderViewChangeManager::NotifyRenderViewChanged
static void NotifyRenderViewChanged(const GlsMatrixType &modelViewMatrix)
Definition: gls_render_view_change_manager.h:90
dynamic_array.h
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
gls_include.h
A file for all GL Studio files to include.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
gls_matrix.h
The GlsMatrix class.
disti
Definition: bmpimage.h:47