1 /***********************************************************************
2     created:    Fri Jan 15 20109
3     author:     Eugene Marcotte
4 *************************************************************************/
5 /***************************************************************************
6  *   Copyright (C) 2004 - 2010 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 #include "CEGUI/RendererModules/Null/GeometryBuffer.h"
28 #include "CEGUI/RendererModules/Null/Texture.h"
29 #include "CEGUI/Vertex.h"
30 #include "CEGUI/RenderEffect.h"
31 
32 // Start of CEGUI namespace section
33 namespace CEGUI
34 {
35 //----------------------------------------------------------------------------//
NullGeometryBuffer()36 NullGeometryBuffer::NullGeometryBuffer() :
37     d_activeTexture(0),
38     d_clipRect(0, 0, 0, 0),
39     d_clippingActive(true),
40     d_translation(0, 0, 0),
41     d_rotation(),
42     d_pivot(0, 0, 0),
43     d_effect(0)
44 {
45 }
46 
47 //----------------------------------------------------------------------------//
~NullGeometryBuffer()48 NullGeometryBuffer::~NullGeometryBuffer()
49 {
50 }
51 
52 //----------------------------------------------------------------------------//
draw() const53 void NullGeometryBuffer::draw() const
54 {
55     const int pass_count = d_effect ? d_effect->getPassCount() : 1;
56     for (int pass = 0; pass < pass_count; ++pass)
57     {
58         // set up RenderEffect
59         if (d_effect)
60             d_effect->performPreRenderFunctions(pass);
61     }
62 
63     // clean up RenderEffect
64     if (d_effect)
65         d_effect->performPostRenderFunctions();
66 }
67 
68 //----------------------------------------------------------------------------//
setTranslation(const Vector3f & v)69 void NullGeometryBuffer::setTranslation(const Vector3f& v)
70 {
71     d_translation = v;
72 }
73 
74 //----------------------------------------------------------------------------//
setRotation(const Quaternion & r)75 void NullGeometryBuffer::setRotation(const Quaternion& r)
76 {
77     d_rotation = r;
78 }
79 
80 //----------------------------------------------------------------------------//
setPivot(const Vector3f & p)81 void NullGeometryBuffer::setPivot(const Vector3f& p)
82 {
83     d_pivot = p;
84 }
85 
86 //----------------------------------------------------------------------------//
setClippingRegion(const Rectf & region)87 void NullGeometryBuffer::setClippingRegion(const Rectf& region)
88 {
89     d_clipRect.top(ceguimax(0.0f, region.top()));
90     d_clipRect.bottom(ceguimax(0.0f, region.bottom()));
91     d_clipRect.left(ceguimax(0.0f, region.left()));
92     d_clipRect.right(ceguimax(0.0f, region.right()));
93 }
94 
95 //----------------------------------------------------------------------------//
appendVertex(const Vertex & vertex)96 void NullGeometryBuffer::appendVertex(const Vertex& vertex)
97 {
98     appendGeometry(&vertex, 1);
99 }
100 
101 //----------------------------------------------------------------------------//
appendGeometry(const Vertex * const vbuff,uint vertex_count)102 void NullGeometryBuffer::appendGeometry(const Vertex* const vbuff,
103                                         uint vertex_count)
104 {
105     // buffer these vertices
106     for (uint i = 0; i < vertex_count; ++i)
107     {
108         d_vertices.push_back(vbuff[i]);
109     }
110 }
111 
112 //----------------------------------------------------------------------------//
setActiveTexture(Texture * texture)113 void NullGeometryBuffer::setActiveTexture(Texture* texture)
114 {
115     d_activeTexture = static_cast<NullTexture*>(texture);
116 }
117 
118 //----------------------------------------------------------------------------//
reset()119 void NullGeometryBuffer::reset()
120 {
121     d_vertices.clear();
122 }
123 
124 //----------------------------------------------------------------------------//
getActiveTexture() const125 Texture* NullGeometryBuffer::getActiveTexture() const
126 {
127     return d_activeTexture;
128 }
129 
130 //----------------------------------------------------------------------------//
getVertexCount() const131 uint NullGeometryBuffer::getVertexCount() const
132 {
133     return d_vertices.size();
134 }
135 
136 //----------------------------------------------------------------------------//
getBatchCount() const137 uint NullGeometryBuffer::getBatchCount() const
138 {
139     return 1;
140 }
141 
142 //----------------------------------------------------------------------------//
setRenderEffect(RenderEffect * effect)143 void NullGeometryBuffer::setRenderEffect(RenderEffect* effect)
144 {
145     d_effect = effect;
146 }
147 
148 //----------------------------------------------------------------------------//
getRenderEffect()149 RenderEffect* NullGeometryBuffer::getRenderEffect()
150 {
151     return d_effect;
152 }
153 
154 //----------------------------------------------------------------------------//
setClippingActive(const bool active)155 void NullGeometryBuffer::setClippingActive(const bool active)
156 {
157     d_clippingActive = active;
158 }
159 
160 //----------------------------------------------------------------------------//
isClippingActive() const161 bool NullGeometryBuffer::isClippingActive() const
162 {
163     return d_clippingActive;
164 }
165 
166 //----------------------------------------------------------------------------//
167 
168 } // End of  CEGUI namespace section
169