Преглед изворни кода

Compiles in Ubuntu 14.04 with gcc

Thomas Buck пре 11 година
родитељ
комит
e088c8ebcd
7 измењених фајлова са 26 додато и 30 уклоњено
  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 Прегледај датотеку

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
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
     [ 20140623 ]
11
     [ 20140623 ]
6
     * Use unsigned char instead of float for colors
12
     * Use unsigned char instead of float for colors
7
 
13
 

+ 3
- 4
include/TextureManager.h Прегледај датотеку

25
     };
25
     };
26
 
26
 
27
     enum TextureFlag {
27
     enum TextureFlag {
28
-        fUseMipmaps      = (1 << 0),
29
-        fUseMultiTexture = (1 << 1),
28
+        fUseMultiTexture = (1 << 0),
30
     };
29
     };
31
 
30
 
32
     /*!
31
     /*!
51
      * \param height height of newly allocated buffer, power of 2, pref same as width
50
      * \param height height of newly allocated buffer, power of 2, pref same as width
52
      * \returns newly allocated texture buffer filled with specified color
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
                                                 unsigned int width,
54
                                                 unsigned int width,
56
                                                 unsigned int height);
55
                                                 unsigned int height);
57
 
56
 
117
      * \param height height of new texture
116
      * \param height height of new texture
118
      * \returns texture ID or -1 on error
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
                             unsigned int width, unsigned int height);
120
                             unsigned int width, unsigned int height);
122
 
121
 
123
     /*!
122
     /*!

+ 3
- 0
src/Font.cpp Прегледај датотеку

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

+ 1
- 0
src/FontTRLE.cpp Прегледај датотеку

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

+ 1
- 9
src/Render.cpp Прегледај датотеку

89
 int Render::initTextures(char *textureDir) {
89
 int Render::initTextures(char *textureDir) {
90
     char *filename;
90
     char *filename;
91
     unsigned int numTextures = 0;
91
     unsigned int numTextures = 0;
92
-    unsigned char color[4];
93
 
92
 
94
     mTexture.reset();
93
     mTexture.reset();
95
     mTexture.setMaxTextureCount(128);  /* TR never needs more than 32 iirc
94
     mTexture.setMaxTextureCount(128);  /* TR never needs more than 32 iirc
96
                                           However, color texturegen is a lot */
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
         numTextures++;
98
         numTextures++;
107
 
99
 
108
     // Temporary
100
     // Temporary

+ 7
- 16
src/TextureManager.cpp Прегледај датотеку

29
     reset();
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
         unsigned int width, unsigned int height) {
33
         unsigned int width, unsigned int height) {
34
     assert(rgba != NULL);
34
     assert(rgba != NULL);
35
     assert(width > 0);
35
     assert(width > 0);
47
     return image;
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
         unsigned int width, unsigned int height) {
51
         unsigned int width, unsigned int height) {
52
     assert(rgba != NULL);
52
     assert(rgba != NULL);
53
     assert(width > 0);
53
     assert(width > 0);
228
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
228
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
229
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
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
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
238
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
248
 
239
 

+ 5
- 1
src/utils/png.cpp Прегледај датотеку

101
     png_read_info(png_ptr, info_ptr);
101
     png_read_info(png_ptr, info_ptr);
102
 
102
 
103
     int bit_depth, color_type;
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
             NULL, NULL, NULL);
107
             NULL, NULL, NULL);
107
 
108
 
109
+    *width = tmpWidth;
110
+    *height = tmpHeight;
111
+
108
     if (bit_depth != 8) {
112
     if (bit_depth != 8) {
109
         pngPrint("%s: Unsupported bit depth %d.  Must be 8.", filename, bit_depth);
113
         pngPrint("%s: Unsupported bit depth %d.  Must be 8.", filename, bit_depth);
110
         return -7;
114
         return -7;

Loading…
Откажи
Сачувај