1 //-----------------------------------------------------------------------------
2 // Overlay
3 //-----------------------------------------------------------------------------
4 
5 #ifndef __OVERLAY_H__
6 #define __OVERLAY_H__
7 
8 #include "world.h"
9 
10 static const colour_t text_colors[10]=
11 {
12   { 255, 255, 255, 255 },       // white  0
13   { 255,   0,   0, 255 },       // red    1
14   {   0, 255,   0, 255 },       // green  2
15   {   0,   0, 255, 255 },       // blue   3
16   { 255,   0, 255, 255 },       // magenta  4
17   { 255, 255,   0, 255 },       // yellow 5
18   {   0, 255, 255, 255 },       // cyan   6
19   {   0,   0,   0, 255 },       // black  7
20   {   0,   0,   0, 255 },       // black  8
21   {   0,   0,   0, 255 }        // black  9
22 };
23 
24 /**
25  * Overlay class.
26  * The overlay class permit textual information rendering. It also permits
27  * logos (or quads) display. For example, the console uses overlays to
28  * display texts.
29  * @todo Remake the public gOver overlay. It should have an internal shader
30  *       for text.
31  */
32 class Overlay
33 {
34   public:
35     void Init(void);
36     void Shut(void);
37 
38     /**
39      * Render the overlay.
40      * @param shaders the available shaders for rendering
41      */
42     void Render(ShaderManager *shaders);
43 
44     /**
45      * Defines a quad for display.
46      * The function does not directly displays the quad. You have to call
47      * the Render function to do it.
48      * @param shader the shader index that will be used for the quad
49      * @param x the position of left side
50      * @param y the position of top
51      * @param w the quad width
52      * @param h the quad height
53      * @param repx horizontal tiling
54      * @param repy vertical tiling
55      */
56     void Quad(int shader,
57           float x, float y,
58           float w, float h,
59           float repx = 1, float repy = 1);
60 
61     /**
62      * Render a string.
63      * @param str the string to write
64      * @param shader the font shader index
65      * @param x the left start position
66      * @param y the sart line top position (text is written upper the line)
67      * @param xsize the font width
68      * @param ysize the font height
69      * @param rows the height of a row
70      * @param cols the width of a column
71      * @param fontstyle the font style for string
72      */
73     void String(const char *str,
74           int shader,
75           float x, float y,
76           float xsize = 8, float ysize = 16,
77           float rows = 16, float cols = 16,
78           int fontstyle = 0);
79 
80     void SetWorld(World *w);
81 
82   private:
83 
84     unsigned int num_quads;
85     unsigned int num_elems;
86     unsigned int num_verts;
87 
88     Surface *quads;
89     int *elems;
90     vertex_t *verts;
91 
92     void CreateVerts(void);   /**< Creates the verts buffer */
93     void CreateQuads(void);   /**< Creates the quads buffer */
94     void CreateElems(void);   /**< Creates the elems buffer */
95 };
96 
97 #endif
98