Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[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   const Surface* surface;
75   Vector source, size;
76 };
77
78 struct TextRequest
79 {
80   const Font* font;
81   std::string text;
82   FontAlignment alignment;
83 };
84
85 struct GradientRequest
86 {
87   Color top, bottom;
88   Vector size;
89 };
90
91 struct FillRectRequest
92 {
93   Color  color;
94   Vector size;
95   float  radius;
96 };
97
98 struct InverseEllipseRequest
99 {
100   Color  color;
101   Vector size;
102 };
103
104 struct DrawingRequest
105 {
106   Target target;
107   RequestType type;
108   Vector pos;
109
110   int layer;
111   DrawingEffect drawing_effect;
112   float alpha;
113   Blend blend;
114   float angle;
115   Color color;
116
117   void* request_data;
118
119   DrawingRequest() :
120     target(),
121     type(),
122     pos(),
123     layer(),
124     drawing_effect(),
125     alpha(),
126     blend(),
127     angle(0.0f),
128     color(1.0f, 1.0f, 1.0f, 1.0f),
129     request_data()
130   {}
131
132   bool operator<(const DrawingRequest& other) const
133   {
134     return layer < other.layer;
135   }
136 };
137
138 struct GetLightRequest
139 {
140   Color* color_ptr;
141 };
142
143 #endif
144
145 /* EOF */