Browse Source

Removed unused code

Thomas Buck 10 years ago
parent
commit
808ce4f1d0
7 changed files with 30 additions and 261 deletions
  1. 4
    0
      ChangeLog
  2. 4
    19
      include/GLString.h
  3. 3
    147
      src/GLString.cpp
  4. 1
    1
      src/OpenRaider.cpp
  5. 12
    17
      src/Render.cpp
  6. 4
    75
      src/SDLSystem.cpp
  7. 2
    2
      src/Texture.cpp

+ 4
- 0
ChangeLog View File

@@ -5,6 +5,10 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140119 ]
9
+	* Removed unused TGA font parts of GLString
10
+	* Removed unused glDrawGrid & glDrawAxis from SDLSystem
11
+
8 12
 	[ 20140118 ]
9 13
 	* Removed unused (and pretty empty) Entity class
10 14
 

+ 4
- 19
include/GLString.h View File

@@ -15,7 +15,6 @@
15 15
 typedef struct gl_string_s {
16 16
     int x; //!< X Coordinate
17 17
     int y; //!< Y Coordinate
18
-    int font; //!< Font ID
19 18
     float scale; //!< Scale factor
20 19
     char *text; //!< Text buffer
21 20
     bool active; //!< active state
@@ -39,12 +38,10 @@ public:
39 38
     ~GLString();
40 39
 
41 40
     /*!
42
-     * \brief Set max number of strings and font faces
41
+     * \brief Set max number of strings
43 42
      * \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 43
      */
47
-    void Init(unsigned int max_strings, unsigned int max_fonts, int *tex_map);
44
+    void Init(unsigned int max_strings);
48 45
 
49 46
     /*!
50 47
      * \brief Sets a single byte in a string
@@ -86,21 +83,13 @@ public:
86 83
     void Scale(float scale);
87 84
 
88 85
     /*!
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 86
      * \brief Generates a new string and renders it to the gl target
97 87
      * \param x valid X screen coordinate
98 88
      * \param y valid Y screen coordinate
99
-     * \param font valid font index
100 89
      * \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
90
+     * \returns 0 on success, -1 on invalid string, -2 on full string list
102 91
      */
103
-    int glPrintf(int x, int y, int font, const char *string, ...);
92
+    int glPrintf(int x, int y, const char *string, ...);
104 93
 
105 94
     /*!
106 95
      * \brief Renders strings over GL scene.
@@ -121,11 +110,7 @@ public:
121 110
 
122 111
 private:
123 112
     unsigned int _num_string_max; //!< Max number of strings buffered
124
-    unsigned int _num_font_max; //!< Max number of font faces
125
-    unsigned int _num_font; //!< Current number of font faces
126 113
     unsigned int _num_string; //!< Current number of strings buffered
127
-    int *_font_texture; //!< Font texture mapping to actual texture index
128
-    int *_font_base; //!< Font GL list, base index list
129 114
     gl_string_t *_string; //!< Buffered strings and their properities
130 115
     float _scale; //!< Default scale factor for new strings
131 116
 };

+ 3
- 147
src/GLString.cpp View File

@@ -26,12 +26,8 @@
26 26
 GLString::GLString()
27 27
 {
28 28
 	_num_string_max = 0;
29
-	_num_font_max = 0;
30
-	_num_font = 0;
31 29
 	_num_string = 0;
32 30
 	_scale = 1.0;
33
-	_font_texture = NULL;
34
-	_font_base = NULL;
35 31
 	_string = NULL;
36 32
 }
37 33
 
@@ -40,22 +36,6 @@ GLString::~GLString()
40 36
 {
41 37
 	unsigned int i;
42 38
 
43
-
44
-	for (i = 0; i < _num_font; ++i)
45
-	{
46
-		glDeleteLists(_font_base[i], 256);
47
-	}
48
-
49
-	if (_font_texture)
50
-	{
51
-		delete [] _font_texture;
52
-	}
53
-
54
-	if (_font_base)
55
-	{
56
-		delete [] _font_base;
57
-	}
58
-
59 39
 	if (_string)
60 40
 	{
61 41
 
@@ -72,33 +52,18 @@ GLString::~GLString()
72 52
 }
73 53
 
74 54
 
75
-void GLString::Init(unsigned int max_strings, unsigned int max_fonts,
76
-						  int *tex_map)
55
+void GLString::Init(unsigned int max_strings)
77 56
 {
78 57
 	unsigned int i;
79 58
 
80 59
 
81
-	if (!max_strings || !max_fonts || !tex_map)
60
+	if (!max_strings)
82 61
 	{
83 62
 		return;
84 63
 	}
85 64
 
86 65
 	_num_string_max = max_strings;
87
-	_num_font_max = max_fonts;
88
-
89
-	_font_texture = new int[max_fonts];
90
-	_font_base = new int[max_fonts];
91 66
 	_string = new gl_string_t[max_strings];
92
-
93
-	for (i = 0; i < max_fonts; ++i)
94
-	{
95
-		_font_texture[i] = tex_map[i];
96
-
97
-		if (BuildFontList(i) < 0)
98
-		{
99
-			printf("GLString::Init> BuildFontList failed for %i\n", i);
100
-		}
101
-	}
102 67
 }
103 68
 
104 69
 
@@ -190,65 +155,7 @@ void GLString::Scale(float scale)
190 155
 }
191 156
 
192 157
 
193
-int GLString::BuildFontList(int index)
194
-{
195
-	int i;
196
-	float cx;
197
-	float cy;
198
-
199
-
200
-	if (_num_font >= _num_font_max || index < 0 || index >= (int)_num_font_max)
201
-	{
202
-		return -1;
203
-	}
204
-
205
-	_font_base[index] = glGenLists(256);
206
-	glBindTexture(GL_TEXTURE_2D, _font_texture[index]);
207
-
208
-	// Mongoose 2002.01.01, Generate 256 lists per font
209
-	//   one per symbol
210
-	for (i = 0; i < 256; i++)
211
-	{
212
-		/* X Position Of Current Character */
213
-		cx = 1 - (float)(i % 16) / 16.0f;
214
-		/* Y Position Of Current Character */
215
-		cy = 1 - (float)(i / 16) / 16.0f;
216
-
217
-		/* Start Building A List */
218
-		glNewList(_font_base[index] + (255 - i), GL_COMPILE);
219
-		/* Use A Quad For Each Character */
220
-		glBegin(GL_QUADS);
221
-		/* Texture Coord (Bottom Left) */
222
-		glTexCoord2f(cx - 0.0625, cy);
223
-		/* Vertex Coord (Bottom Left) */
224
-		glVertex2i(0, 0);
225
-
226
-		/* Texture Coord (Bottom Right) */
227
-		glTexCoord2f(cx, cy);
228
-		/* Vertex Coord (Bottom Right) */
229
-		glVertex2i(16, 0);
230
-
231
-		/* Texture Coord (Top Right) */
232
-		glTexCoord2f(cx, cy - 0.0625f);
233
-		 /* Vertex Coord (Top Right) */
234
-		glVertex2i(16, 16);
235
-
236
-		/* Texture Coord (Top Left) */
237
-		glTexCoord2f(cx - 0.0625f, cy - 0.0625f);
238
-		/* Vertex Coord (Top Left) */
239
-		glVertex2i(0, 16);
240
-		glEnd();
241
-
242
-		/* Move To The Left Of The Character */
243
-		glTranslated(10, 0, 0);
244
-		glEndList();
245
-	}
246
-
247
-	return 0;
248
-}
249
-
250
-
251
-int GLString::glPrintf(int x, int y, int font, const char *string, ...)
158
+int GLString::glPrintf(int x, int y, const char *string, ...)
252 159
 {
253 160
 	int sz = 60;
254 161
 	int n;
@@ -267,11 +174,6 @@ int GLString::glPrintf(int x, int y, int font, const char *string, ...)
267 174
 		return -2;
268 175
 	}
