src/video/drawing_request.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP
00018 #define HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP
00019 
00020 #include <memory>
00021 #include <string>
00022 #include <vector>
00023 
00024 #include <stdint.h>
00025 
00026 #include "math/vector.hpp"
00027 #include "video/color.hpp"
00028 #include "video/font.hpp"
00029 #include "video/glutil.hpp"
00030 
00031 class Surface;
00032 
00033 // some constants for predefined layer values
00034 enum {
00035   // Image/gradient backgrounds (should cover entire screen)
00036   LAYER_BACKGROUND0 = -300,
00037   // Particle backgrounds
00038   LAYER_BACKGROUND1 = -200,
00039   // Tilemap backgrounds
00040   LAYER_BACKGROUNDTILES = -100,
00041   // Solid tilemaps
00042   LAYER_TILES = 0,
00043   // Ordinary objects
00044   LAYER_OBJECTS = 50,
00045   // Objects that pass through walls
00046   LAYER_FLOATINGOBJECTS = 150,
00047   // 
00048   LAYER_FOREGROUNDTILES = 200,
00049   // 
00050   LAYER_FOREGROUND0 = 300,
00051   // 
00052   LAYER_FOREGROUND1 = 400,
00053   // Hitpoints, time, coins, etc.
00054   LAYER_HUD = 500,
00055   // Menus, mouse, console etc.
00056   LAYER_GUI         = 600
00057 };
00058 
00059 class Blend
00060 {
00061 public:
00062   GLenum sfactor;
00063   GLenum dfactor;
00064 
00065   Blend()
00066     : sfactor(GL_SRC_ALPHA), dfactor(GL_ONE_MINUS_SRC_ALPHA)
00067   {}
00068 
00069   Blend(GLenum s, GLenum d)
00070     : sfactor(s), dfactor(d)
00071   {}
00072 };
00073 
00074 enum Target {
00075   NORMAL, LIGHTMAP
00076 };
00077 
00078 enum RequestType
00079 {
00080   SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, INVERSEELLIPSE, DRAW_LIGHTMAP, GETLIGHT
00081 };
00082 
00083 struct SurfacePartRequest
00084 {
00085   SurfacePartRequest() :
00086     surface(),
00087     source(),
00088     size()
00089   {}
00090 
00091   const Surface* surface;
00092   Vector source;
00093   Vector size;
00094 };
00095 
00096 struct TextRequest
00097 {
00098   TextRequest() :
00099     font(),
00100     text(),
00101     alignment()
00102   {}
00103 
00104   const Font* font;
00105   std::string text;
00106   FontAlignment alignment;
00107 
00108 private:
00109   TextRequest(const TextRequest&);
00110   TextRequest& operator=(const TextRequest&);
00111 };
00112 
00113 struct GradientRequest
00114 {
00115   GradientRequest()  :
00116     top(),
00117     bottom(),
00118     size()
00119   {}
00120 
00121   Color top;
00122   Color bottom;
00123   Vector size;
00124 };
00125 
00126 struct FillRectRequest
00127 {
00128   FillRectRequest() :
00129     color(),
00130     size(),
00131     radius()
00132   {}
00133 
00134   Color  color;
00135   Vector size;
00136   float  radius;
00137 };
00138 
00139 struct InverseEllipseRequest
00140 {
00141   InverseEllipseRequest() :
00142     color(),
00143     size()
00144   {}
00145 
00146   Color  color;
00147   Vector size;
00148 };
00149 
00150 struct DrawingRequest
00151 {
00152   Target target;
00153   RequestType type;
00154   Vector pos;
00155 
00156   int layer;
00157   DrawingEffect drawing_effect;
00158   float alpha;
00159   Blend blend;
00160   float angle;
00161   Color color;
00162 
00163   void* request_data;
00164 
00165   DrawingRequest() :
00166     target(),
00167     type(),
00168     pos(),
00169     layer(),
00170     drawing_effect(),
00171     alpha(),
00172     blend(),
00173     angle(0.0f),
00174     color(1.0f, 1.0f, 1.0f, 1.0f),
00175     request_data()
00176   {}
00177 
00178   bool operator<(const DrawingRequest& other) const
00179   {
00180     return layer < other.layer;
00181   }
00182 };
00183 
00184 struct GetLightRequest
00185 {
00186   Color* color_ptr;
00187 };
00188 
00189 #endif
00190 
00191 /* EOF */

Generated on Mon Jun 9 03:38:24 2014 for SuperTux by  doxygen 1.5.1