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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America. Use, distribution,
38duplication, 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
50namespace disti
51{
52/** Interface for listeners that need to perform specific actions once per frame for each "camera" rendering a view. */
54{
55public:
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
61protected:
62 /** Protected destructor -- no polymorphic deletion */
64};
65
66/** Singleton to keep a list of all listeners for changes in the render view. */
68{
69public:
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 */
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 */
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
99private:
100 // Member types
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
Definition: dynamic_array.h:79
bool Erase(const T &object)
Definition: dynamic_array.h:414
unsigned Count() const
Definition: dynamic_array.h:218
unsigned PushBack(const T &object)
Definition: dynamic_array.h:340
Definition: gls_render_view_change_manager.h:54
virtual ~GlsRenderViewChangeListener()
Definition: gls_render_view_change_manager.h:63
virtual void OnViewChanged(const GlsMatrixType &modelViewMatrix)=0
Definition: gls_render_view_change_manager.h:68
static void RemoveRenderViewChangeListener(GlsRenderViewChangeListener *listener)
Definition: gls_render_view_change_manager.h:82
static void AddRenderViewChangeListener(GlsRenderViewChangeListener *listener)
Definition: gls_render_view_change_manager.h:74
static void NotifyRenderViewChanged(const GlsMatrixType &modelViewMatrix)
Definition: gls_render_view_change_manager.h:90
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
The GlsMatrix class.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47