00001
00002
00003
00004
00005
00006 #ifndef TILEBUF_H
00007 #define TILEBUF_H
00008
00009 #include "glwrapper.h"
00010
00011 #include <string>
00012 #include <vector>
00013
00014 class FontWrapper;
00015 class formatted_string;
00016 class GenericTexture;
00017 class TilesTexture;
00018
00019 class VertBuffer
00020 {
00021 public:
00022 VertBuffer(bool texture, bool colour, const GenericTexture *tex = NULL,
00023 drawing_modes prim = GLW_RECTANGLE);
00024 ~VertBuffer();
00025
00026
00027
00028 void draw() const;
00029
00030
00031 const GLState& state() const { return m_state; }
00032 const GenericTexture* current_texture() const { return m_tex; }
00033 unsigned int size() const;
00034
00035
00036 void add_primitive(const GLWPrim &rect);
00037 void clear();
00038
00039
00040
00041
00042
00043
00044 void set_tex(const GenericTexture *tex);
00045
00046 protected:
00047 const GenericTexture *m_tex;
00048 GLShapeBuffer *m_vert_buf;
00049 GLState m_state;
00050 drawing_modes m_prim;
00051 bool m_colour_verts;
00052 bool m_texture_verts;
00053 };
00054
00055 class FontBuffer : public VertBuffer
00056 {
00057 public:
00058 FontBuffer(FontWrapper *font);
00059 void add(const formatted_string &fs, float x, float y);
00060 void add(const std::string &s, const VColour &col, float x, float y);
00061 protected:
00062 FontWrapper *m_font;
00063 };
00064
00065 class TileBuffer : public VertBuffer
00066 {
00067 public:
00068 TileBuffer(const TilesTexture *tex = NULL);
00069
00070 void add_unscaled(tileidx_t idx, float x, float y, int ymax = TILE_Y);
00071 void add(tileidx_t idx, int x, int y,
00072 int ox = 0, int oy = 0, bool centre = true, int ymax = -1);
00073 };
00074
00075 class ColouredTileBuffer : public VertBuffer
00076 {
00077 public:
00078 ColouredTileBuffer(const TilesTexture *tex = NULL);
00079
00080 void add(tileidx_t idx, int x, int y, int z,
00081 int ox, int oy, int ymin, int ymax,
00082 int alpha_top, int alpha_bottom);
00083 };
00084
00085
00086 class SubmergedTileBuffer
00087 {
00088 public:
00089 SubmergedTileBuffer(const TilesTexture *tex, int water_level);
00090
00091 void add(tileidx_t idx, int x, int y, int z = 0, bool submerged = false,
00092 bool ghost = false, int ox = 0, int oy = 0, int ymax = -1);
00093
00094 void draw() const;
00095 void clear();
00096
00097 protected:
00098 int m_water_level;
00099
00100 ColouredTileBuffer m_below_water;
00101 ColouredTileBuffer m_above_water;
00102 };
00103
00104 class ShapeBuffer : public VertBuffer
00105 {
00106 public:
00107 ShapeBuffer();
00108 void add(float sx, float sy, float ex, float ey, const VColour &c);
00109 };
00110
00111 class LineBuffer : public VertBuffer
00112 {
00113 public:
00114 LineBuffer();
00115 void add(float sx, float sy, float ex, float ey, const VColour &c);
00116 void add_square(float sx, float sy, float ex, float ey, const VColour &c);
00117 };
00118
00119 #endif