GL Studio 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 "gls_include.h"
47 #include "dynamic_array.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. */
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  protected:
61  /** Protected, non-virtual destructor -- no polymorphic deletion */
63  };
64 
65  /** Singleton to keep a list of all listeners for changes in the render view. */
67  {
68  public:
69  /** Add a listener to the notification list for render views changing
70  * Note: Does not take ownership of the listener
71  * \param listener the listener to add
72  */
73  GLS_EXPORT static void AddRenderViewChangeListener(GlsRenderViewChangeListener* listener)
74  {
75  GetListeners().PushObject(listener);
76  }
77 
78  /** Remove a listener from the notification list for render views changing
79  * \param listener the listener to remove
80  */
82  {
83  GetListeners().DeleteObject(listener);
84  }
85 
86  /** Notify all listeners that a new view has been applied to OpenGL
87  * \param modelViewMatrix the matrix of the new view
88  */
89  GLS_EXPORT static void NotifyRenderViewChanged(const GlsMatrixType& modelViewMatrix)
90  {
91  Listeners& listeners = GetListeners();
92  for( unsigned int i = 0; i < listeners.Count(); ++i )
93  {
94  listeners[i]->OnViewChanged(modelViewMatrix);
95  }
96  }
97  private:
98  // Member types
100 
101  // Disable construction for static class
102  GlsRenderViewChangeManager(); // = delete
103 
104  static Listeners& GetListeners()
105  {
106  static Listeners s_renderViewChangeListeners;
107  return s_renderViewChangeListeners;
108  }
109  };
110 
111 } // namespace disti
112 
113 #endif
Definition: dynamic_array.h:63
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
The GlsMatrix class.
A file for all GL Studio files to include.
bool DeleteObject(const T &obj)
Definition: dynamic_array.h:294
void Count(const unsigned int count)
Definition: dynamic_array.h:120
Definition: gls_render_view_change_manager.h:53
static void RemoveRenderViewChangeListener(GlsRenderViewChangeListener *listener)
Definition: gls_render_view_change_manager.h:81
void PushObject(const T &obj)
Definition: dynamic_array.h:276
virtual void OnViewChanged(const GlsMatrixType &modelViewMatrix)=0
~GlsRenderViewChangeListener()
Definition: gls_render_view_change_manager.h:62
Definition: bmpimage.h:46
static void AddRenderViewChangeListener(GlsRenderViewChangeListener *listener)
Definition: gls_render_view_change_manager.h:73
static void NotifyRenderViewChanged(const GlsMatrixType &modelViewMatrix)
Definition: gls_render_view_change_manager.h:89
Definition: gls_render_view_change_manager.h:66