Browse Source

Compiles in Ubuntu 14.04 with gcc

Thomas Buck 10 years ago
parent
commit
e088c8ebcd
7 changed files with 26 additions and 30 deletions
  1. 6
    0
      ChangeLog.md
  2. 3
    4
      include/TextureManager.h
  3. 3
    0
      src/Font.cpp
  4. 1
    0
      src/FontTRLE.cpp
  5. 1
    9
      src/Render.cpp
  6. 7
    16
      src/TextureManager.cpp
  7. 5
    1
      src/utils/png.cpp

+ 6
- 0
ChangeLog.md View File

@@ -2,6 +2,12 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140624 ]
6
+    * Some changes to allow compilation with Ubuntu 14.04 / gcc
7
+    * Modified utils/png to allow compilation with different integer sizes
8
+      Thanks to Christian for his help and his Linux machine :)
9
+    * Removed TextureManagers fUseMipmaps flag, now always used
10
+
5 11
     [ 20140623 ]
6 12
     * Use unsigned char instead of float for colors
7 13
 

+ 3
- 4
include/TextureManager.h View File

@@ -25,8 +25,7 @@ public:
25 25
     };
26 26
 
27 27
     enum TextureFlag {
28
-        fUseMipmaps      = (1 << 0),
29
-        fUseMultiTexture = (1 << 1),
28
+        fUseMultiTexture = (1 << 0),
30 29
     };
31 30
 
32 31
     /*!
@@ -51,7 +50,7 @@ public:
51 50
      * \param height height of newly allocated buffer, power of 2, pref same as width
52 51
      * \returns newly allocated texture buffer filled with specified color
53 52
      */
54
-    static unsigned char *generateColorTexture(unsigned char rgba[4],
53
+    static unsigned char *generateColorTexture(const unsigned char rgba[4],
55 54
                                                 unsigned int width,
56 55
                                                 unsigned int height);
57 56
 
@@ -117,7 +116,7 @@ public:
117 116
      * \param height height of new texture
118 117
      * \returns texture ID or -1 on error
119 118
      */
120
-    int loadColorTexture(unsigned char rgba[4],
119
+    int loadColorTexture(const unsigned char rgba[4],
121 120
                             unsigned int width, unsigned int height);
122 121
 
123 122
     /*!

+ 3
- 0
src/Font.cpp View File

@@ -5,6 +5,9 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include <stdio.h>
9
+#include <stdarg.h>
10
+
8 11
 #include "global.h"
9 12
 #include "utils/strings.h"
10 13
 #include "Font.h"

+ 1
- 0
src/FontTRLE.cpp View File

@@ -7,6 +7,7 @@
7 7
 
8 8
 #include <fstream>
9 9
 #include <sstream>
10
+#include <stdexcept>
10 11
 
11 12
 #include "global.h"
12 13
 #include "utils/strings.h"

+ 1
- 9
src/Render.cpp View File

@@ -89,20 +89,12 @@ void Render::loadTexture(unsigned char *image,
89 89
 int Render::initTextures(char *textureDir) {
90 90
     char *filename;
91 91
     unsigned int numTextures = 0;
92
-    unsigned char color[4];
93 92
 
94 93
     mTexture.reset();
95 94
     mTexture.setMaxTextureCount(128);  /* TR never needs more than 32 iirc
96 95
                                           However, color texturegen is a lot */
97 96
 
98
-    mTexture.setFlag(TextureManager::fUseMipmaps);
99
-
100
-    color[0] = 0xff;
101
-    color[1] = 0xff;
102
-    color[2] = 0xff;
103
-    color[3] = 0xff;
104
-
105
-    if (mTexture.loadColorTexture(color, 32, 32) > -1)
97
+    if (mTexture.loadColorTexture(WHITE, 32, 32) > -1)
106 98
         numTextures++;
107 99
 
108 100
     // Temporary

+ 7
- 16
src/TextureManager.cpp View File

@@ -29,7 +29,7 @@ TextureManager::~TextureManager() {
29 29
     reset();
30 30
 }
31 31
 
32
-unsigned char *TextureManager::generateColorTexture(unsigned char rgba[4],
32
+unsigned char *TextureManager::generateColorTexture(const unsigned char rgba[4],
33 33
         unsigned int width, unsigned int height) {
34 34
     assert(rgba != NULL);
35 35
     assert(width > 0);
@@ -47,7 +47,7 @@ unsigned char *TextureManager::generateColorTexture(unsigned char rgba[4],
47 47
     return image;
48 48
 }
49 49
 
50
-int TextureManager::loadColorTexture(unsigned char rgba[4],
50
+int TextureManager::loadColorTexture(const unsigned char rgba[4],
51 51
         unsigned int width, unsigned int height) {
52 52
     assert(rgba != NULL);
53 53
     assert(width > 0);
@@ -228,21 +228,12 @@ int TextureManager::loadBufferSlot(unsigned char *image,
228 228
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
229 229
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
230 230
 
231
-    if (mFlags & fUseMipmaps) {
232
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
233
-                GL_NEAREST_MIPMAP_LINEAR);
234
-        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
235
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
236
-                GL_LINEAR_MIPMAP_LINEAR);
231
+    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
232
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
233
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
237 234
 
238
-        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
239
-        glTexImage2D(GL_TEXTURE_2D, 0, bytes, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
240
-    } else {
241
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
242
-
243
-        glTexImage2D(GL_TEXTURE_2D, 0, glcMode, width, height, 0,
244
-                glcMode, GL_UNSIGNED_BYTE, image);
245
-    }
235
+    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
236
+    glTexImage2D(GL_TEXTURE_2D, 0, bytes, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
246 237
 
247 238
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
248 239
 

+ 5
- 1
src/utils/png.cpp View File

@@ -101,10 +101,14 @@ int pngLoad(const char *filename, unsigned char **image, unsigned int *width, un
101 101
     png_read_info(png_ptr, info_ptr);
102 102
 
103 103
     int bit_depth, color_type;
104
+    png_uint_32 tmpWidth, tmpHeight;
104 105
 
105
-    png_get_IHDR(png_ptr, info_ptr, width, height, &bit_depth, &color_type,
106
+    png_get_IHDR(png_ptr, info_ptr, &tmpWidth, &tmpHeight, &bit_depth, &color_type,
106 107
             NULL, NULL, NULL);
107 108
 
109
+    *width = tmpWidth;
110
+    *height = tmpHeight;
111
+
108 112
     if (bit_depth != 8) {
109 113
         pngPrint("%s: Unsupported bit depth %d.  Must be 8.", filename, bit_depth);
110 114
         return -7;

Loading…
Cancel
Save