Ver código fonte

All Unit Tests without warning

Thomas Buck 11 anos atrás
pai
commit
db95bfd412
9 arquivos alterados com 76 adições e 67 exclusões
  1. 1
    0
      ChangeLog
  2. 1
    1
      include/Sound.h
  3. 58
    58
      include/Texture.h
  4. 1
    1
      src/Sound.cpp
  5. 4
    4
      src/Texture.cpp
  6. 6
    1
      test/GLString.cpp
  7. 2
    1
      test/Sound.cpp
  8. 0
    0
      test/greatest.h
  9. 3
    1
      test/mtk_tga.cpp

+ 1
- 0
ChangeLog Ver arquivo

@@ -6,6 +6,7 @@
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8 8
 	[ 20140110 ]
9
+	* All Unit Tests build without warning
9 10
 	* Converted many FIXME comments to be in the doxygen documentation
10 11
 	* Removed hel & mstl folders, moved into parent directory
11 12
 	* mtk_tga Unit Test uses greatest

+ 1
- 1
include/Sound.h Ver arquivo

@@ -57,7 +57,7 @@ public:
57 57
      * \param flags (un)set options. Use SoundFlags enum
58 58
      * \returns 0 for no error or < 0 error flag
59 59
      */
60
-    int addFile(char *filename, int *source, unsigned int flags);
60
+    int addFile(const char *filename, int *source, unsigned int flags);
61 61
 
62 62
     /*!
63 63
      * \brief Load wav file from buffer

+ 58
- 58
include/Texture.h Ver arquivo

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*==========================================================================
3
- * 
3
+ *
4 4
  * Project : MTK, Freyja, OpenRaider
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440
@@ -10,13 +10,13 @@
10 10
  *
11 11
  *           See file COPYING for license details.
12 12
  *
13
- * 
14
- *-- History ---------------------------------------------------------- 
15 13
  *
16
- * 2003.06.30, 
14
+ *-- History ----------------------------------------------------------
15
+ *
16
+ * 2003.06.30,
17 17
  * Mongoose - API update, SDL_TTF support moved here, misc features
18 18
  *            SDL_TTF support based on Sam Lantinga's public domain
19
- *            SDL_TTF demo functions and algorithms 
19
+ *            SDL_TTF demo functions and algorithms
20 20
  *
21 21
  * 2001.05.29:
22 22
  * Mongoose - Removed legacy code and done clean up
@@ -39,14 +39,14 @@ typedef struct
39 39
 	int x, y, w, h;
40 40
 	int minx; int maxx; int miny; int maxy; int advance;
41 41
 
42
-} ttf_glyph_t; 
42
+} ttf_glyph_t;
43 43
 
44 44
 typedef struct
45 45
 {
46 46
 	unsigned int utf8Offset;
47
-	unsigned int count;   
47
+	unsigned int count;
48 48
 
49
-/* [utf8Offset -> utf8Offset+count], 
49
+/* [utf8Offset -> utf8Offset+count],
50 50
 	 matches indexing into glyphs[0 -> count] for texcoords, etc
51 51
 	----------------------------------------
52 52
 	41     -> 126     ASCII English w/ special chars,
@@ -62,7 +62,7 @@ typedef struct
62 62
 	int fontDescent;
63 63
 	int fontSpacing;
64 64
 
65
-} ttf_texture_t; 
65
+} ttf_texture_t;
66 66
 
67 67
 
68 68
 typedef struct
@@ -102,7 +102,7 @@ class Texture
102 102
 
103 103
    Texture();
104 104
 	/*------------------------------------------------------
105
-	 * Pre  : 
105
+	 * Pre  :
106 106
 	 * Post : Constructs an object of Texture
107 107
 	 *
108 108
 	 *-- History ------------------------------------------
@@ -110,7 +110,7 @@ class Texture
110 110
 	 * 2001.05.29:
111 111
 	 * Mongoose - Big code clean up, documentation
112 112
 	 *
113
-	 * 2000.10.05: 
113
+	 * 2000.10.05:
114 114
 	 * Mongoose - Created
115 115
 	 ------------------------------------------------------*/
116 116
 
@@ -124,7 +124,7 @@ class Texture
124 124
 	 * 2001.05.29:
125 125
 	 * Mongoose - Big code clean up, documentation
126 126
 	 *
127
-	 * 2000.10.05: 
127
+	 * 2000.10.05:
128 128
 	 * Mongoose - Created
129 129
 	 ------------------------------------------------------*/
130 130
 
