Selaa lähdekoodia

Documented GLString class

Thomas Buck 11 vuotta sitten
vanhempi
commit
6116f666fa
3 muutettua tiedostoa jossa 135 lisäystä ja 251 poistoa
  1. 1
    1
      Doxyfile
  2. 6
    21
      src/GLString.cpp
  3. 128
    229
      src/GLString.h

+ 1
- 1
Doxyfile Näytä tiedosto

@@ -358,7 +358,7 @@ INLINE_GROUPED_CLASSES = NO
358 358
 # Man pages) or section (for LaTeX and RTF).
359 359
 # The default value is: NO.
360 360
 
361
-INLINE_SIMPLE_STRUCTS  = NO
361
+INLINE_SIMPLE_STRUCTS  = YES
362 362
 
363 363
 # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
364 364
 # enum is documented as struct, union, or enum with the name of the typedef. So

+ 6
- 21
src/GLString.cpp Näytä tiedosto

@@ -1,23 +1,9 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file GLString.cpp
3
+ * \brief Open GL rendering font/string class
3 4
  *
4
- * Project : Mtk
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : GLString
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: Open GL rendering font/string class
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2002.01.01:
19
- * Mongoose - Created
20
- =================================================================*/
5
+ * \author Mongoose
6
+ */
21 7
 
22 8
 #include <string.h>
23 9
 #include <stdio.h>
@@ -34,11 +20,10 @@
34 20
 #include "GLString.h"
35 21
 
36 22
 #ifdef DEBUG_MEMEORY
37
-#   include "memeory_test.h"
23
+#include "memeory_test.h"
38 24
 #endif
39 25
 
40 26
 
41
-
42 27
 GLString::GLString()
