725a346b96876a53ec748633056d7f420c0f7351
[supertux.git] / src / video / drawing_request.hpp
1 //  $Id: drawing_request.hpp 4986 2007-04-16 17:48:28Z matzeb $
2 //
3 //  SuperTux
4 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 #ifndef SUPERTUX_DRAWINGREQUEST_H
20 #define SUPERTUX_DRAWINGREQUEST_H
21
22 #include <vector>
23 #include <string>
24 #include <memory>
25
26 #include <stdint.h>
27
28 #include "glutil.hpp"
29 #include "color.hpp"
30 #include "font.hpp"
31 #include "math/vector.hpp"
32
33 class Surface;
34
35 // some constants for predefined layer values
36 enum {
37   LAYER_BACKGROUND0 = -300,
38   LAYER_BACKGROUND1 = -200,
39   LAYER_BACKGROUNDTILES = -100,
40   LAYER_TILES = 0,
41   LAYER_OBJECTS = 50,
42   LAYER_FLOATINGOBJECTS = 150,
43   LAYER_FOREGROUNDTILES = 200,
44   LAYER_FOREGROUND0 = 300,
45   LAYER_FOREGROUND1 = 400,
46   LAYER_HUD = 500,
47   LAYER_GUI         = 600
48 };
49
50 class Blend
51 {
52 public:
53   GLenum sfactor;
54   GLenum dfactor;
55
56   Blend()
57     : sfactor(GL_SRC_ALPHA), dfactor(GL_ONE_MINUS_SRC_ALPHA)
58   {}
59
60   Blend(GLenum s, GLenum d)
61     : sfactor(s), dfactor(d)
62   {}
63 };
64
65 enum Target {
66   NORMAL, LIGHTMAP
67 };
68
69 enum RequestType
70 {
71   SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, INVERSEELLIPSE, DRAW_LIGHTMAP, GETLIGHT
72 };
73
74 struct SurfacePartRequest
75 {
76   const Surface* surface;
77   Vector source, size;
78 };
79
80 struct TextRequest
81 {
82   const Font* font;
83   std::string text;
84   FontAlignment alignment;
85 };
86
87 struct GradientRequest
88 {
89   Color top, bottom;
90   Vector size;
91 };
92
93 struct FillRectRequest
94 {
95   Color  color;
96   Vector size;
97   float  radius;
98 };
99
100 struct InverseEllipseRequest
101 {
102   Color  color;
103   Vector size;
104 };
105
106 struct DrawingRequest
107 {
108   Target target;
109   RequestType type;
110   Vector pos;
111
112   int layer;
113   DrawingEffect drawing_effect;
114   float alpha;
115   Blend blend;
116   float angle;
117   Color color;
118
119   void* request_data;
120
121   DrawingRequest()
122     : angle(0.0f),
123       color(1.0f, 1.0f, 1.0f, 1.0f)
124   {}
125
126   bool operator<(const DrawingRequest& other) const
127   {
128     return layer < other.layer;
129   }
130 };
131
132 struct GetLightRequest
133 {
134   Color* color_ptr;
135 };
136
137 #endif
138