269 176
 
270
-	if (font < 0 || font > (int)_num_font_max)
271
-	{
272
-		return -3;
273
-	}
274
-
275 177
 	// Mongoose 2002.01.01, Assume no longer than 'sz' wide lines
276 178
 	//   on first try
277 179
 	_string[_num_string].text = new char[sz];
@@ -283,9 +185,6 @@ int GLString::glPrintf(int x, int y, int font, const char *string, ...)
283 185
 	_string[_num_string].x = x;
284 186
 	_string[_num_string].y = y;
285 187
 
286
-	//  Mongoose 2002.01.01, Setup font list base index to use
287
-	_string[_num_string].font = font;
288
-
289 188
 	va_start(args, string);
290 189
 
291 190
 	// Mongoose 2002.01.01, Get exact size needed if the first try fails
@@ -336,48 +235,6 @@ void GLString::Render(int width, int height)
336 235
 {
337 236
 	unsigned int i;
338 237
 
339
-#ifndef HAVE_SDL_TTF
340
-	// Mongoose 2001.12.31, Start the evil font rendering...
341
-	glLoadIdentity();
342
-	glDisable(GL_DEPTH_TEST);
343
-
344
-	// Mongoose 2001.12.31, New 'flat' projection
345
-	glMatrixMode(GL_PROJECTION);
346
-	glPushMatrix();
347
-	glLoadIdentity();
348
-	glOrtho(0, width, 0, height, -1, 1);
349
-
350
-	// Mongoose 2001.12.31, New rendering matrix
351
-	glMatrixMode(GL_MODELVIEW);
352
-	glPushMatrix();
353
-	glLoadIdentity();
354
-
355
-	// Mongoose 2001.12.31, Rasterize strings' text
356
-	for (i = 0; i < _num_string; ++i)
357
-	{
358
-		if (_string[i].active)
359
-		{
360
-			glPushMatrix();
361
-			glBindTexture(GL_TEXTURE_2D, _font_texture[_string[i].font]);
362
-			glTranslated(_string[i].x, _string[i].y, 0);
363
-			glScaled(_string[i].scale, _string[i].scale, _string[i].scale);
364
-			glListBase(_font_base[_string[i].font] - 32);
365
-			glCallLists(strlen(_string[i].text), GL_BYTE, _string[i].text);
366
-			glPopMatrix();
367
-		}
368
-	}
369
-
370
-
371
-	// Mongoose 2001.12.31, Restore scene projection
372
-	glMatrixMode(GL_PROJECTION);
373
-	glPopMatrix();
374
-
375
-	// Mongoose 2001.12.31, Restore scene matrix
376
-	glMatrixMode(GL_MODELVIEW);
377
-	glPopMatrix();
378
-
379
-	glEnable(GL_DEPTH_TEST);
380
-#else
381 238
 	for (i = 0; i < _num_string; ++i)
382 239
 	{
383 240
 		if (_string[i].active)
@@ -387,7 +244,6 @@ void GLString::Render(int width, int height)
387 244
 						 _string[i].text);
388 245
 		}