43 28
 {
44 29
 	_num_string_max = 0;

+ 128
- 229
src/GLString.h Näytä tiedosto

@@ -1,244 +1,143 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file GLString.h
3
+ * \brief Open GL rendering font/string class
3 4
  *
4
- * Project : Mtk
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : GLString
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: Open GL rendering font/string class
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History ------------------------------------------------
17
- *
18
- * 2002.01.01:
19
- * Mongoose - Created
20
- ================================================================*/
21
-
5
+ * \author Mongoose
6
+ * \author xythobuz
7
+ */
22 8
 
23 9
 #ifndef __MTK_MONGOOSE_GLSTRING_H_
24 10
 #define __MTK_MONGOOSE_GLSTRING_H_
25 11
 
26
-typedef struct gl_string_s
27
-{
28
-	int x;
29
-	int y;
30
-	int font;
31
-	float scale;
32
-	char *text;
33
-	bool active;
34
-	unsigned short int len;
35
-
12
+/*!
13
+ * \brief Internal data structure representing GL Strings
14
+ */
15
+typedef struct gl_string_s {
16
+    int x; //!< X Coordinate
17
+    int y; //!< Y Coordinate
18
+    int font; //!< Font ID
19
+    float scale; //!< Scale factor
20
+    char *text; //!< Text buffer
21
+    bool active; //!< active state
22
+    unsigned short int len; //!< length
36 23
 } gl_string_t;
37 24
 
38
-
39
-class GLString
40
-{
41
- public:
42
-
43
-	GLString();
44
-	/*------------------------------------------------------
45
-	 * Pre  :
46
-	 * Post : Constructs an object of GLString
47
-	 *
48
-	 *-- History ------------------------------------------
49
-	 *
50
-	 * 2002.01.01:
51
-	 * Mongoose - Created
52
-	 ------------------------------------------------------*/
53
-
54
-	~GLString();
55
-	/*------------------------------------------------------
56
-	 * Pre  : GLString object is allocated
57
-	 * Post : Deconstructs an object of GLString
58
-	 *
59
-	 *-- History ------------------------------------------
60
-	 *
61
-	 * 2002.01.01:
62
-	 * Mongoose - Created
63
-	 ------------------------------------------------------*/
64
-
65
-   void Init(unsigned int max_strings, unsigned int max_fonts, int *tex_map);
66
-   /*------------------------------------------------------
67
-    * Pre  : Set max number of strings and font faces
68
-	 *
69
-	 *        Pass an int array as a map of font texture ids
70
-	 *        and it's size should be 'max_fonts' since
71
-	 *        you need a texture per font  =)
72
-	 *
73
-    * Post :
74
-    *
75
-    *-- History ------------------------------------------
76
-    *
77
-    * 2002.01.01:
78
-    * Mongoose - Created
79
-    ------------------------------------------------------*/
80
-
81
-	void SetChar(unsigned int string, unsigned int pos, char c);
82
-   /*------------------------------------------------------
83
-    * Pre  : String is valid gl_string id
84
-	 *        Pos is position in that gl_string to set
85
-	 *        to character C
86
-	 *
87
-    * Post : Sets a single byte in a string
88
-    *
89
-    *-- History ------------------------------------------
90
-    *
91
-    * 2002.03.30:
92
-    * Mongoose - Created
93
-    ------------------------------------------------------*/
94
-
95
-	unsigned int GetStringLen(unsigned int string);
96
-   /*------------------------------------------------------
97
-    * Pre  : String is valid gl_string id
98
-	 *
99
-    * Post : Gets num bytes in string buffer
100
-    *
101
-    *-- History ------------------------------------------
102
-    *
103
-    * 2002.03.30:
104
-    * Mongoose - Created
105
-    ------------------------------------------------------*/
106
-
107
-	char *GetBuffer(unsigned int string);
108
-   /*------------------------------------------------------
109
-    * Pre  : String is valid gl_string id
110
-	 *
111
-    * Post : Returns a pointer to string buffer
112
-    *
113
-    *-- History ------------------------------------------
114
-    *
115
-    * 2002.03.30:
116
-    * Mongoose - Created
117
-    ------------------------------------------------------*/
118
-
119
-	void setActive(unsigned int string, bool active);
120
-
121
-	void SetString(unsigned int string, const char *s, ...);
122
-   /*------------------------------------------------------
123
-    * Pre  : String is valid gl_string id
124
-	 *        Args form the string to fill String buffer
125
-	 *        Args are same as printf format
126
-	 *
127
-    * Post : Sets text in a string, which will be
128
-	 *        truncated as needed to fit
129
-    *
130
-    *-- History ------------------------------------------
131
-    *
132
-    * 2002.03.30:
133
-    * Mongoose - Created
134
-    ------------------------------------------------------*/
135
-
136
-   void Scale(float scale);
137
-   /*------------------------------------------------------
138
-    * Pre  : scale is > 0.0
139
-    * Post : Sets default text scaling
140
-    *
141
-    *-- History ------------------------------------------
142
-    *
143
-    * 2002.01.03:
144
-    * Mongoose - Created
145
-    ------------------------------------------------------*/
146
-
147
-   int BuildFontList(int index);
148
-   /*------------------------------------------------------
149
-    * Pre  : Index is valid index into the font base list
150
-    * Post : Adds a new font face to font list
151
-	 *
152
-	 *        Returns index of font on no error
153
-	 *        Returns -1 on full font list
154
-    *
155
-    *-- History ------------------------------------------
156
-    *
157
-    * 2002.01.01:
158
-    * Mongoose - Created
159
-    ------------------------------------------------------*/
160
-
161
-   int glPrintf(int x, int y, int font, const char *string, ...);
162
-   /*------------------------------------------------------
163
-    * Pre  : X, Y are valid screen coor
164
-	 *        Font is valid font index
165
-	 *        String is valid string with args
166
-	 *
167
-	 *        Returns  0 on no error
168
-	 *        Returns -1 on invalid string
169
-	 *        Returns -2 on full string list
170
-	 *        Returns -3 on full font list
171
-	 *
172
-    * Post : Generates a new string
173
-	 *        Renders string to gl target
174
-    *
175
-    *-- History ------------------------------------------
176
-    *
177
-    * 2001.12.31:
178
-    * Mongoose - Created
179
-    ------------------------------------------------------*/
180
-
181
-   void Render(int width, int height);
182
-   /*------------------------------------------------------
183
-    * Pre  : Width and Height for the GL context
184
-	 *        Called after scene is rendered
185
-	 *
186
-	 *        GL Culling disabled
187
-	 *
188
-    * Post : Renders strings over GL scene
189
-    *
190
-    *-- History ------------------------------------------
191
-    *
192
-    * 2002.01.01:
193
-    * Mongoose - Created
194
-    ------------------------------------------------------*/
195
-
196
-   gl_string_t *GetString(unsigned int id);
197
-   /*------------------------------------------------------
198
-    * Pre  : Id is valid string id
199
-    * Post : Return string with id, or NULL if DNE
200
-    *
201
-    *-- History ------------------------------------------
202
-    *
203
-    * 2002.01.04:
204
-    * Mongoose - Created
205
-    ------------------------------------------------------*/
25
+/*!
26
+ * \brief Open GL rendering font/string class
27
+ */
28
+class GLString {
29
+public:
30
+
31
+    /*!
32
+     * \brief Constructs an object of GLString
33
+     */
34
+    GLString();
35
+
36
+    /*!
37
+     * \brief Deconstructs an object of GLString
38
+     */
39
+    ~GLString();
40
+
41
+    /*!
42
+     * \brief Set max number of strings and font faces
43
+     * \param max_strings maximum number of strings
44
+     * \param max_fonts maximum number of fonts and length of tex_map
45
+     * \param tex_map int array as a map of font texture ids
46
+     */
47
+    void Init(unsigned int max_strings, unsigned int max_fonts, int *tex_map);
48
+
49
+    /*!
50
+     * \brief Sets a single byte in a string
51
+     * \param string valid gl string id
52
+     * \param pos position in that gl string to set
53
+     * \param c character to set in gl string
54
+     */
55
+    void SetChar(unsigned int string, unsigned int pos, char c);
56
+
57
+    /*!
58
+     * \brief Gets number of bytes in a string buffer
59
+     * \param string valid gl string id
60
+     * \returns length/number of bytes of string
61
+     */
62
+    unsigned int GetStringLen(unsigned int string);
63
+
64
+    /*!
65
+     * \brief Returns string buffer
66
+     * \param string valid gl string id
67
+     * \returns pointer to string buffer
68
+     */
69
+    char *GetBuffer(unsigned int string);
70
+
71
+
72
+    void setActive(unsigned int string, bool active);
73
+
74
+    /*!
75
+     * \brief Sets text in a string.
76
+     * It will be truncated as needed to fit
77
+     * \param string valid string id
78
+     * \param s format string and args like for printf
79
+     */
80
+    void SetString(unsigned int string, const char *s, ...);
81
+
82
+    /*!
83
+     * \brief Sets default text scaling
84
+     * \param scale new scale factor > 0.0
85
+     */
86
+    void Scale(float scale);
87
+
88
+    /*!
89
+     * \brief Adds a new font face to font list
90
+     * \param index valid index into the font base list
91
+     * \returns index of font on no error, -1 on full font list
92
+     */
93
+    int BuildFontList(int index);
94
+
95
+    /*!
96
+     * \brief Generates a new string and renders it to the gl target
97
+     * \param x valid X screen coordinate
98
+     * \param y valid Y screen coordinate
99
+     * \param font valid font index
100
+     * \param string valid format string with args like for printf
101
+     * \returns 0 on success, -1 on invalid string, -2 on full string list, -3 on full font list
102
+     */
103
+    int glPrintf(int x, int y, int font, const char *string, ...);
104
+
105
+    /*!
106
+     * \brief Renders strings over GL scene.
107
+     * Should be called after scene is rendered.
108
+     * GL Culling should be disabled.
109
+     * \param width width of GL context
110
+     * \param height height of GL context
111
+     */
112
+    void Render(int width, int height);
113
+
114
+    /*!
115
+     * \brief Get the String data structure for a string id
116
+     * \param id valid string id
117
+     * \returns string for id, or NULL if it does not exist
118
+     */
119
+    gl_string_t *GetString(unsigned int id);
206 120
 
207 121
 
208 122
 #ifdef __TEST__
209
-	int _RegressionTest(int argc, char *argv[]);
210
-	/*------------------------------------------------------
211
-	 * Pre  : argc and argv are valid
212
-	 * Post : Tests GLString
213
-	 *
214
-	 *        Returns 0 on sucess, or an error id
215
-	 *
216
-	 *-- History ------------------------------------------
217
-	 *
218
-	 * 2002.01.01:
219
-	 * Mongoose - Created
220
-	 ------------------------------------------------------*/
123
+    /*!
124
+     * \brief Tests GLString
125
+     * \param argc length of argv
126
+     * \param argv array of argument strings
127
+     * \returns 0 on success or an error id
128
+     */
129
+    int _RegressionTest(int argc, char *argv[]);
221 130
 #endif
222 131
 
223
- private:
224
-
225
-	unsigned int _num_string_max;	   /* Max number of strings buffered */
226
-
227
-	unsigned int _num_font_max;	   /* Max number of font faces */
228
-
229
-	unsigned int _num_font;	         /* Current number of font faces */
230
-
231
-	unsigned int _num_string;	      /* Current number of strings buffered */
232
-
233
-	int *_font_texture;	            /* Font texture mapping to actual
234
-												   texture index */
235
-
236
-	int *_font_base;	               /* Font GL list, base index list */
237
-
238
-	gl_string_t *_string;            /* Buffered strings and their
239
-													properities */
240
-
241
-	float _scale;                    /* Default scale factor for new strings */
132
+private:
133
+    unsigned int _num_string_max; //!< Max number of strings buffered
134
+    unsigned int _num_font_max; //!< Max number of font faces
135
+    unsigned int _num_font; //!< Current number of font faces
136
+    unsigned int _num_string; //!< Current number of strings buffered
137
+    int *_font_texture; //!< Font texture mapping to actual texture index
138
+    int *_font_base; //!< Font GL list, base index list
139
+    gl_string_t *_string; //!< Buffered strings and their properities
140
+    float _scale; //!< Default scale factor for new strings
242 141
 };
243 142
 
244 143
 #endif

Loading…
Peruuta
Tallenna