Browse Source

unsigned char instead of float for colors

Thomas Buck 10 years ago
parent
commit
436f04fd10

+ 3
- 0
ChangeLog.md View File

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140623 ]
6
+    * Use unsigned char instead of float for colors
7
+
5 8
     [ 20140622 ]
6 9
     * Wrote simple image reader/writer utilizing libpng
7 10
     * Created utils/pixels for pixel handling utilities

+ 1
- 0
TODO.md View File

@@ -10,6 +10,7 @@
10 10
     * Rewrite Console and use operator << to write to the console?
11 11
 * SDL_TTF 2.0.12+ [can do line breaks](http://stackoverflow.com/questions/17847818/how-to-do-line-breaks-and-line-wrapping-with-sdl-ttf/18418688#18418688), use it
12 12
 * Mesh has 2 different approaches of storing the same data (eg. mColors and mColorArray), but half of ‘em isn’t implemented. Unify this, probably even combining Mesh and StaticMesh...
13
+* Don’t use float everywhere just because (eg. float colors)
13 14
 
14 15
 ## Changes
15 16
 

+ 1
- 0
include/Camera.h View File

@@ -5,6 +5,7 @@
5 5
  * \author Mongoose
6 6
  * \author xythobuz
7 7
  */
8
+
8 9
 #ifndef _CAMERA_H_
9 10
 #define _CAMERA_H_
10 11
 

+ 2
- 2
include/Font.h View File

@@ -15,7 +15,7 @@ typedef struct {
15 15
     int w;
16 16
     int h;
17 17
     float scale;
18
-    float color[4];
18
+    unsigned char color[4];
19 19
 } FontString;
20 20
 
21 21
 /*!
@@ -35,7 +35,7 @@ public:
35 35
 
36 36
     virtual void writeString(FontString &s) = 0;
37 37
 
38
-    virtual void drawText(unsigned int x, unsigned int y, float scale, const float color[4], const char *s, ...)
38
+    virtual void drawText(unsigned int x, unsigned int y, float scale, const unsigned char color[4], const char *s, ...)
39 39
         __attribute__((format(printf, 6, 0)));
40 40
 
41 41
 protected:

+ 1
- 1
include/RoomData.h View File

@@ -19,7 +19,7 @@ public:
19 19
     BoundingBox();
20 20
     void getBoundingBox(vec3_t box[2]);
21 21
     void setBoundingBox(vec3_t min, vec3_t max);
22
-    void display(bool points, const vec4_t c1, const vec4_t c2);
22
+    void display(bool points, const unsigned char c1[4], const unsigned char c2[4]);
23 23
     bool inBox(vec_t x, vec_t y, vec_t z);
24 24
     bool inBoxPlane(vec_t x, vec_t z);
25 25
 

+ 0
- 2
include/TextureManager.h View File

@@ -152,8 +152,6 @@ private:
152 152
     unsigned int mTextureCount; //!< Texture counter
153 153
     unsigned int mTextureLimit; //!< The texture limit
154 154
     unsigned int mFlags;        //!< Class options
155
-    int mTextureId;             //!< Currently bound texture id
156
-    int mTextureId2;            //!< Multitexture Texture Id
157 155
 };
158 156
 
159 157
 #endif

+ 11
- 11
include/global.h View File

@@ -48,17 +48,17 @@
48 48
 #include <cassert>
49 49
 #endif
50 50
 
51
-// Colors used for Rendering
52
-const float BLACK[]       = {  0.0f,  0.0f,  0.0f, 1.0f };
53
-const float DIM_WHITE[]   = {  0.5f,  0.5f,  0.5f, 1.0f };
54
-const float WHITE[]       = {  1.0f,  1.0f,  1.0f, 1.0f };
55
-const float RED[]         = {  1.0f,  0.0f,  0.0f, 1.0f };
56
-const float GREEN[]       = {  0.0f,  1.0f,  0.0f, 1.0f };
57
-const float NEXT_PURPLE[] = {  0.3f,  0.3f,  0.5f, 1.0f };
58
-const float OR_BLUE[]     = {  0.5f,  0.7f,  1.0f, 1.0f };
59
-const float PINK[]        = {  1.0f,  0.0f,  1.0f, 1.0f };
60
-const float YELLOW[]      = {  1.0f,  1.0f,  0.0f, 1.0f };
61
-const float CYAN[]        = {  0.0f,  1.0f,  1.0f, 1.0f };
51
+// Colors used where ever needed
52
+const unsigned char BLACK[]  = {   0,   0,   0, 255 };
53
+const unsigned char GREY[]   = { 128, 128, 128, 255 };
54
+const unsigned char WHITE[]  = { 255, 255, 255, 255 };
55
+const unsigned char RED[]    = { 255,   0,   0, 255 };
56
+const unsigned char GREEN[]  = {   0, 255,   0, 255 };
57
+const unsigned char PURPLE[] = {  77,  77, 128, 255 };
58
+const unsigned char BLUE[]   = { 128, 179, 255, 255 };
59
+const unsigned char PINK[]   = { 255,   0, 255, 255 };
60
+const unsigned char YELLOW[] = { 255, 255,   0, 255 };
61
+const unsigned char CYAN[]   = {   0, 255, 255, 255 };
62 62
 
63 63
 // Actions that can be bound to a key and sent to the game engine
64 64
 typedef enum {

+ 4
- 4
src/Console.cpp View File

@@ -101,7 +101,7 @@ void Console::display() {
101 101
             scrollIndicator = 100;
102 102
         }
103 103
 
104
-        getFont().drawText(10, 10, 0.70f, OR_BLUE,
104
+        getFont().drawText(10, 10, 0.70f, BLUE,
105 105
                 "%s uptime %lus scroll %d%%", VERSION, systemTimerGet() / 1000, scrollIndicator);
106 106
 
107 107
         // Draw output log
@@ -116,14 +116,14 @@ void Console::display() {
116 116
         }
117 117
         for (int i = 0; i < end; i++) {
118 118
             getFont().drawText(10, ((i + drawOffset) * lineSteps) + firstLine,
119
-                    0.75f, OR_BLUE, "%s", mHistory[i + historyOffset - mLineOffset]);
119
+                    0.75f, BLUE, "%s", mHistory[i + historyOffset - mLineOffset]);
120 120
         }
121 121
 
122 122
         // Draw current input
123 123
         if ((mInputBufferPointer > 0) && (mInputBuffer[0] != '\0')) {
124
-            getFont().drawText(10, inputLine, 0.75f, OR_BLUE, "> %s", mInputBuffer);
124
+            getFont().drawText(10, inputLine, 0.75f, BLUE, "> %s", mInputBuffer);
125 125
         } else {
126
-            getFont().drawText(10, inputLine, 0.75f, OR_BLUE, ">");
126
+            getFont().drawText(10, inputLine, 0.75f, BLUE, ">");
127 127
         }
128 128
 
129 129
         //! \todo display the current mPartialInput. The UTF-8 segfaults SDL-TTF, somehow?

+ 1
- 1
src/Font.cpp View File

@@ -22,7 +22,7 @@ void Font::setFont(const char *font) {
22 22
     mFontName = fullPath(font, 0);
23 23
 }
24 24
 
25
-void Font::drawText(unsigned int x, unsigned int y, float scale, const float color[4], const char *s, ...) {
25
+void Font::drawText(unsigned int x, unsigned int y, float scale, const unsigned char color[4], const char *s, ...) {
26 26
     FontString tempText;
27 27
     va_list args;
28 28
     va_start(args, s);

+ 5
- 5
src/FontSDL.cpp View File

@@ -50,10 +50,10 @@ void FontSDL::writeString(FontString &s) {
50 50
     assert(s.text != NULL);
51 51
 
52 52
     SDL_Color color;
53
-    color.r = (unsigned char)(s.color[0] * 255.0f);
54
-    color.g = (unsigned char)(s.color[1] * 255.0f);
55
-    color.b = (unsigned char)(s.color[2] * 255.0f);
56
-    color.a = (unsigned char)(s.color[3] * 255.0f);
53
+    color.r = s.color[0];
54
+    color.g = s.color[1];
55
+    color.b = s.color[2];
56
+    color.a = s.color[3];
57 57
 
58 58
     SDL_Surface *surface = TTF_RenderUTF8_Blended(mFont, s.text, color);
59 59
     if (surface == NULL) {
@@ -87,7 +87,7 @@ void FontSDL::writeString(FontString &s) {
87 87
     GLuint xMax = xMin + s.w;
88 88
     GLuint yMax = yMin + s.h;
89 89
 
90
-    glColor4f(color.r / 256.0f, color.g / 256.0f, color.b / 256.0f, color.a / 256.0f);
90
+    glColor4ubv(s.color);
91 91
 
92 92
     glBegin(GL_QUADS);
93 93
     glTexCoord2f(0.0f, 0.0f);

+ 1
- 1
src/FontTRLE.cpp View File

@@ -123,7 +123,7 @@ void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, FontString &s)
123 123
 
124 124
     // draw
125 125
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
126
-    glColor4f(s.color[0], s.color[1], s.color[2], s.color[3]);
126
+    glColor4f(s.color[0] * 256.0f, s.color[1] * 256.0f, s.color[2] * 256.0f, s.color[3] * 256.0f);
127 127
     glBegin(GL_QUADS);
128 128
     glTexCoord2f(txMin, tyMin);
129 129
     glVertex2i(xMin, yMin);

+ 6
- 6
src/Menu.cpp View File

@@ -30,10 +30,10 @@ Menu::Menu() {
30 30
     mMin = 0;
31 31
 
32 32
     mainText.text = bufferString(VERSION);
33
-    mainText.color[0] = OR_BLUE[0];
34
-    mainText.color[1] = OR_BLUE[1];
35
-    mainText.color[2] = OR_BLUE[2];
36
-    mainText.color[3] = OR_BLUE[3];
33
+    mainText.color[0] = BLUE[0];
34
+    mainText.color[1] = BLUE[1];
35
+    mainText.color[2] = BLUE[2];
36
+    mainText.color[3] = BLUE[3];
37 37
     mainText.scale = 1.2f;
38 38
     mainText.y = 10;
39 39
     mainText.w = 0;
@@ -194,7 +194,7 @@ void Menu::displayMapList() {
194 194
         if ((i + min) == (int)mCursor)
195 195
             getFont().drawText(25, 100 + (25 * i), 0.75f, RED, "%s", map);
196 196
         else
197
-            getFont().drawText(25, 100 + (25 * i), 0.75f, OR_BLUE, "%s", map);
197
+            getFont().drawText(25, 100 + (25 * i), 0.75f, BLUE, "%s", map);
198 198
     }
199 199
 }
200 200
 
@@ -212,7 +212,7 @@ void Menu::display() {
212 212
         getFont().writeString(mainText);
213 213
 
214 214
         if (!mMapListFilled) {
215
-            getFont().drawText(25, (getWindow().getHeight() / 2) - 20, 0.75f, OR_BLUE, "Generating map list...");
215
+            getFont().drawText(25, (getWindow().getHeight() / 2) - 20, 0.75f, BLUE, "Generating map list...");
216 216
         } else {
217 217
             if (mMapList.size() == 0) {
218 218
                 getFont().drawText(25, (getWindow().getHeight() / 2) - 20, 0.75f, RED, "No maps found! See README.md");

+ 2
- 2
src/OpenRaider.cpp View File

@@ -120,13 +120,13 @@ void OpenRaider::frame() {
120 120
 
121 121
     // Draw FPS counter
122 122
     if (mFPS)
123
-        getFont().drawText(10, getWindow().getHeight() - 20, 0.5f, OR_BLUE, "%dFPS", fps);
123
+        getFont().drawText(10, getWindow().getHeight() - 20, 0.5f, BLUE, "%dFPS", fps);
124 124
 
125 125
 #ifdef DEBUG
126 126
     // Draw debug infos
127 127
     if (getGame().isLoaded() && (!getMenu().isVisible())) {
128 128
         for (int i = 0; i < 3; i++) {
129
-            getFont().drawText(10, getWindow().getHeight() - ((4 - i) * 20), 0.5f, OR_BLUE, "%.2f (%.2f)",
129
+            getFont().drawText(10, getWindow().getHeight() - ((4 - i) * 20), 0.5f, BLUE, "%.2f (%.2f)",
130 130
                 getGame().getLara().getPos(i) / 256.0f, getGame().getLara().getAngle(i));
131 131
         }
132 132
     }

+ 28
- 11
src/Render.cpp View File

@@ -81,7 +81,7 @@ void Render::loadTexture(unsigned char *image,
81 81
         unsigned int width, unsigned int height,
82 82
         unsigned int id)
83 83
 {
84
-    glColor3fv(WHITE);
84
+    glColor3ubv(WHITE);
85 85
     mTexture.loadBufferSlot(image, width, height, TextureManager::RGBA, 32, id);
86 86
 }
87 87
 
@@ -169,11 +169,22 @@ void setLighting(bool on)
169 169
 {
170 170
     if (on)
171 171
     {
172
+        float color[4];
173
+        color[0] = WHITE[0] * 256.0f;
174
+        color[1] = WHITE[1] * 256.0f;
175
+        color[2] = WHITE[2] * 256.0f;
176
+        color[3] = WHITE[3] * 256.0f;
177
+
172 178
         glEnable(GL_LIGHTING);
173 179
         glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
174
-        glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, WHITE);
175
-        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, WHITE);
176
-        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, DIM_WHITE);
180
+        glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
181
+        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
182
+
183
+        color[0] = GREY[0] * 256.0f;
184
+        color[1] = GREY[1] * 256.0f;
185
+        color[2] = GREY[2] * 256.0f;
186
+        color[3] = GREY[3] * 256.0f;
187
+        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color);
177 188
     }
178 189
     else
179 190
     {
@@ -249,7 +260,13 @@ void Render::setFlags(unsigned int flags)
249 260
         glFogf(GL_FOG_DENSITY, 0.00008f);
250 261
         glFogf(GL_FOG_START, 30000.0f);
251 262
         glFogf(GL_FOG_END, 50000.0f);
252
-        glFogfv(GL_FOG_COLOR, BLACK);
263
+
264
+        float color[4];
265
+        color[0] = BLACK[0] * 256.0f;
266
+        color[1] = BLACK[1] * 256.0f;
267
+        color[2] = BLACK[2] * 256.0f;
268
+        color[3] = BLACK[3] * 256.0f;
269
+        glFogfv(GL_FOG_COLOR, color);
253 270
     }
254 271
 
255 272
     if (flags & Render::fGL_Lights)
@@ -275,8 +292,8 @@ void Render::setMode(int n)
275 292
             break;
276 293
         case Render::modeSolid:
277 294
         case Render::modeWireframe:
278
-            glClearColor(NEXT_PURPLE[0], NEXT_PURPLE[1],
279
-                    NEXT_PURPLE[2], NEXT_PURPLE[3]);
295
+            glClearColor(PURPLE[0] * 256.0f, PURPLE[1] * 256.0f,
296
+                    PURPLE[2] * 256.0f, PURPLE[3] * 256.0f);
280 297
             glDisable(GL_TEXTURE_2D);
281 298
             break;
282 299
         default:
@@ -412,7 +429,7 @@ void Render::display()
412 429
     updateViewVolume();
413 430
 
414 431
     // Render world
415
-    glColor3fv(DIM_WHITE); // was WHITE
432
+    glColor3ubv(GREY); // was WHITE
416 433
     drawSkyMesh(96.0);
417 434
 
418 435
     // Figure out how much of the map to render
@@ -507,7 +524,7 @@ void Render::drawLoadScreen()
507 524
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
508 525
     glLoadIdentity();
509 526
 
510
-    glColor3fv(WHITE);
527
+    glColor3ubv(WHITE);
511 528
 
512 529
     if (mFlags & Render::fGL_Lights)
513 530
         glDisable(GL_LIGHTING);
@@ -691,7 +708,7 @@ bool Render::isVisible(float x, float y, float z)
691 708
     if (mMode == Render::modeWireframe)
692 709
     {
693 710
         glPointSize(5.0);
694
-        glColor3fv(PINK);
711
+        glColor3ubv(PINK);
695 712
         glBegin(GL_POINTS);
696 713
         glVertex3f(x, y, z);
697 714
         glEnd();
@@ -707,7 +724,7 @@ bool Render::isVisible(float x, float y, float z, float radius)
707 724
     if (mMode == Render::modeWireframe)
708 725
     {
709 726
         glPointSize(5.0);
710
-        glColor3fv(PINK);
727
+        glColor3ubv(PINK);
711 728
         glBegin(GL_POINTS);
712 729
         glVertex3f(x, y, z);
713 730
         glEnd();

+ 2
- 2
src/Room.cpp View File

@@ -461,7 +461,7 @@ void Room::display(bool alpha) {
461 461
 
462 462
     if ((!alpha) && getRender().getMode() == Render::modeWireframe) {
463 463
         glLineWidth(2.0);
464
-        glColor3fv(RED);
464
+        glColor3ubv(RED);
465 465
 
466 466
         for (unsigned int i = 0; i < sizePortals(); i++) {
467 467
             Portal &portal = getPortal(i);
@@ -486,7 +486,7 @@ void Room::display(bool alpha) {
486 486
     glTranslated(pos[0], pos[1], pos[2]);
487 487
 
488 488
     // Reset since GL_MODULATE used, reset to WHITE
489
-    glColor3fv(WHITE);
489
+    glColor3ubv(WHITE);
490 490
 
491 491
     switch (getRender().getMode())
492 492
     {

+ 3
- 3
src/RoomData.cpp View File

@@ -43,14 +43,14 @@ bool BoundingBox::inBoxPlane(vec_t x, vec_t z) {
43 43
             && (z > a[2]) && (z < b[2]));
44 44
 }
45 45
 
46
-void BoundingBox::display(bool points, const vec4_t c1, const vec4_t c2) {
46
+void BoundingBox::display(bool points, const unsigned char c1[4], const unsigned char c2[4]) {
47 47
     // Bind before entering now
48 48
     //glBindTexture(GL_TEXTURE_2D, 1);
49 49
     glPointSize(4.0);
50 50
     //glLineWidth(1.25);
51 51
 
52 52
     //! \fixme Need to make custom color key for this
53
-    glColor3fv(c1);
53
+    glColor3ubv(c1);
54 54
 
55 55
     glBegin(GL_POINTS);
56 56
     glVertex3f(b[0], b[1], b[2]);
@@ -68,7 +68,7 @@ void BoundingBox::display(bool points, const vec4_t c1, const vec4_t c2) {
68 68
 
69 69
     glEnd();
70 70
 
71
-    glColor3fv(c2);
71
+    glColor3ubv(c2);
72 72
 
73 73
     glBegin(GL_LINES);
74 74
     // max, top quad

+ 2
- 2
src/Sprite.cpp View File

@@ -129,14 +129,14 @@ void Sprite::display() {
129 129
             glEnd();
130 130
             break;
131 131
         case Render::modeWireframe:
132
-            glColor3fv(CYAN);
132
+            glColor3ubv(CYAN);
133 133
             glBegin(GL_LINE_LOOP);
134 134
             glVertex3fv(vertex[0]);
135 135
             glVertex3fv(vertex[1]);
136 136
             glVertex3fv(vertex[2]);
137 137
             glVertex3fv(vertex[3]);
138 138
             glEnd();
139
-            glColor3fv(WHITE);
139
+            glColor3ubv(WHITE);
140 140
             break;
141 141
         default:
142 142
             glBindTexture(GL_TEXTURE_2D, texture+1);

+ 2
- 2
src/StaticMesh.cpp View File

@@ -247,10 +247,10 @@ void StaticMesh::display() {
247 247
         //   return;
248 248
 
249 249
         //! \fixme 'AMBIENT' -- Mongoose 2002.01.08
250
-        glColor3fv(WHITE);
250
+        glColor3ubv(WHITE);
251 251
 
252 252
         if (getRender().getMode() == Render::modeWireframe)
253
-            glColor3fv(WHITE);
253
+            glColor3ubv(WHITE);
254 254
 
255 255
         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
256 256
         glBindTexture(GL_TEXTURE_2D, 1);  // White texture for colors

+ 19
- 37
src/TextureManager.cpp View File

@@ -21,8 +21,6 @@
21 21
 TextureManager::TextureManager() {
22 22
     mTextureIds = NULL;
23 23
     mFlags = 0;
24
-    mTextureId = -1;
25
-    mTextureId2 = -1;
26 24
     mTextureCount = 0;
27 25
     mTextureLimit = 0;
28 26
 }
@@ -33,21 +31,17 @@ TextureManager::~TextureManager() {
33 31
 
34 32
 unsigned char *TextureManager::generateColorTexture(unsigned char rgba[4],
35 33
         unsigned int width, unsigned int height) {
36
-    unsigned char *image;
37
-    unsigned int i, size;
38
-
39 34
     assert(rgba != NULL);
40 35
     assert(width > 0);
41 36
     assert(height > 0);
42 37
 
43
-    image = new unsigned char[height*width*4];
38
+    unsigned char *image = new unsigned char[height * width * 4];
44 39
 
45
-    for (i = 0, size = width*height; i < size; ++i) {
46
-        /* RBGA */
47
-        image[i*4]   = rgba[0];
48
-        image[i*4+1] = rgba[1];
49
-        image[i*4+2] = rgba[2];
50
-        image[i*4+3] = rgba[3];
40
+    for (unsigned int i = 0; i < (width * height); i++) {
41
+        image[i * 4] = rgba[0];
42
+        image[(i * 4) + 1] = rgba[1];
43
+        image[(i * 4) + 2] = rgba[2];
44
+        image[(i * 4) + 3] = rgba[3];
51 45
     }
52 46
 
53 47
     return image;
@@ -55,15 +49,12 @@ unsigned char *TextureManager::generateColorTexture(unsigned char rgba[4],
55 49
 
56 50
 int TextureManager::loadColorTexture(unsigned char rgba[4],
57 51
         unsigned int width, unsigned int height) {
58
-    unsigned char *image;
59
-    int id;
60
-
61 52
     assert(rgba != NULL);
62 53
     assert(width > 0);
63 54
     assert(height > 0);
64 55
 
65
-    image = generateColorTexture(rgba, width, height);
66
-    id = loadBuffer(image, width, height, RGBA, 32);
56
+    unsigned char *image = generateColorTexture(rgba, width, height);
57
+    int id = loadBuffer(image, width, height, RGBA, 32);
67 58
     delete [] image;
68 59
 
69 60
     return id;
@@ -89,9 +80,7 @@ void TextureManager::reset() {
89 80
 }
90 81
 
91 82
 void TextureManager::disableMultiTexture() {
92
-    mFlags ^= fUseMultiTexture;
93
-    mTextureId = -1;
94
-    mTextureId2 = -1;
83
+    mFlags &= ~fUseMultiTexture;
95 84
 
96 85
     glDisable(GL_TEXTURE_2D);
97 86
     glActiveTextureARB(GL_TEXTURE0_ARB);
@@ -106,23 +95,17 @@ void TextureManager::useMultiTexture(float aU, float aV, float bU, float bV) {
106 95
 }
107 96
 
108 97
 void TextureManager::useMultiTexture(float u, float v) {
109
-    if (!(mFlags & fUseMultiTexture))
110
-        return;
111
-
112
-    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u, v);
113
-    glMultiTexCoord2fARB(GL_TEXTURE1_ARB, u, v);
98
+    useMultiTexture(u, v, u, v);
114 99
 }
115 100
 
116 101
 void TextureManager::bindMultiTexture(int texture0, int texture1) {
117 102
     assert(mTextureIds != NULL);
118 103
     assert(texture0 >= 0);
119
-    assert((unsigned int)texture0 <= mTextureCount);
120 104
     assert(texture1 >= 0);
105
+    assert((unsigned int)texture0 <= mTextureCount);
121 106
     assert((unsigned int)texture1 <= mTextureCount);
122 107
 
123 108
     mFlags |= fUseMultiTexture;
124
-    mTextureId  = texture0;
125
-    mTextureId2 = texture1;
126 109
 
127 110
     glActiveTextureARB(GL_TEXTURE0_ARB);
128 111
     glEnable(GL_TEXTURE_2D);
@@ -134,12 +117,8 @@ void TextureManager::bindMultiTexture(int texture0, int texture1) {
134 117
 }
135 118
 
136 119
 void TextureManager::setMaxTextureCount(unsigned int n) {
137
-    assert(n > 0);
138
-
139 120
     mTextureLimit = n;
140
-
141 121
     mTextureIds = new unsigned int[n];
142
-
143 122
     glGenTextures(n, mTextureIds);
144 123
 }
145 124
 
@@ -274,8 +253,6 @@ void TextureManager::bindTextureId(unsigned int n) {
274 253
     assert(mTextureIds != NULL);
275 254
     assert(n <= mTextureCount);
276 255
 
277
-    mTextureId = n;
278
-
279 256
     glEnable(GL_TEXTURE_2D);
280 257
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
281 258
 
@@ -283,11 +260,15 @@ void TextureManager::bindTextureId(unsigned int n) {
283 260
 }
284 261
 
285 262
 int TextureManager::loadPCX(const char *filename) {
263
+    assert(filename != NULL);
264
+    assert(filename[0] != '\0');
265
+
286 266
     unsigned char *image;
287 267
     unsigned int w, h, bpp;
288 268
     ColorMode c;
289 269
     int id = -1;
290 270
     int error = pcxLoad(filename, &image, &w, &h, &c, &bpp);
271
+
291 272
     if (error == 0) {
292 273
         unsigned char *image2 = scaleBuffer(image, &w, &h, bpp);
293 274
         if (image2) {
@@ -297,19 +278,20 @@ int TextureManager::loadPCX(const char *filename) {
297 278
         id = loadBuffer(image, w, h, c, bpp);
298 279
         delete [] image;
299 280
     }
281
+
300 282
     return id;
301 283
 }
302 284
 
303 285
 int TextureManager::loadTGA(const char *filename) {
286
+    assert(filename != NULL);
287
+    assert(filename[0] != '\0');
288
+
304 289
     unsigned char *image = NULL;
305 290
     unsigned char *image2 = NULL;
306 291
     unsigned int w, h;
307 292
     char type;
308 293
     int id = -1;
309 294
 
310
-    assert(filename != NULL);
311
-    assert(filename[0] != '\0');
312
-
313 295
     if (!tgaCheck(filename)) {
314 296
         tgaLoad(filename, &image, &w, &h, &type);
315 297
 

+ 0
- 4
src/utils/pcx.cpp View File

@@ -13,12 +13,8 @@
13 13
 #include "global.h"
14 14
 #include "utils/pcx.h"
15 15
 
16
-#ifdef DEBUG
17 16
 #include "Console.h"
18 17
 #define pcxPrint getConsole().print
19
-#else
20
-void pcxPrint(...) { }
21
-#endif
22 18
 
23 19
 int pcxCheck(const char *filename) {
24 20
     assert(filename != NULL);

+ 0
- 4
src/utils/png.cpp View File

@@ -15,12 +15,8 @@
15 15
 #include "utils/pixel.h"
16 16
 #include "utils/png.h"
17 17
 
18
-#ifdef DEBUG
19 18
 #include "Console.h"
20 19
 #define pngPrint getConsole().print
21
-#else
22
-void pngPrint(...) { }
23
-#endif
24 20
 
25 21
 int pngCheck(const char *filename) {
26 22
     png_byte header[8];

Loading…
Cancel
Save