389 246
 	}
390
-#endif
391 247
 }
392 248
 
393 249
 

+ 1
- 1
src/OpenRaider.cpp View File

@@ -1247,7 +1247,7 @@ void OpenRaider::gameFrame()
1247 1247
 		if (time - lastTime > 100.0f)
1248 1248
 		{
1249 1249
 			if (mText)
1250
-				mText->SetString(1, "FPS %d", frames);
1250
+				mText->SetString(1, "%dFPS", frames);
1251 1251
 
1252 1252
 			lastTime = time;
1253 1253
 			frames = 0;

+ 12
- 17
src/Render.cpp View File

@@ -197,7 +197,6 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
197 197
 	int snow2_id;
198 198
 	int bg_id;
199 199
 	int err;
200
-	int id[5];
201 200
 	unsigned int numTextures = 0;
202 201
 	unsigned char color[4];
203 202
 
@@ -267,61 +266,57 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
267 266
 	// Setup particle system test
268 267
 	initEmitter("Snow test", 650, snow1_id, snow2_id);
269 268
 
270
-	// Mongoose 2002.01.01, Temp placement of GLString init
271
-	id[0] = font_id;
272
-	id[4] = id[3] = id[2] = id[1] = -1;
273
-
274
-	mString.Init(5, 5, id);
269
+	mString.Init(5);
275 270
 
276 271
 	// String 0: OpenRaider version in lower right corner
277 272
 	mString.Scale(1.00);
278 273
 	err = mString.glPrintf(mWidth - 15 * strlen(VERSION),
279
-								  mHeight-35, 0, VERSION);
274
+								  mHeight-35, VERSION);
280 275
 	mString.SetString(0, VERSION);