@@ -134,13 +134,13 @@ class Texture
134 134
 	////////////////////////////////////////////////////////////
135 135
 
136 136
 	static unsigned char *generateColorTexture(unsigned char rgba[4],
137
-															 unsigned int width, 
137
+															 unsigned int width,
138 138
 															 unsigned int height);
139 139
 	/*------------------------------------------------------
140 140
 	 * Pre  : <Rgba> is 32bpp RGBA color
141 141
 	 *        <Width> and <Height> are powers of two, pref
142 142
 	 *        the same number
143
-	 * Post : 
143
+	 * Post :
144 144
 	 *
145 145
 	 *-- History ------------------------------------------
146 146
 	 *
@@ -150,8 +150,8 @@ class Texture
150 150
 
151 151
 	gl_font_t *generateFont(ttf_texture_t *texture);
152 152
 	/*------------------------------------------------------
153
-	 * Pre  : 
154
-	 * Post : 
153
+	 * Pre  :
154
+	 * Post :
155 155
 	 *
156 156
 	 *-- History ------------------------------------------
157 157
 	 *
@@ -159,7 +159,7 @@ class Texture
159 159
 	 * Mongoose - Created
160 160
 	 ------------------------------------------------------*/
161 161
 
162
-	ttf_texture_t *generateFontTexture(char *filename, int pointSize, 
162
+	ttf_texture_t *generateFontTexture(const char *filename, int pointSize,
163 163
 												  unsigned int textureWidth,
164 164
 												  unsigned char color[3],
165 165
 												  unsigned int utf8Offset,
@@ -172,7 +172,7 @@ class Texture
172 172
 	 *        <Color> is RGB 24bit color
173 173
 	 *        <Utf8Offset> is offset into font's encoding chart
174 174
 	 *        <Count> is number of glyphs to read from offset start
175
-	 *        <Verbose> dumps debug info to stdout 
175
+	 *        <Verbose> dumps debug info to stdout
176 176
 	 *
177 177
 	 * Post : Generates a font texture with typeset info from TTF
178 178
 	 *
@@ -188,7 +188,7 @@ class Texture
188 188
 
189 189
    int getTextureCount();
190 190
 	/*------------------------------------------------------
191
-	 * Pre  : 
191
+	 * Pre  :
192 192
 	 * Post : Returns number of textures in use, or -1 for
193 193
 	 *        error ( Not initalized )
194 194
 	 *
@@ -197,16 +197,16 @@ class Texture
197 197
 	 * 2001.05.29:
198 198
 	 * Mongoose - Big code clean up, documentation
199 199
 	 *
200
-	 * 2000.10.05: 
200
+	 * 2000.10.05:
201 201
 	 * Mongoose - Created
202 202
 	 ------------------------------------------------------*/
203 203
 
204 204
 	void glScreenShot(char *base, unsigned int width, unsigned int height);
205 205
 	/*------------------------------------------------------
206
-	 * Pre  : <Base> is base filename, 
206
+	 * Pre  : <Base> is base filename,
207 207
 	 *        <Width> and <Height> are viewport dim
208 208
 	 *
209
-	 * Post : Dumps a screenshot to disk, 
209
+	 * Post : Dumps a screenshot to disk,
210 210
 	 *        avoids overwriting files with same base name
211 211
 	 *
212 212
 	 *-- History ------------------------------------------
@@ -222,7 +222,7 @@ class Texture
222 222
 
223 223
 	void bindMultiTexture(int texture0, int texture1);
224 224
 	/*------------------------------------------------------
225
-	 * Pre  : 
225
+	 * Pre  :
226 226
 	 * Post : Sets up multitexture rendering with passed texture ids
227 227
 	 *
228 228
 	 *-- History ------------------------------------------
@@ -241,13 +241,13 @@ class Texture
241 241
 	 * 2001.05.29:
242 242
 	 * Mongoose - Big code clean up, documentation
243 243
 	 *
244
-	 * 2000.10.05: 
244
+	 * 2000.10.05:
245 245
 	 * Mongoose - Created
246 246
 	 ------------------------------------------------------*/
247 247
 
248 248
 	void clearFlag(TextureFlag flag);
249 249
 	/*------------------------------------------------------
250
-	 * Pre  : 
250
+	 * Pre  :
251 251
 	 * Post : CLears a option flag
252 252
 	 *
253 253
 	 *-- History ------------------------------------------
@@ -258,8 +258,8 @@ class Texture
258 258
 
259 259
 	void disableMultiTexture();
260 260
 	/*------------------------------------------------------
261
-	 * Pre  : 
262
-	 * Post : 
261
+	 * Pre  :
262
+	 * Post :
263 263
 	 *
264 264
 	 *-- History ------------------------------------------
265 265
 	 *
@@ -269,7 +269,7 @@ class Texture
269 269
 
270 270
 	void initSDL_TTF();
271 271
 	/*------------------------------------------------------
272
-	 * Pre  : 
272
+	 * Pre  :
273 273
 	 * Post : Loads SDL_TTF if avalible
274 274
 	 *
275 275
 	 *-- History ------------------------------------------
@@ -278,8 +278,8 @@ class Texture
278 278
 	 * Mongoose - Created
279 279
 	 ------------------------------------------------------*/
280 280
 
281
-   int loadBuffer(unsigned char *image, 
282
-						unsigned int width, unsigned int height, 
281
+   int loadBuffer(unsigned char *image,
282
+						unsigned int width, unsigned int height,
283 283
 						ColorMode mode, unsigned int bpp);
284 284
 	/*------------------------------------------------------
285 285
 	 * Pre  : image must be a valid pixmap that agrees
@@ -292,12 +292,12 @@ class Texture
292 292
 	 * 2001.05.29:
293 293
 	 * Mongoose - Big code clean up, documentation
294 294
 	 *
295
-	 * 2000.10.05: 
295
+	 * 2000.10.05:
296 296
 	 * Mongoose - Created
297 297
 	 ------------------------------------------------------*/
298 298
 
299
-   int loadBufferSlot(unsigned char *image, 
300
-							 unsigned int width, unsigned int height, 
299
+   int loadBufferSlot(unsigned char *image,
300
+							 unsigned int width, unsigned int height,
301 301
 							 ColorMode mode, unsigned int bpp,
302 302
 							 unsigned int slot);
303 303
 	/*------------------------------------------------------
@@ -308,14 +308,14 @@ class Texture
308 308
 	 *
309 309
 	 *-- History ------------------------------------------
310 310
 	 *
311
-	 * 2002.09.05: 
311
+	 * 2002.09.05:
312 312
 	 * Mongoose - Created
313 313
 	 ------------------------------------------------------*/
314 314
 
315 315
 	int loadColorTexture(unsigned char rgba[4],
316 316
 								unsigned int width, unsigned int height);
317 317
 	/*------------------------------------------------------
318
-	 * Pre  : 
318
+	 * Pre  :
319 319
 	 * Post : Generates and loads a solid color texture,
320 320
 	 *        returns texture Id or -1 if failed
321 321
 	 *
@@ -325,14 +325,14 @@ class Texture
325 325
 	 * Mongoose - Created
326 326
 	 ------------------------------------------------------*/
327 327
 
328
-	int loadFontTTF(char *filename, 
328
+	int loadFontTTF(const char *filename,
329 329
 						 unsigned int utf8Offset, unsigned int count);
330 330
 	/*------------------------------------------------------
331 331
 	 * Pre  : <Filename> of TTF font
332 332
 	 *        <Utf8Offset> is offset into UNICODE table
333 333
 	 *        <Count> is number of glyphs to load
334 334
 	 *
335
-	 * Post : Loads a TTF, 
335
+	 * Post : Loads a TTF,
336 336
 	 *        Generates: texture image, glyph list, and drawlist
337 337
 	 *
338 338
 	 *        Returns font id if sucessful, or < 0 if error
@@ -343,7 +343,7 @@ class Texture
343 343
 	 * Mongoose - Created
344 344
 	 ------------------------------------------------------*/
345 345
 
346
-	int loadPNG(char *filename);
346
+	int loadPNG(const char *filename);
347 347
 	/*------------------------------------------------------
348 348
 	 * Pre  : Texture is init and filename/file is valid
349 349
 	 * Post : Loads PNG as texture and returns ID or -1 error
@@ -354,7 +354,7 @@ class Texture
354 354
 	 * Mongoose - Created, from Freyja
355 355
 	 ------------------------------------------------------*/
356 356
 
357
-	int loadTGA(char *filename);
357
+	int loadTGA(const char *filename);
358 358
 	/*------------------------------------------------------
359 359
 	 * Pre  : Texture is init and filename/file is valid
360 360
 	 * Post : Loads TGA as texture and returns ID or -1 error
@@ -367,7 +367,7 @@ class Texture
367 367
 
368 368
    void reset();
369 369
 	/*------------------------------------------------------
370
-	 * Pre  : 
370
+	 * Pre  :
371 371
 	 * Post : Resets all texture data
372 372
 	 *
373 373
 	 *-- History ------------------------------------------
@@ -375,13 +375,13 @@ class Texture
375 375
 	 * 2001.05.29:
376 376
 	 * Mongoose - Big code clean up, documentation
377 377
 	 *
378
-	 * 2000.10.05: 
378
+	 * 2000.10.05:
379 379
 	 * Mongoose - Created
380 380
 	 ------------------------------------------------------*/
381 381
 
382 382
 	void setFlag(TextureFlag flag);
383 383
 	/*------------------------------------------------------
384
-	 * Pre  : 
384
+	 * Pre  :
385 385
 	 * Post : Sets a option flag
386 386
 	 *
387 387
 	 *-- History ------------------------------------------
@@ -393,7 +393,7 @@ class Texture
393 393
 	void setMaxTextureCount(unsigned int n);
394 394
 	/*------------------------------------------------------
395 395
 	 * Pre  : n is max number of textures you wish to allow
396
-	 * Post : Sets up GL texturing, and must be called 
396
+	 * Post : Sets up GL texturing, and must be called
397 397
 	 *        as the first setup step
398 398
 	 *
399 399
 	 *-- History ------------------------------------------
@@ -401,14 +401,14 @@ class Texture
401 401
 	 * 2001.05.29:
402 402
 	 * Mongoose - Big code clean up, documentation
403 403
 	 *
404
-	 * 2000.10.05: 
404
+	 * 2000.10.05:
405 405
 	 * Mongoose - Created
406 406
 	 ------------------------------------------------------*/
407 407
 
408 408
 	void useMultiTexture(float u, float v);
409 409
 	/*------------------------------------------------------
410
-	 * Pre  : 
411
-	 * Post : 
410
+	 * Pre  :
411
+	 * Post :
412 412
 	 *
413 413
 	 *-- History ------------------------------------------
414 414
 	 *
@@ -418,8 +418,8 @@ class Texture
418 418
 
419 419
 	void useMultiTexture(float aU, float aV, float bU, float bV);
420 420
 	/*------------------------------------------------------
421
-	 * Pre  : 
422
-	 * Post : 
421
+	 * Pre  :
422
+	 * Post :
423 423
 	 *
424 424
 	 *-- History ------------------------------------------
425 425
 	 *
@@ -436,8 +436,8 @@ class Texture
436 436
 
437 437
 	int nextPower(int seed);
438 438
 	/*------------------------------------------------------
439
-	 * Pre  : 
440
-	 * Post : 
439
+	 * Pre  :
440
+	 * Post :
441 441
 	 *
442 442
 	 *-- History ------------------------------------------
443 443
 	 *
@@ -445,11 +445,11 @@ class Texture
445 445
 	 * Mongoose - Created
446 446
 	 ------------------------------------------------------*/
447 447
 
448
-	unsigned char *scaleBuffer(unsigned char *image, int width, int height,	
448
+	unsigned char *scaleBuffer(unsigned char *image, int width, int height,
449 449
 										int components);
450 450
 	/*------------------------------------------------------
451
-	 * Pre  : 
452
-	 * Post : 
451
+	 * Pre  :
452
+	 * Post :
453 453
 	 *
454 454
 	 *-- History ------------------------------------------
455 455
 	 *
@@ -465,7 +465,7 @@ class Texture
465 465
    unsigned int *mTextureIds;		/* GL texture list */
466 466
 
467 467
    unsigned int mTextureCount;	/* Texture counter */
468
-	
468
+
469 469
    unsigned int mTextureLimit;	/* The texture limit */
470 470
 
471 471
 	unsigned int mFlags;				/* Class options */
@@ -479,8 +479,8 @@ class Texture
479 479
 /* Experimental testing */
480 480
 void bufferedPrintf(char *string, unsigned int len, char *s, ...);
481 481
 
482
-void glPrint3d(float x, float y, float z, 
483
-					float pitch, float yaw, float roll, 
482
+void glPrint3d(float x, float y, float z,
483
+					float pitch, float yaw, float roll,
484 484
 					float scale,
485 485
 					char *string);
486 486
 
@@ -488,7 +488,7 @@ void glPrint2d(float x, float y, float scale, char *string);
488 488
 
489 489
 	void glEnterMode2d(unsigned int width, unsigned int height);
490 490
 	/*------------------------------------------------------
491
-	 * Pre  : 
491
+	 * Pre  :
492 492
 	 * Post : OpenGL ortho projection
493 493
 	 *
494 494
 	 *-- History ------------------------------------------
@@ -499,7 +499,7 @@ void glPrint2d(float x, float y, float scale, char *string);
499 499
 
500 500
 	void glExitMode2d();
501 501
 	/*------------------------------------------------------
502
-	 * Pre  : 
502
+	 * Pre  :
503 503
 	 * Post : OpenGL model matrix projection
504 504
 	 *
505 505
 	 *-- History ------------------------------------------

+ 1
- 1
src/Sound.cpp Ver arquivo

@@ -111,7 +111,7 @@ void Sound::sourceAt(int source, float pos[3])
111 111
 
112 112
 
113 113
 //! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
114
-int Sound::addFile(char *filename, int *source, unsigned int flags)
114
+int Sound::addFile(const char *filename, int *source, unsigned int flags)
115 115
 {
116 116
 #ifdef USING_OPENAL
117 117
    ALsizei size;

+ 4
- 4
src/Texture.cpp Ver arquivo

@@ -242,7 +242,7 @@ void glPrint3d(float x, float y, float z,
242 242
 }
243 243
 
244 244
 
245
-int Texture::loadFontTTF(char *filename,
245
+int Texture::loadFontTTF(const char *filename,
246 246
 								 unsigned int utf8Offset, unsigned int count)
247 247
 {
248 248
 	ttf_texture_t *texture;
@@ -380,7 +380,7 @@ gl_font_t *Texture::generateFont(ttf_texture_t *texture)
380 380
 }
381 381
 
382 382
 
383
-ttf_texture_t *Texture::generateFontTexture(char *filename, int pointSize,
383
+ttf_texture_t *Texture::generateFontTexture(const char *filename, int pointSize,
384 384
 														  unsigned int textureWidth,
385 385
 														  unsigned char color[3],
386 386
 														  unsigned int utf8Offset,
@@ -998,7 +998,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
998 998
 }
999 999
 
1000 1000
 
1001
-int Texture::loadPNG(char *filename)
1001
+int Texture::loadPNG(const char *filename)
1002 1002
 {
1003 1003
 #ifdef USING_MTK_PNG
1004 1004
 	FILE *f;
@@ -1057,7 +1057,7 @@ int Texture::loadPNG(char *filename)
1057 1057
 }
1058 1058
 
1059 1059
 
1060
-int Texture::loadTGA(char *filename)
1060
+int Texture::loadTGA(const char *filename)
1061 1061
 {
1062 1062
 #ifdef USING_MTK_TGA
1063 1063
 	FILE *f;

+ 6
- 1
test/GLString.cpp Ver arquivo

@@ -37,7 +37,12 @@ void event_resize(int width, int height)
37 37
 	aspect = (GLfloat)width/(GLfloat)height;
38 38
 
39 39
 	// Mongoose 2002.01.01, Setup view volume, with a nice FOV
40
-	gluPerspective(40.0, aspect, 1, 2000);
40
+    // gluPerspective is deprecated!
41
+	// gluPerspective(40.0, aspect, 1, 2000);
42
+    // fix: http://stackoverflow.com/a/2417756
43
+    GLfloat fH = tan(float(40.0 / 360.0f * 3.14159f));
44
+    GLfloat fW = fH * aspect;
45
+    glFrustum(-fW, fW, -fH, fH, 1, 2000);
41 46
 
42 47
 	glMatrixMode(GL_MODELVIEW);
43 48
 }

+ 2
- 1
test/Sound.cpp Ver arquivo

@@ -8,9 +8,10 @@
8 8
 #include <stdio.h>
9 9
 #include <unistd.h>
10 10
 
11
-#include <greatest.h>
12 11
 #include <Sound.h>
13 12
 
13
+#include "greatest.h"
14
+
14 15
 #define TESTFILE "data/sample.wav"
15 16
 
16 17
 Sound sound;

include/greatest.h → test/greatest.h Ver arquivo


+ 3
- 1
test/mtk_tga.cpp Ver arquivo

@@ -6,9 +6,11 @@
6 6
  */
7 7
 #include <stdio.h>
8 8
 #include <stdlib.h>
9
-#include <greatest.h>
9
+
10 10
 #include <mtk_tga.h>
11 11
 
12
+#include "greatest.h"
13
+
12 14
 #define TESTFILE "data/font-0.tga"
13 15
 FILE *f = NULL;
14 16
 

Carregando…
Cancelar
Salvar