Spinning Topp Logo BlackTopp Studios
inc
simplerenderer.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _uisimplerenderer_h
42 #define _uisimplerenderer_h
43 
44 #include "UI/vertex.h"
45 #include "XML/xml.h"
46 
47 namespace Mezzanine
48 {
49  namespace UI
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief A simple class providing basic methods to generate vertices with.
53  /// @details
54  ///////////////////////////////////////
56  {
57  protected:
58  /// @internal
59  /// @brief This determines whether or not the vertices in this renderer need to be refreshed.
61  /// @internal
62  /// @brief This contains the name of the atlas that will be used as default when one isn't specified.
64  /// @internal
65  /// @brief This is a container storing all the vertices generated by this renderer.
66  std::vector<VertexData> RenderVertices;
67  /// @internal
68  /// @brief Provides the class specific implementation for regenerating vertices for this renderable.
69  /// @param Force Whether or not to force the regenerating of vertices regardless of whether or not the data is dirty.
70  virtual void RedrawImpl(Boole Force) = 0;
71  /// @internal
72  /// @brief Collects all the relevant information for a single vertex and pushes it to a vector.
73  /// @param X The vertex position on the X axis.
74  /// @param Y The vertex position on the Y axis.
75  /// @param UV The Vertex texture coordinates.
76  /// @param Colour The Vertex colour.
77  /// @param Atlas The name of the Atlas to use for the UV coordinates.
78  virtual void PushVertex(const Real& X, const Real& Y, const Vector2& UV, const ColourValue& Colour, const String& Atlas);
79  /// @internal
80  /// @brief Pushes vertex information for a triangle to a vector. Equivalent to calling "PushVertex" three times.
81  /// @note This is primarily useful when your Vertices aren't using an actual image for their rendering due to the reuse of the UV.
82  /// @param A The position of the first vertex.
83  /// @param B The position of the second vertex.
84  /// @param C The position of the third vertex.
85  /// @param UV The texture coordinates to be appended to all three vertices.
86  /// @param Colour The colour for all 3 vertices to be appended.
87  /// @param Atlas The name of the Atlas to use for the UV coordinates.
88  virtual void PushTriangle(const Vector2& A, const Vector2& B, const Vector2& C, const Vector2& UV, const ColourValue& Colour, const String& Atlas);
89  //public:
90  /// @brief Class constructor.
92  /// @brief Class destructor.
93  virtual ~SimpleRenderer();
94  public:
95  ///////////////////////////////////////////////////////////////////////////////
96  // Utility Methods
97 
98  /// @brief Sets the Atlas to be assumed when one isn't provided for atlas related tasks.
99  /// @param Atlas The name of the atlas to be used.
100  virtual void SetPrimaryAtlas(const String& Atlas);
101  /// @brief Gets the currently set primary atlas.
102  /// @return Returns a string containing the name of the primary atlas that is set, or an empty string if none.
103  virtual String GetPrimaryAtlas() const;
104 
105  ///////////////////////////////////////////////////////////////////////////////
106  // Serialization
107 
108  /// @brief Convert this class to an XML::Node ready for serialization.
109  /// @param ParentNode The point in the XML hierarchy that all this renderable should be appended to.
110  virtual void ProtoSerialize(XML::Node& ParentNode) const;
111  /// @brief Convert the properties of this class to an XML::Node ready for serialization.
112  /// @param SelfRoot The root node containing all the serialized data for this instance.
113  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
114 
115  /// @brief Take the data stored in an XML Node and overwrite this object with it.
116  /// @param SelfRoot An XML::Node containing the data to populate this class with.
117  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
118  /// @brief Take the data stored in an XML Node and overwrite the properties of this object with it.
119  /// @param SelfRoot An XML::Node containing the data to populate this class with.
120  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
121 
122  /// @brief Gets the most derived serializable name of this Renderable.
123  /// @note When creating a new Renderable class verify this method has a valid return for it in order for serialization to work properly.
124  /// @return Returns the name of the XML tag from the most derived class of "this".
125  virtual String GetDerivedSerializableName() const;
126  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
127  /// @return A string containing the name of this class.
128  static String GetSerializableName();
129 
130  ///////////////////////////////////////////////////////////////////////////////
131  // Internal Methods
132 
133  /// @internal
134  /// @brief Marks this renderable as well as all parent objects as dirty.
135  virtual void _MarkDirty() = 0;
136  /// @internal
137  /// @brief Gets whether or not this renderer is dirty.
138  /// @return Returns true if this renderer is dirty, false otherwise.
139  Boole _IsDirty();
140  /// @internal
141  /// @brief Regenerates the verticies in this renderable.
142  /// @param Force If true this will force this object to redraw it's verticies regardless of whether it is dirty.
143  void _Redraw(Boole Force);
144  /// @internal
145  /// @brief Appends the vertices of this renderable to another vector.
146  /// @param Vertices The vector of vertex's to append to.
147  void _AppendVertices(std::vector<VertexData>& Vertices);
148  };//SimpleRenderer
149  }//UI
150 }//Mezzanine
151 
152 #endif
A simple class providing basic methods to generate vertices with.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
String PriAtlas
This contains the name of the atlas that will be used as default when one isn't specified.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
std::vector< VertexData > RenderVertices
This is a container storing all the vertices generated by this renderer.
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
Boole Dirty
This determines whether or not the vertices in this renderer need to be refreshed.
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159