281 276
 
282 277
 	if (err)
283 278
 	{
284
-		printf("\n*** GLPrint test: ERROR %i font_tex %i\n", err, id[0]);
279
+		printf("\n*** GLPrint test: ERROR %i\n", err);
285 280
 	}
286 281
 
287 282
 	// String 1: Used for FPS in game text output
288
-	mString.Scale(1.0);
289
-	err = mString.glPrintf(8, mHeight - 35, 0, "                ");
283
+	mString.Scale(0.75);
284
+	err = mString.glPrintf(8, mHeight - 25, "                ");
290 285
     mString.SetString(1, "                ");
291 286
 
292 287
 	if (err)
293 288
 	{
294
-		printf("\n*** GLPrint test: ERROR %i font_tex %i\n", err, id[0]);
289
+		printf("\n*** GLPrint test: ERROR %i\n", err);
295 290
 	}
296 291
 
297 292
 	// String 2: Used for game console
298 293
     mString.Scale(1.0);
299
-	err = mString.glPrintf(8, 25, 0, console);
294
+	err = mString.glPrintf(8, 25, console);
300 295
     mString.SetString(2, console);
301 296
 
302 297
 	if (err)
303 298
 	{
304
-		printf("\n*** GLPrint test: ERROR %i font_tex %i\n", err, id[0]);
299
+		printf("\n*** GLPrint test: ERROR %i\n", err);
305 300
 	}
306 301
 
307 302
 	// String 3: Used for one line map select menu
308 303
 	mString.Scale(1.75);
309
-	err = mString.glPrintf(mWidth/2-235, mHeight/2-24, 0, menu);
304
+	err = mString.glPrintf(mWidth/2-235, mHeight/2-24, menu);
310 305
     mString.SetString(3, menu);
311 306
 
312 307
 	if (err)
313 308
 	{
314
-		printf("\n*** GLPrint test: ERROR %i font_tex %i\n", err, id[0]);
309
+		printf("\n*** GLPrint test: ERROR %i\n", err);
315 310
 	}
316 311
 
317 312
 	// String 4: Used for one line in game text output
318 313
 	mString.Scale(1.0);
319
-	err = mString.glPrintf(8, 55, 0, "                    ");
314
+	err = mString.glPrintf(8, 55, "                    ");
320 315
     mString.SetString(4, "                    ");
321 316
 
322 317
 	if (err)
323 318
 	{
324
-		printf("\n*** GLPrint test: ERROR %i font_tex %i\n", err, id[0]);
319
+		printf("\n*** GLPrint test: ERROR %i\n", err);
325 320
 	}
326 321
 
327 322
 	printf("\n");

+ 4
- 75
src/SDLSystem.cpp View File

@@ -48,74 +48,6 @@
48 48
 unsigned int *gWidth = 0x0;
49 49
 unsigned int *gHeight = 0x0;
50 50
 
