1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#ifndef TILEBUF_H
#define TILEBUF_H
#include "glwrapper.h"
#include <string>
#include <vector>
class FontWrapper;
class formatted_string;
class GenericTexture;
class TilesTexture;
class VertBuffer
{
public:
VertBuffer(bool texture, bool colour, const GenericTexture *tex = NULL,
drawing_modes prim = GLW_RECTANGLE);
~VertBuffer();
// Rendering
// void draw(const GLW_3VF *pt = NULL, const GLW_3VF *ps = NULL) const;
void draw() const;
// State query
const GLState& state() const { return m_state; }
const GenericTexture* current_texture() const { return m_tex; }
unsigned int size() const;
// State Manipulation
void add_primitive(const GLWPrim &rect);
void clear();
// Note: this could invalidate previous additions if they were
// from a different texture.
// But we leave it here as a convenience and because it is required to set
// textures that load late. Specifically ones that rely on the item
// description tables -- Ixtli
void set_tex(const GenericTexture *tex);
protected:
const GenericTexture *m_tex;
GLShapeBuffer *m_vert_buf;
GLState m_state;
drawing_modes m_prim;
bool m_colour_verts;
bool m_texture_verts;
};
class FontBuffer : public VertBuffer
{
public:
FontBuffer(FontWrapper *font);
void add(const formatted_string &fs, float x, float y);
void add(const string &s, const VColour &col, float x, float y);
protected:
FontWrapper *m_font;
};
class TileBuffer : public VertBuffer
{
public:
TileBuffer(const TilesTexture *tex = NULL);
void add_unscaled(tileidx_t idx, float x, float y, int ymax = TILE_Y,
float scale = 1.0f);
void add(tileidx_t idx, int x, int y,
int ox = 0, int oy = 0, bool centre = true, int ymax = -1,
float tile_x = TILE_X, float tile_y = TILE_Y);
};
class ColouredTileBuffer : public VertBuffer
{
public:
ColouredTileBuffer(const TilesTexture *tex = NULL);
void add(tileidx_t idx, int x, int y, int z,
int ox, int oy, int ymin, int ymax,
int alpha_top, int alpha_bottom);
};
// Helper class for tiles submerged in water.
class SubmergedTileBuffer
{
public:
SubmergedTileBuffer(const TilesTexture *tex, int water_level);
void add(tileidx_t idx, int x, int y, int z = 0, bool submerged = false,
bool ghost = false, int ox = 0, int oy = 0, int ymax = -1);
void add_alpha(tileidx_t idx, int x, int y, int z,
int ox, int oy, int ymax, int alpha);
void add_masked(tileidx_t idx, int x, int y, int z,
int ox, int oy, int ymax,
int alpha_above, int alpha_below, int water_level = 0);
void draw() const;
void clear();
protected:
int m_water_level;
ColouredTileBuffer m_below_water;
ColouredTileBuffer m_above_water;
};
class ShapeBuffer : public VertBuffer
{
public:
ShapeBuffer();
void add(float sx, float sy, float ex, float ey, const VColour &c);
};
class LineBuffer : public VertBuffer
{
public:
LineBuffer();
void add(float sx, float sy, float ex, float ey, const VColour &c);
void add_square(float sx, float sy, float ex, float ey, const VColour &c);
};
#endif
|