Initial integration, lots of broken stuff
[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 <assert.h>
27
28 //#include <stdint.h>
29
30 //#include <SDL_video.h>
31
32 #include "glutil.hpp"
33 //#include "math/vector.hpp"
34 //#include "color.hpp"
35 //#include "font.hpp"
36 #include <unison/video/RenderOptions.hpp>
37
38 class Surface;
39
40 // some constants for predefined layer values
41 enum {
42   LAYER_BACKGROUND0 = -300,
43   LAYER_BACKGROUND1 = -200,
44   LAYER_BACKGROUNDTILES = -100,
45   LAYER_TILES = 0,
46   LAYER_OBJECTS = 50,
47   LAYER_FLOATINGOBJECTS = 150,
48   LAYER_FOREGROUNDTILES = 200,
49   LAYER_FOREGROUND0 = 300,
50   LAYER_FOREGROUND1 = 400,
51   LAYER_HUD = 500,
52   LAYER_GUI         = 600
53 };
54
55 class Blend
56 {
57 public:
58   GLenum sfactor;
59   GLenum dfactor;
60
61   Blend()
62     : sfactor(GL_SRC_ALPHA), dfactor(GL_ONE_MINUS_SRC_ALPHA)
63   {}
64
65   Blend(GLenum s, GLenum d)
66     : sfactor(s), dfactor(d)
67   {}
68
69   Unison::Video::BlendMode to_unison_blend() const
70   {
71     if(sfactor == GL_ONE && dfactor == GL_ZERO)
72     {
73       return Unison::Video::BLEND_NONE;
74     }
75     else if(sfactor == GL_SRC_ALPHA && dfactor == GL_ONE_MINUS_SRC_ALPHA)
76     {
77       return Unison::Video::BLEND_ALPHA;
78     }
79     else if(sfactor == GL_SRC_ALPHA && dfactor == GL_ONE)
80     {
81       return Unison::Video::BLEND_ADD;
82     }
83     else if(sfactor == GL_ZERO && dfactor == GL_SRC_COLOR)
84     {
85       return Unison::Video::BLEND_MOD;
86     }
87     else
88     {
89       assert(0 && "Unsupported blend factors");
90     }
91   }
92 };
93
94 enum Target {
95   NORMAL, LIGHTMAP
96 };
97
98 /*enum RequestType
99 {
100   SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, GETLIGHT
101 };
102
103 struct SurfacePartRequest
104 {
105   const Surface* surface;
106   Vector source, size;
107 };
108
109 struct TextRequest
110 {
111   const Font* font;
112   std::string text;
113   FontAlignment alignment;
114 };
115
116 struct GradientRequest
117 {
118   Color top, bottom;
119   Vector size;
120 };
121
122 struct FillRectRequest
123 {
124   Color color;
125   Vector size;
126 };
127
128 struct DrawingRequest
129 {
130   Target target;
131   RequestType type;
132   Vector pos;
133
134   int layer;
135   DrawingEffect drawing_effect;
136   float alpha;
137   Blend blend;
138   float angle;
139   Color color;
140
141   void* request_data;
142
143   DrawingRequest()
144     : angle(0.0f),
145       color(1.0f, 1.0f, 1.0f, 1.0f)
146   {}
147
148   bool operator<(const DrawingRequest& other) const
149   {
150     return layer < other.layer;
151   }
152 };
153
154 struct GetLightRequest
155 {
156   Color* color_ptr;
157 };*/
158
159 #endif
160