51
-/* 500, 50 */
52
-void glDrawGrid(float size, float step)
53
-{
54
-	float x, y;
55
-
56
-
57
-	// Draw grid
58
-	glPushMatrix();
59
-	glScalef(2.0f, 2.0f, 2.0f);
60
-	glColor3f(0.4f, 0.4f, 0.6f);
61
-
62
-	for (x = -size; x < size; x += step)
63
-	{
64
-		glBegin(GL_LINE_LOOP);
65
-		for (y = -size; y < size; y += step)
66
-		{
67
-			glVertex3f(x + step, 0.0f, y);
68
-			glVertex3f(x, 0.0f, y);
69
-			glVertex3f(x, 0.0f, y + step);
70
-			glVertex3f(x + step, 0.0f, y + step);
71
-		}
72
-		glEnd();
73
-	}
74
-
75
-	glPopMatrix();
76
-}
77
-
78
-void glDrawAxis(float length, float arrowLenght)
79
-{
80
-	/* Draw axis list to show bone orientation */
81
-	glBegin(GL_LINES);
82
-
83
-	/* X axis */
84
-	glColor3f(1.0f, 0.0f, 0.0f);
85
-	glVertex3f(-8.0f, 0.0f, 0.0f);
86
-	glVertex3f(8.0f, 0.0f, 0.0f);
87
-
88
-	/* X direction */
89
-	glVertex3f(8.0f, 0.0f, 0.0f);
90
-	glVertex3f(7.0f, 1.0f, 0.0f);
91
-	glVertex3f(8.0f, 0.0f, 0.0f);
92
-	glVertex3f(7.0f, -1.0f, 0.0f);
93
-
94
-	/* Y axis */
95
-	glColor3f(0.0f, 1.0f, 0.0f);
96
-	glVertex3f(0.0f, -8.0f, 0.0f);
97
-	glVertex3f(0.0f, 8.0f, 0.0f);
98
-
99
-	/* Y direction */
100
-	glVertex3f(0.0f, 8.0f, 0.0f);
101
-	glVertex3f(0.0f, 7.0f, 1.0f);
102
-	glVertex3f(0.0f, 8.0f, 0.0f);
103
-	glVertex3f(0.0f, 7.0f, -1.0f);
104
-
105
-	/* Z axis */
106
-	glColor3f(0.0f, 0.0f, 1.0f);
107
-	glVertex3f(0.0f, 0.0f, -8.0f);
108
-	glVertex3f(0.0f, 0.0f, 8.0f);
109
-
110
-	/* Z direction */
111
-	glVertex3f(0.0f, 0.0f, 8.0f);
112
-	glVertex3f(0.0f, 1.0f, 7.0f);
113
-	glVertex3f(0.0f, 0.0f, 8.0f);
114
-	glVertex3f(0.0f, -1.0f, 7.0f);
115
-
116
-	glEnd();
117
-}
118
-
119 51
 
120 52
 ////////////////////////////////////////////////////////////
121 53
 // Constructors
@@ -210,7 +142,7 @@ void SDLSystem::setGrabMouse(bool on)
210 142
 void SDLSystem::initVideo(unsigned int width, unsigned int height,
211 143
 								  bool fullscreen)
212 144
 {
213
-	int flags; //, x, y;
145
+	int flags = 0; //, x, y;
214 146
 
215 147
 
216 148
 	// Create GL context
@@ -242,15 +174,11 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
242 174
 	}
243 175
 #endif
244 176
 
245
-	flags = 0;
246
-
247 177
 	flags |= SDL_OPENGL;
248 178
 
249 179
     mFullscreen = fullscreen;
250 180
 	if (mFullscreen)
251
-	{
252 181
 		flags |= SDL_FULLSCREEN;
253
-	}
254 182
 
255 183
     SDL_ShowCursor(SDL_DISABLE);
256 184
     setGrabMouse(true); // Always grab mouse!
@@ -280,7 +208,7 @@ void SDLSystem::initVideo(unsigned int width, unsigned int height,
280 208
 
281 209
 void SDLSystem::resize(unsigned int width, unsigned int height)
282 210
 {
283
-    int flags;
211
+    int flags = 0;
284 212
 
285 213
 	GLfloat aspect;
286 214
 
@@ -306,7 +234,8 @@ void SDLSystem::resize(unsigned int width, unsigned int height)
306 234
 	glLoadIdentity();
307 235
 
308 236
 	// Resize window
309
-    flags = SDL_OPENGL;
237
+    flags |= SDL_OPENGL;
238
+
310 239
     if (mFullscreen)
311 240
         flags |= SDL_FULLSCREEN;
312 241
 

+ 2
- 2
src/Texture.cpp View File

@@ -231,7 +231,7 @@ void glPrint3d(float x, float y, float z,
231 231
 	glRotatef(pitch, 0, 0, 1);
232 232
 	glScalef(scale, scale, scale);
233 233
 
234
-	/* FIXME:
234
+	/*! \fixme
235 235
 	 * Add utf-8 dencoding of char* string
236 236
 	 *
237 237
 	 *	Also this string must be preprocessed to have glyph offsets
@@ -278,7 +278,7 @@ int Texture::loadFontTTF(const char *filename,
278 278
 
279 279
 		gFontTest = generateFont(texture);
280 280
 
281
-		/* FIXME: Until UTF8 decoder is working, we map from
281
+		/*! \fixme Until UTF8 decoder is working, we map from
282 282
 			ASCII when rendering */
283 283
 		gFontTest->utf8Offset = 32; // hack to use ASCII strings to test unicode
284 284
 

Loading…
Cancel
Save