Crazy Eddie's GUI System  ${CEGUI_VERSION}
EffectsDemo.h
1 /***********************************************************************
2  created: 9/7/2012
3  author: Lukas E Meindl
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _Effects_Demo_
28 #define _Effects_Demo_
29 
30 #include "SampleBase.h"
31 #include "CEGUI/CEGUI.h"
32 
34 {
35 public:
37 
38  // implement required functions from RenderEffect interface.
39  int getPassCount() const;
40  void performPreRenderFunctions(const int pass);
43  bool update(const float elapsed, CEGUI::RenderingWindow& window);
44 
45 protected:
46  void syncPivots(CEGUI::RenderingWindow& window);
47 
48  // number of horizontal subdivisions
49  static const int ds_xPivotCount = 11;
50  // number of vertical subdivisions
51  static const int ds_yPivotCount = 11;
52 
53  CEGUI::Vector2f d_pivots[ds_xPivotCount][ds_yPivotCount];
54  CEGUI::Vector2f d_pivotVelocities[ds_xPivotCount][ds_yPivotCount];
55 
56  bool d_initialised;
57 
58  // we need 6 vertices for two triangles = one quad
59  //
60  // lets say we have 3x3 subdivision
61  //
62  // *---*---*
63  // | | |
64  // *---*---*
65  // | | |
66  // *---*---*
67  //
68  // as we can see, we have 2x2 quads for 3x3 subdivision (because of reused
69  // neighbouring vertices)
70  static const unsigned int ds_vertexCount = (ds_xPivotCount - 1) * (ds_yPivotCount - 1) * 6;
71  CEGUI::Vertex d_vertices[ds_vertexCount];
72 
73  CEGUI::FrameWindow* d_window;
74 };
75 
76 // Sample subclass for CEGUI::RenderEffect. This particluar implementation
77 // provides a basic 'wobbly window' type effect.
79 {
80 public:
82 
83  // implement required functions from RenderEffect interface.
84  int getPassCount() const;
85  void performPreRenderFunctions(const int pass);
88  bool update(const float elapsed, CEGUI::RenderingWindow& window);
89 
90 protected:
91  static const float tess_x;
92  static const float tess_y;
93  // tess_x * tess_y * vertex_per_quad
94  static const int buffsize = (8 * 8 * 6);
95 
96  bool initialised;
97 
98  float lastX, lastY;
99  float dragX, dragY;
100  float elasX, elasY;
101 
102  CEGUI::Vertex vb[buffsize];
103 
104  CEGUI::Window* d_window;
105 };
106 
108 {
109 public:
111 
112  // implement required functions from RenderEffect interface.
113  int getPassCount() const;
114  void performPreRenderFunctions(const int pass);
117  bool update(const float elapsed, CEGUI::RenderingWindow& window);
118 
119 protected:
120  CEGUI::Vector2f d_currentPosition;
121  CEGUI::Vector2f d_currentVelocity;
122 
123  bool d_initialised;
124 
125  static const unsigned int ds_vertexCount = 6;
126  CEGUI::Vertex d_vertices[ds_vertexCount];
127 
128  CEGUI::Window* d_window;
129 };
130 
131 // Sample class
132 class EffectsDemo : public Sample
133 {
134 public:
135  // method to initialse the samples windows and events.
136  virtual bool initialise(CEGUI::GUIContext* guiContext);
137 
138  // method to perform any required cleanup operations.
139  virtual void deinitialise();
140 
141 protected:
142  // Initialiser for the effects in the combobox
143  void initialiseEffectsCombobox(CEGUI::Combobox* effectsCombobox);
144 
145  // Handler for the selection changes in the effects combobox
146  bool handleEffectsComboboxSelectionChanged(const CEGUI::EventArgs& args);
147 
148  // Initialise the RenderEffects we will switch between using the combobox
149  void initialiseEffects(CEGUI::Window* effectsWindow);
150 
151  // Names for the effects
152  static const CEGUI::String s_effectNameElastic;
153  static const CEGUI::String s_effectNameWobblyNew;
154  static const CEGUI::String s_effectNameWobblyOld;
155 
156  CEGUI::RenderEffect* d_renderEffectElastic;
157  CEGUI::RenderEffect* d_renderEffectWobblyNew;
158  CEGUI::RenderEffect* d_renderEffectWobblyOld;
159 
160  // The listbox items of the effects combobox
161  CEGUI::ListboxItem* d_listItemEffectElastic;
162  CEGUI::ListboxItem* d_listItemEffectWobblyNew;
163  CEGUI::ListboxItem* d_listItemEffectWobblyOld;
164  CEGUI::ListboxItem* d_listItemEffectNone;
165 
166  CEGUI::GUIContext* d_guiContext;
167 };
168 
169 
170 // Sample sub-class for ListboxTextItem that auto-sets the selection brush
171 // image. This saves doing it manually every time in the code.
173 {
174 public:
175  MyListItem(const CEGUI::String& text) : ListboxTextItem(text)
176  {
177  setSelectionBrushImage("TaharezLook/MultiListSelectionBrush");
178  }
179 };
180 
181 
182 #endif
bool realiseGeometry(CEGUI::RenderingWindow &window, CEGUI::GeometryBuffer &geometry)
Function called to generate geometry for the RenderingWindow.
Definition: EffectsDemo.cpp:86
Definition: cegui/include/CEGUI/GUIContext.h:68
Interface for objects that hook into RenderingWindow to affect the rendering process, thus allowing various effects to be achieved.
Definition: cegui/include/CEGUI/RenderEffect.h:40
void performPreRenderFunctions(const int pass)
Function called prior to RenderingWindow::draw being called. This is intended to be used for any requ...
Definition: EffectsDemo.cpp:50
Base class for the Combobox widget.
Definition: cegui/include/CEGUI/widgets/Combobox.h:50
Base class used as the argument to all subscribers Event object.
Definition: cegui/include/CEGUI/EventArgs.h:49
structure that is used to hold details of a single vertex in 3D space.
Definition: cegui/include/CEGUI/Vertex.h:40
Definition: EffectsDemo.h:107
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: cegui/include/CEGUI/GeometryBuffer.h:42
Definition: EffectsDemo.h:172
int getPassCount() const
Return the number of passes required by this effect.
Definition: EffectsDemo.cpp:44
RenderingWindow is a RenderingSurface that can be "drawn back" onto another RenderingSurface and is p...
Definition: cegui/include/CEGUI/RenderingWindow.h:50
void performPostRenderFunctions()
Function called after RenderingWindow::draw is called. This is intended to be used for any required c...
Definition: EffectsDemo.cpp:56
Class used for textual items in a list box.
Definition: cegui/include/CEGUI/widgets/ListboxTextItem.h:42
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: cegui/include/CEGUI/Window.h:149
Definition: EffectsDemo.h:132
Base class for list box items.
Definition: cegui/include/CEGUI/widgets/ListboxItem.h:51
Abstract base class for a movable, sizable, window with a title-bar and a frame.
Definition: cegui/include/CEGUI/widgets/FrameWindow.h:48
Definition: EffectsDemo.h:78
bool update(const float elapsed, CEGUI::RenderingWindow &window)
Function called to perform any time based updates on the RenderEffect state.
Definition: EffectsDemo.cpp:156
Definition: EffectsDemo.h:33
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62
Definition: Sample.h:36