More -Weffc++ cleanup
[supertux.git] / src / video / drawing_request.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program 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 //  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP
18 #define HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP
19
20 #include <memory>
21 #include <string>
22 #include <vector>
23
24 #include <stdint.h>
25
26 #include "math/vector.hpp"
27 #include "video/color.hpp"
28 #include "video/font.hpp"
29 #include "video/glutil.hpp"
30
31 class Surface;
32
33 // some constants for predefined layer values
34 enum {
35   LAYER_BACKGROUND0 = -300,
36   LAYER_BACKGROUND1 = -200,
37   LAYER_BACKGROUNDTILES = -100,
38   LAYER_TILES = 0,
39   LAYER_OBJECTS = 50,
40   LAYER_FLOATINGOBJECTS = 150,
41   LAYER_FOREGROUNDTILES = 200,
42   LAYER_FOREGROUND0 = 300,
43   LAYER_FOREGROUND1 = 400,
44   LAYER_HUD = 500,
45   LAYER_GUI         = 600
46 };
47
48 class Blend
49 {
50 public:
51   GLenum sfactor;
52   GLenum dfactor;
53
54   Blend()
55     : sfactor(GL_SRC_ALPHA), dfactor(GL_ONE_MINUS_SRC_ALPHA)
56   {}
57
58   Blend(GLenum s, GLenum d)
59     : sfactor(s), dfactor(d)
60   {}
61 };
62
63 enum Target {
64   NORMAL, LIGHTMAP
65 };
66
67 enum RequestType
68 {
69   SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, INVERSEELLIPSE, DRAW_LIGHTMAP, GETLIGHT
70 };
71
72 struct SurfacePartRequest
73 {
74   SurfacePartRequest() :
75     surface(),
76     source(),
77     size()
78   {}
79
80   const Surface* surface;
81   Vector source;
82   Vector size;
83 };
84
85 struct TextRequest
86 {
87   TextRequest() :
88     font(),
89     text(),
90     alignment()
91   {}
92
93   const Font* font;
94   std::string text;
95   FontAlignment alignment;
96
97 private:
98   TextRequest(const TextRequest&);
99   TextRequest& operator=(const TextRequest&);
100 };
101
102 struct GradientRequest
103 {
104   GradientRequest()  :
105     top(),
106     bottom(),
107     size()
108   {}
109
110   Color top;
111   Color bottom;
112   Vector size;
113 };
114
115 struct FillRectRequest
116 {
117   FillRectRequest() :
118     color(),
119     size(),
120     radius()
121   {}
122
123   Color  color;
124   Vector size;
125   float  radius;
126 };
127
128 struct InverseEllipseRequest
129 {
130   InverseEllipseRequest() :
131     color(),
132     size()
133   {}
134
135   Color  color;
136   Vector size;
137 };
138
139 struct DrawingRequest
140 {
141   Target target;
142   RequestType type;
143   Vector pos;
144
145   int layer;
146   DrawingEffect drawing_effect;
147   float alpha;
148   Blend blend;
149   float angle;
150   Color color;
151
152   void* request_data;
153
154   DrawingRequest() :
155     target(),
156     type(),
157     pos(),
158     layer(),
159     drawing_effect(),
160     alpha(),
161     blend(),
162     angle(0.0f),
163     color(1.0f, 1.0f, 1.0f, 1.0f),
164     request_data()
165   {}
166
167   bool operator<(const DrawingRequest& other) const
168   {
169     return layer < other.layer;
170   }
171 };
172
173 struct GetLightRequest
174 {
175   Color* color_ptr;
176 };
177
178 #endif
179
180 /* EOF */