Explorar el Código

TextureManager now has independent storages

Thomas Buck hace 10 años
padre
commit
60c217d16a
Se han modificado 13 ficheros con 118 adiciones y 380 borrados
  1. 3
    0
      ChangeLog.md
  2. 0
    6
      include/Game.h
  3. 20
    52
      include/TextureManager.h
  4. 2
    57
      include/TombRaider.h
  5. 5
    20
      src/Game.cpp
  6. 15
    14
      src/Mesh.cpp
  7. 1
    7
      src/Render.cpp
  8. 2
    16
      src/Room.cpp
  9. 3
    4
      src/Sprite.cpp
  10. 9
    13
      src/StaticMesh.cpp
  11. 46
    90
      src/TextureManager.cpp
  12. 10
    99
      src/TombRaider.cpp
  13. 2
    2
      src/UI.cpp

+ 3
- 0
ChangeLog.md Ver fichero

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20141122 ]
6
+    * TextureManager now knows the difference between level and system textures.
7
+
5
     [ 20141116 ]
8
     [ 20141116 ]
6
     * Fixed background color of wireframe mode
9
     * Fixed background color of wireframe mode
7
 
10
 

+ 0
- 6
include/Game.h Ver fichero

32
     void handleAction(ActionEvents action, bool isFinished);
32
     void handleAction(ActionEvents action, bool isFinished);
33
     void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
33
     void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
34
 
34
 
35
-    unsigned int getTextureStart();
36
-    unsigned int getTextureOffset();
37
-
38
     Entity& getLara();
35
     Entity& getLara();
39
 
36
 
40
   private:
37
   private:
52
 
49
 
53
     TombRaider mTombRaider;
50
     TombRaider mTombRaider;
54
 
51
 
55
-    unsigned int mTextureStart;
56
-    unsigned int mTextureOffset;
57
-
58
     long mLara;
52
     long mLara;
59
 };
53
 };
60
 
54
 

+ 20
- 52
include/TextureManager.h Ver fichero

11
 
11
 
12
 #include <vector>
12
 #include <vector>
13
 
13
 
14
+// These are loaded into TextureStorage::SYSTEM by initialize()!
15
+#define TEXTURE_WHITE 0
16
+#define TEXTURE_SPLASH 1
17
+
14
 /*!
18
 /*!
15
  * \brief Texture registry
19
  * \brief Texture registry
16
  */
20
  */
17
 class TextureManager {
21
 class TextureManager {
18
   public:
22
   public:
19
 
23
 
20
-    enum TextureFlag {
21
-        fUseMultiTexture = (1 << 0),
24
+    enum class TextureStorage {
25
+        GAME,
26
+        SYSTEM
22
     };
27
     };
23
 
28
 
24
-    /*!
25
-    * \brief Constructs an object of Texture
26
-    */
27
-    TextureManager();
28
-
29
-    /*!
30
-     * \brief Deconstructs an object of Texture
31
-     */
32
     ~TextureManager();
29
     ~TextureManager();
33
 
30
 
34
-    /*!
35
-     * \brief Resets all texture data
36
-     */
37
-    void reset();
38
-
39
     int initialize();
31
     int initialize();
40
 
32
 
41
     /*!
33
     /*!
42
-     * \brief Get number of textures in use
43
-     * \returns used texture count, or -1 on error (uninitialized)
44
-     */
45
-    int getTextureCount();
46
-
47
-    /*!
48
-     * \brief Sets up multitexture rendering with passed ids
49
-     * \param texture0 first texture for multitexture
50
-     * \param texture1 second texture for multitexture
51
-     */
52
-    void bindMultiTexture(int texture0, int texture1);
53
-
54
-    /*!
55
      * \brief Binds the texture for use in GL
34
      * \brief Binds the texture for use in GL
56
      * \param n valid texture index
35
      * \param n valid texture index
36
+     * \param s Which TextureStorage should be accessed
57
      */
37
      */
58
-    void bindTextureId(unsigned int n);
59
-
60
-    /*!
61
-     * \brief Clears an option flag
62
-     * \param flag flag to clear
63
-     */
64
-    void clearFlag(TextureFlag flag);
65
-
66
-    void disableMultiTexture();
38
+    void bindTextureId(unsigned int n, TextureStorage s = TextureStorage::GAME);
67
 
39
 
68
     /*!
40
     /*!
69
      * \brief Loads Buffer as texture
41
      * \brief Loads Buffer as texture
72
      * \param height height of image
44
      * \param height height of image
73
      * \param mode mode of image
45
      * \param mode mode of image
74
      * \param bpp bits per pixel of image
46
      * \param bpp bits per pixel of image
47
+     * \param s Which TextureStorage should be accessed
75
      * \param slot slot (ID) of image
48
      * \param slot slot (ID) of image
76
      * \param filter if the texture should be mipmap filtered
49
      * \param filter if the texture should be mipmap filtered
77
      * \returns texture ID or < 0 on error
50
      * \returns texture ID or < 0 on error
79
     int loadBufferSlot(unsigned char* image,
52
     int loadBufferSlot(unsigned char* image,
80
                        unsigned int width, unsigned int height,
53
                        unsigned int width, unsigned int height,
81
                        ColorMode mode, unsigned int bpp,
54
                        ColorMode mode, unsigned int bpp,
82
-                       unsigned int slot, bool filter = true);
55
+                       TextureStorage s = TextureStorage::GAME,
56
+                       int slot = -1, bool filter = true);
83
 
57
 
84
-    int loadImage(const char* filename);
85
-
86
-    /*!
87
-     * \brief Sets an option flag
88
-     * \param flag flag to set
89
-     */
90
-    void setFlag(TextureFlag flag);
91
-
92
-    void useMultiTexture(float aU, float aV, float bU, float bV);
58
+    int loadImage(const char* filename, TextureStorage s = TextureStorage::GAME, int slot = -1);
93
 
59
 
94
   private:
60
   private:
95
-    int loadTGA(const char* filename);
96
-    int loadPCX(const char* filename);
97
-    int loadPNG(const char* filename);
61
+    std::vector<unsigned int>& getIds(TextureStorage s);
62
+
63
+    int loadTGA(const char* filename, TextureStorage s, int slot);
64
+    int loadPCX(const char* filename, TextureStorage s, int slot);
65
+    int loadPNG(const char* filename, TextureStorage s, int slot);
98
 
66
 
99
-    std::vector<unsigned int> mTextureIds;
100
-    unsigned int mFlags;
67
+    std::vector<unsigned int> mTextureIdsGame;
68
+    std::vector<unsigned int> mTextureIdsSystem;
101
 };
69
 };
102
 
70
 
103
 TextureManager& getTextureManager();
71
 TextureManager& getTextureManager();

+ 2
- 57
include/TombRaider.h Ver fichero

52
 
52
 
53
     int NumStaticMeshes();
53
     int NumStaticMeshes();
54
 
54
 
55
-    int NumSprites();
56
-
57
     int NumSpriteSequences();
55
     int NumSpriteSequences();
58
 
56
 
59
     int NumItems();
57
     int NumItems();
66
 
64
 
67
     tr2_item_t* Item();
65
     tr2_item_t* Item();
68
 
66
 
69
-    tr2_object_texture_t* ObjectTextures();
70
-
71
-    /*!
72
-     * \brief Get number of boxes
73
-     * \returns number of boxes
74
-     */
75
-    unsigned int getNumBoxes();
76
-
77
     tr2_box_t* Box();
67
     tr2_box_t* Box();
78
 
68
 
79
     tr2_mesh_t* Mesh();
69
     tr2_mesh_t* Mesh();
100
     tr2_sprite_sequence_t* SpriteSequence();
90
     tr2_sprite_sequence_t* SpriteSequence();
101
 
91
 
102
     /*!
92
     /*!
103
-     * \brief Makes a 32bit RGBA image from a stexture/bmap
104
-     * \param texture valid index into tex_special list
105
-     * \returns 32bit RGBA image or NULL on error
106
-     */
107
-    unsigned char* SpecialTexTile(int texture);
108
-
109
-    /*!
110
      * \brief Get copies of texture and it's bumpmap
93
      * \brief Get copies of texture and it's bumpmap
111
      * \param texture valid textile index
94
      * \param texture valid textile index
112
      * \param image will be set to texture if found, or NULL
95
      * \param image will be set to texture if found, or NULL
114
      */
97
      */
115
     void Texture(int texture, unsigned char** image, unsigned char** bumpmap);
98
     void Texture(int texture, unsigned char** image, unsigned char** bumpmap);
116
 
99
 
117
-    unsigned int* Palette16();
118
-
119
-    unsigned char* Palette8();
100
+    //unsigned int* Palette16();
101
+    //unsigned char* Palette8();
120
 
102
 
121
     tr2_room_t* Room();
103
     tr2_room_t* Room();
122
 
104
 
123
     /*!
105
     /*!
124
-     * \brief Check if a file is a TombRaider pak
125
-     * \param filename file to check
126
-     * \returns 0 if it is a TombRaider pak
127
-     */
128
-    static int checkMime(const char* filename);
129
-
130
-    /*!
131
      * \brief Loads TombRaider 1-5 pak into memory
106
      * \brief Loads TombRaider 1-5 pak into memory
132
      * and does some processing.
107
      * and does some processing.
133
      * \param filename points to valid TombRaider pak
108
      * \param filename points to valid TombRaider pak
137
     int Load(const char* filename);
112
     int Load(const char* filename);
138
 
113
 
139
     /*!
114
     /*!
140
-     * \brief Makes a clamped 0.0 to 1.0 texel from coord pair
141
-     * \param texel texel value, is modified, divided by 255.0 and returned
142
-     * \param offset if offset is negative, texel is decreased by one, else increased
143
-     * \returns modified texel divided by 255.0
144
-     */
145
-    float adjustTexel(unsigned char texel, char offset);
146
-
147
-    /*!
148
      * \brief Compute rotation angles from moveable animation data
115
      * \brief Compute rotation angles from moveable animation data
149
      * \param frame moveable animation data
116
      * \param frame moveable animation data
150
      * \param frame_offset moveable animation data
117
      * \param frame_offset moveable animation data
166
      */
133
      */
167
     void computeUV(tr2_object_texture_vert_t* st, float* u, float* v);
134
     void computeUV(tr2_object_texture_vert_t* st, float* u, float* v);
168
 
135
 
169
-    /*!
170
-     * \brief Get number of bump maps in loaded pak
171
-     * \returns number of bump maps
172
-     */
173
-    int getBumpMapCount();
174
-
175
     void getColor(int index, float color[4]);
136
     void getColor(int index, float color[4]);
176
 
137
 
177
     tr2_version_type getEngine();
138
     tr2_version_type getEngine();
550
      */
511
      */
551
     int getSkyModelId();
512
     int getSkyModelId();
552
 
513
 
553
-    void getSprites();
554
-
555
     /*!
514
     /*!
556
      * \brief Get a copy of a sound sample and its byte size
515
      * \brief Get a copy of a sound sample and its byte size
557
      * \param index sound sample index
516
      * \param index sound sample index
590
 
549
 
591
     void reset();
550
     void reset();
592
 
551
 
593
-    void setDebug(bool toggle);
594
-
595
-    /*!
596
-     * \brief Sets lighting factor for each vertex color per room in TR3 paks
597
-     * \param f new lighting factor
598
-     */
599
-    void setRoomVertexLightingFactor(float f);
600
-
601
-    /*!
602
-     * \brief Set scaling for sprite texel alignment, etc.
603
-     * \param f new scaling factor
604
-     */
605
-    void setTexelScalingFactor(float f);
606
-
607
   private:
552
   private:
608
 
553
 
609
     void extractMeshes(unsigned char* mesh_data,
554
     void extractMeshes(unsigned char* mesh_data,

+ 5
- 20
src/Game.cpp Ver fichero

31
 Game::Game() {
31
 Game::Game() {
32
     mLoaded = false;
32
     mLoaded = false;
33
     mLara = -1;
33
     mLara = -1;
34
-    mTextureStart = 0;
35
-    mTextureOffset = 0;
36
 }
34
 }
37
 
35
 
38
 Game::~Game() {
36
 Game::~Game() {
39
 }
37
 }
40
 
38
 
41
-unsigned int Game::getTextureStart() {
42
-    return mTextureStart;
43
-}
44
-
45
-unsigned int Game::getTextureOffset() {
46
-    return mTextureOffset;
47
-}
48
-
49
 int Game::initialize() {
39
 int Game::initialize() {
50
     // Enable Renderer
40
     // Enable Renderer
51
     getRender().setMode(Render::modeLoadScreen);
41
     getRender().setMode(Render::modeLoadScreen);
52
 
42
 
53
-    mTextureStart = getTextureManager().getTextureCount();
54
-
55
     return 0;
43
     return 0;
56
 }
44
 }
57
 
45
 
270
 
258
 
271
         // Overwrite any previous level textures on load
259
         // Overwrite any previous level textures on load
272
         getTextureManager().loadBufferSlot(image, 256, 256,
260
         getTextureManager().loadBufferSlot(image, 256, 256,
273
-                                           RGBA, 32, (mTextureStart - 1) + i);
261
+                                           RGBA, 32, TextureManager::TextureStorage::GAME, i);
274
 
262
 
275
 #ifdef MULTITEXTURE
263
 #ifdef MULTITEXTURE
276
-        gMapTex2Bump[(mTextureStart - 1) + i] = -1;
264
+        gMapTex2Bump[i] = -1;
277
 #endif
265
 #endif
278
 
266
 
279
         if (bumpmap) {
267
         if (bumpmap) {
280
 #ifdef MULTITEXTURE
268
 #ifdef MULTITEXTURE
281
-            gMapTex2Bump[(mTextureStart - 1) + i] = (mTextureStart - 1) + i +
282
-                                                    mTombRaider.NumTextures();
269
+            gMapTex2Bump[i] = i + mTombRaider.NumTextures();
283
 #endif
270
 #endif
284
             getTextureManager().loadBufferSlot(bumpmap, 256, 256,
271
             getTextureManager().loadBufferSlot(bumpmap, 256, 256,
285
-                                               RGBA, 32,
286
-                                               (mTextureStart - 1) + i + mTombRaider.NumTextures());
272
+                                               RGBA, 32, TextureManager::TextureStorage::GAME,
273
+                                               i + mTombRaider.NumTextures());
287
         }
274
         }
288
 
275
 
289
         if (image)
276
         if (image)
293
             delete [] bumpmap;
280
             delete [] bumpmap;
294
     }
281
     }
295
 
282
 
296
-    mTextureOffset = (mTextureStart - 1) + mTombRaider.NumTextures();
297
-
298
     getLog() << "Found " << mTombRaider.NumTextures() << " textures." << Log::endl;
283
     getLog() << "Found " << mTombRaider.NumTextures() << " textures." << Log::endl;
299
 }
284
 }
300
 
285
 

+ 15
- 14
src/Mesh.cpp Ver fichero

8
 #include <stdlib.h>
8
 #include <stdlib.h>
9
 
9
 
10
 #include "global.h"
10
 #include "global.h"
11
+#include "TextureManager.h"
11
 #include "Mesh.h"
12
 #include "Mesh.h"
12
 
13
 
13
 
14
 
122
         switch (mMode) {
123
         switch (mMode) {
123
             case MeshModeWireframe:
124
             case MeshModeWireframe:
124
                 glColor3f(0.0, 0.0, 1.0);
125
                 glColor3f(0.0, 0.0, 1.0);
125
-                glBindTexture(GL_TEXTURE_2D, 0);
126
+                getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
126
                 break;
127
                 break;
127
             case MeshModeSolid:
128
             case MeshModeSolid:
128
                 // Bind WHITE texture for solid colors
129
                 // Bind WHITE texture for solid colors
129
-                glBindTexture(GL_TEXTURE_2D, 0);
130
+                getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
130
                 break;
131
                 break;
131
             case MeshModeTexture:
132
             case MeshModeTexture:
132
             case MeshModeMultiTexture:
133
             case MeshModeMultiTexture:
133
                 // Bind texture id for textures
134
                 // Bind texture id for textures
134
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture + 1);
135
+                getTextureManager().bindTextureId(mQuads[i].texture);
135
                 break;
136
                 break;
136
         }
137
         }
137
 
138
 
155
         switch (mMode) {
156
         switch (mMode) {
156
             case MeshModeWireframe:
157
             case MeshModeWireframe:
157
                 glColor3f(0.0, 1.0, 0.0);
158
                 glColor3f(0.0, 1.0, 0.0);
158
-                glBindTexture(GL_TEXTURE_2D, 0);
159
+                getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
159
                 break;
160
                 break;
160
             case MeshModeSolid:
161
             case MeshModeSolid:
161
                 // Bind WHITE texture for solid colors
162
                 // Bind WHITE texture for solid colors
162
-                glBindTexture(GL_TEXTURE_2D, 0);
163
+                getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
163
                 break;
164
                 break;
164
             case MeshModeTexture:
165
             case MeshModeTexture:
165
             case MeshModeMultiTexture:
166
             case MeshModeMultiTexture:
166
                 // Bind texture id for textures
167
                 // Bind texture id for textures
167
-                glBindTexture(GL_TEXTURE_2D, mTris[i].texture + 1);
168
+                getTextureManager().bindTextureId(mTris[i].texture);
168
                 break;
169
                 break;
169
         }
170
         }
170
 
171
 
231
                 break;
232
                 break;
232
             case MeshModeWireframe:
233
             case MeshModeWireframe:
233
                 // Bind WHITE texture for solid colors
234
                 // Bind WHITE texture for solid colors
234
-                glBindTexture(GL_TEXTURE_2D, 0);
235
+                getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
235
                 break;
236
                 break;
236
 #ifdef MULTITEXTURE
237
 #ifdef MULTITEXTURE
237
             case MeshModeMultiTexture:
238
             case MeshModeMultiTexture:
238
                 glActiveTextureARB(GL_TEXTURE0_ARB);
239
                 glActiveTextureARB(GL_TEXTURE0_ARB);
239
                 glEnable(GL_TEXTURE_2D);
240
                 glEnable(GL_TEXTURE_2D);
240
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture + 1);
241
+                getTextureManager().bindTextureId(mQuads[i].texture);
241
 
242
 
242
                 glActiveTextureARB(GL_TEXTURE1_ARB);
243
                 glActiveTextureARB(GL_TEXTURE1_ARB);
243
                 glEnable(GL_TEXTURE_2D);
244
                 glEnable(GL_TEXTURE_2D);
244
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].bumpmap + 1);
245
+                getTextureManager().bindTextureId(mQuads[i].bumpmap);
245
                 break;
246
                 break;
246
 #else
247
 #else
247
             case MeshModeMultiTexture:
248
             case MeshModeMultiTexture:
249
             case MeshModeTexture:
250
             case MeshModeTexture:
250
                 // Bind texture id for textures
251
                 // Bind texture id for textures
251
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
252
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
252
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture + 1);
253
+                getTextureManager().bindTextureId(mQuads[i].texture);
253
                 break;
254
                 break;
254
         }
255
         }
255
 
256
 
286
                 break;
287
                 break;
287
             case MeshModeWireframe:
288
             case MeshModeWireframe:
288
                 // Bind WHITE texture for solid colors
289
                 // Bind WHITE texture for solid colors
289
-                glBindTexture(GL_TEXTURE_2D, 0);
290
+                getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
290
                 break;
291
                 break;
291
 #ifdef MULTITEXTURE
292
 #ifdef MULTITEXTURE
292
             case MeshModeMultiTexture:
293
             case MeshModeMultiTexture:
293
                 glActiveTextureARB(GL_TEXTURE0_ARB);
294
                 glActiveTextureARB(GL_TEXTURE0_ARB);
294
                 glEnable(GL_TEXTURE_2D);
295
                 glEnable(GL_TEXTURE_2D);
295
-                glBindTexture(GL_TEXTURE_2D, mTris[i].texture + 1);
296
+                getTextureManager().bindTextureId(mTris[i].texture);
296
 
297
 
297
                 glActiveTextureARB(GL_TEXTURE1_ARB);
298
                 glActiveTextureARB(GL_TEXTURE1_ARB);
298
                 glEnable(GL_TEXTURE_2D);
299
                 glEnable(GL_TEXTURE_2D);
299
-                glBindTexture(GL_TEXTURE_2D, mTris[i].bumpmap + 1);
300
+                getTextureManager().bindTextureId(mTris[i].bumpmap);
300
                 break;
301
                 break;
301
 #else
302
 #else
302
             case MeshModeMultiTexture:
303
             case MeshModeMultiTexture:
304
             case MeshModeTexture:
305
             case MeshModeTexture:
305
                 // Bind texture id for textures
306
                 // Bind texture id for textures
306
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
307
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
307
-                glBindTexture(GL_TEXTURE_2D, mTris[i].texture + 1);
308
+                getTextureManager().bindTextureId(mTris[i].texture);
308
                 break;
309
                 break;
309
         }
310
         }
310
 
311
 

+ 1
- 7
src/Render.cpp Ver fichero

339
     float x = 0.0f, y = 0.0f, z = 0.0f;
339
     float x = 0.0f, y = 0.0f, z = 0.0f;
340
     float w = getWindow().getWidth(), h = getWindow().getHeight();
340
     float w = getWindow().getWidth(), h = getWindow().getHeight();
341
 
341
 
342
-    if (getTextureManager().getTextureCount() <= 0)
343
-        return;
344
-
345
     // Mongoose 2002.01.01, Rendered while game is loading...
342
     // Mongoose 2002.01.01, Rendered while game is loading...
346
     //! \fixme seperate logo/particle coor later
343
     //! \fixme seperate logo/particle coor later
347
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
344
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
356
     glTranslatef(0.0f, 0.0f, -2000.0f);
353
     glTranslatef(0.0f, 0.0f, -2000.0f);
357
     glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
354
     glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
358
 
355
 
359
-    if (getTextureManager().getTextureCount() < 2)
360
-        getTextureManager().bindTextureId(0); //! \fixme store texture id somewhere
361
-    else
362
-        getTextureManager().bindTextureId(1);
356
+    getTextureManager().bindTextureId(TEXTURE_SPLASH, TextureManager::TextureStorage::SYSTEM);
363
 
357
 
364
     glBegin(GL_TRIANGLE_STRIP);
358
     glBegin(GL_TRIANGLE_STRIP);
365
     glTexCoord2f(1.0, 1.0);
359
     glTexCoord2f(1.0, 1.0);

+ 2
- 16
src/Room.cpp Ver fichero

104
     mesh.bufferNormalArray(normalCount, normalArray);
104
     mesh.bufferNormalArray(normalCount, normalArray);
105
     mesh.bufferColorArray(vertexCount, colorArray);
105
     mesh.bufferColorArray(vertexCount, colorArray);
106
 
106
 
107
-    tr.getRoomTriangles(index, getGame().getTextureStart(),
108
-                        &triCount, &indices, &texCoords, &textures,
109
-                        &fflags);
107
+    tr.getRoomTriangles(index, 0, &triCount, &indices, &texCoords, &textures, &fflags);
110
 
108
 
111
     mesh.bufferTriangles(triCount, indices, texCoords, textures, fflags);
109
     mesh.bufferTriangles(triCount, indices, texCoords, textures, fflags);
112
 #else
110
 #else
161
         tr.getRoomTriangle(index, t,
159
         tr.getRoomTriangle(index, t,
162
                            indices, texCoords, &texture, &flags);
160
                            indices, texCoords, &texture, &flags);
163
 
161
 
164
-        texture += getGame().getTextureStart();
165
-
166
         if (texture > (int)TextureLimit) {
162
         if (texture > (int)TextureLimit) {
167
             getLog() << "Handling bad room[" << index << "].tris["
163
             getLog() << "Handling bad room[" << index << "].tris["
168
                      << t << "].texture = " << texture << Log::endl;
164
                      << t << "].texture = " << texture << Log::endl;
189
         tr.getRoomRectangle(index, r,
185
         tr.getRoomRectangle(index, r,
190
                             indices, texCoords, &texture, &flags);
186
                             indices, texCoords, &texture, &flags);
191
 
187
 
192
-        texture += getGame().getTextureStart();
193
-
194
         if (texture > (int)TextureLimit) {
188
         if (texture > (int)TextureLimit) {
195
             getLog() << "Handling bad room[" << index << "].quad["
189
             getLog() << "Handling bad room[" << index << "].quad["
196
                      << r << "].texture = " << texture << Log::endl;
190
                      << r << "].texture = " << texture << Log::endl;
302
         tr.getRoomTriangle(index, t,
296
         tr.getRoomTriangle(index, t,
303
                            indices, texCoords, &texture, &flags);
297
                            indices, texCoords, &texture, &flags);
304
 
298
 
305
-        // Adjust texture id using getGame().getTextureStart() to map into
306
-        // correct textures
307
-        texture += getGame().getTextureStart();
308
-
309
         unsigned int j = tris_mesh_map[texture] - 1;
299
         unsigned int j = tris_mesh_map[texture] - 1;
310
 
300
 
311
         // Setup per vertex
301
         // Setup per vertex
352
         tr.getRoomRectangle(index, r,
342
         tr.getRoomRectangle(index, r,
353
                             indices, texCoords, &texture, &flags);
343
                             indices, texCoords, &texture, &flags);
354
 
344
 
355
-        // Adjust texture id using getGame().getTextureStart() to map into
356
-        // correct textures
357
-        texture += getGame().getTextureStart();
358
-
359
         if (texture > (int)TextureLimit) {
345
         if (texture > (int)TextureLimit) {
360
             texture = TextureLimit - 1;
346
             texture = TextureLimit - 1;
361
         }
347
         }
424
     glPushMatrix();
410
     glPushMatrix();
425
     //LightingSetup();
411
     //LightingSetup();
426
 
412
 
427
-    getTextureManager().bindTextureId(0); // \fixme WHITE texture
413
+    getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
428
 
414
 
429
     if ((!alpha) && getRender().getMode() == Render::modeWireframe) {
415
     if ((!alpha) && getRender().getMode() == Render::modeWireframe) {
430
         glLineWidth(2.0);
416
         glLineWidth(2.0);

+ 3
- 4
src/Sprite.cpp Ver fichero

9
 #include "Camera.h"
9
 #include "Camera.h"
10
 #include "Game.h"
10
 #include "Game.h"
11
 #include "Render.h"
11
 #include "Render.h"
12
+#include "TextureManager.h"
12
 #include "Sprite.h"
13
 #include "Sprite.h"
13
 
14
 
14
 SpriteSequence::SpriteSequence(TombRaider& tr, unsigned int item, unsigned int sequence) {
15
 SpriteSequence::SpriteSequence(TombRaider& tr, unsigned int item, unsigned int sequence) {
79
     texel[0][0] = (float)(x) / texelScale;
80
     texel[0][0] = (float)(x) / texelScale;
80
     texel[0][1] = (float)(y + height) / texelScale;
81
     texel[0][1] = (float)(y + height) / texelScale;
81
 
82
 
82
-    texture = sprite->tile + getGame().getTextureStart();
83
+    texture = sprite->tile;
83
     radius = width2 / 2.0f;
84
     radius = width2 / 2.0f;
84
 }
85
 }
85
 
86
 
90
     tr.getRoomSprite(room, index,
91
     tr.getRoomSprite(room, index,
91
                      10.0f, &texture, pos, spriteVertices, spriteTexCoords);
92
                      10.0f, &texture, pos, spriteVertices, spriteTexCoords);
92
 
93
 
93
-    texture += getGame().getTextureStart(); // OpenRaider preloads some textures
94
-
95
     for (unsigned int j = 0; j < 12; j++)
94
     for (unsigned int j = 0; j < 12; j++)
96
         vertex[j / 3][j % 3] = spriteVertices[j];
95
         vertex[j / 3][j % 3] = spriteVertices[j];
97
 
96
 
140
             glColor3ubv(WHITE);
139
             glColor3ubv(WHITE);
141
             break;
140
             break;
142
         default:
141
         default:
143
-            glBindTexture(GL_TEXTURE_2D, texture + 1);
142
+            getTextureManager().bindTextureId(texture);
144
 
143
 
145
             glBegin(GL_TRIANGLE_STRIP);
144
             glBegin(GL_TRIANGLE_STRIP);
146
             glTexCoord2fv(texel[0]);
145
             glTexCoord2fv(texel[0]);

+ 9
- 13
src/StaticMesh.cpp Ver fichero

31
 
31
 
32
     if ((getRender().getMode() != Render::modeWireframe)
32
     if ((getRender().getMode() != Render::modeWireframe)
33
         && (getRender().getMode() != Render::modeSolid)) {
33
         && (getRender().getMode() != Render::modeSolid)) {
34
-        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
35
-        glBindTexture(GL_TEXTURE_2D, texture + 1);
34
+        getTextureManager().bindTextureId(texture);
36
     }
35
     }
37
 
36
 
38
     glBegin(GL_TRIANGLES);
37
     glBegin(GL_TRIANGLES);
116
         texture = gColorTextureHACK.at(colorI);
115
         texture = gColorTextureHACK.at(colorI);
117
     } catch (...) {
116
     } catch (...) {
118
         unsigned char* image = generateColorTexture(color, 32, 32, 32);
117
         unsigned char* image = generateColorTexture(color, 32, 32, 32);
119
-        texture = getTextureManager().loadBufferSlot(image, 32, 32,
120
-                  RGBA, 32, getTextureManager().getTextureCount());
118
+        texture = getTextureManager().loadBufferSlot(image, 32, 32, RGBA, 32);
121
         delete [] image;
119
         delete [] image;
122
     }
120
     }
123
 
121
 
157
                                    vertexIndices, st,
155
                                    vertexIndices, st,
158
                                    &texture, &transparency);
156
                                    &texture, &transparency);
159
         triangles.push_back(
157
         triangles.push_back(
160
-            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
158
+            new TexturedTriangle(vertexIndices, st, texture, transparency));
161
     }
159
     }
162
 
160
 
163
     // Coloured Triangles
161
     // Coloured Triangles
180
         transparency = 0;
178
         transparency = 0;
181
 
179
 
182
         triangles.push_back(
180
         triangles.push_back(
183
-            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
181
+            new TexturedTriangle(vertexIndices, st, texture, transparency));
184
     }
182
     }
185
 
183
 
186
     // Textured Rectangles
184
     // Textured Rectangles
190
                                     vertexIndices, st,
188
                                     vertexIndices, st,
191
                                     &texture, &transparency);
189
                                     &texture, &transparency);
192
         triangles.push_back(
190
         triangles.push_back(
193
-            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
191
+            new TexturedTriangle(vertexIndices, st, texture, transparency));
194
         triangles.push_back(
192
         triangles.push_back(
195
-            new TexturedTriangle(vertexIndices + 3, st + 6, texture + getGame().getTextureStart(),
196
-                                 transparency));
193
+            new TexturedTriangle(vertexIndices + 3, st + 6, texture, transparency));
197
     }
194
     }
198
 
195
 
199
     // Coloured Rectangles
196
     // Coloured Rectangles
217
         transparency = 0;
214
         transparency = 0;
218
 
215
 
219
         triangles.push_back(
216
         triangles.push_back(
220
-            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
217
+            new TexturedTriangle(vertexIndices, st, texture, transparency));
221
         triangles.push_back(
218
         triangles.push_back(
222
-            new TexturedTriangle(vertexIndices + 3, st, texture + getGame().getTextureStart(), transparency));
219
+            new TexturedTriangle(vertexIndices + 3, st, texture, transparency));
223
     }
220
     }
224
 }
221
 }
225
 
222
 
246
         if (getRender().getMode() == Render::modeWireframe)
243
         if (getRender().getMode() == Render::modeWireframe)
247
             glColor3ubv(WHITE);
244
             glColor3ubv(WHITE);
248
 
245
 
249
-        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
250
-        glBindTexture(GL_TEXTURE_2D, 1);  // White texture for colors
246
+        getTextureManager().bindTextureId(TEXTURE_WHITE, TextureManager::TextureStorage::SYSTEM);
251
 
247
 
252
         for (unsigned int i = 0; i < triangles.size(); i++)
248
         for (unsigned int i = 0; i < triangles.size(); i++)
253
             triangles.at(i)->display(vertices, colors, normals);
249
             triangles.at(i)->display(vertices, colors, normals);

+ 46
- 90
src/TextureManager.cpp Ver fichero

24
 #include "utils/png.h"
24
 #include "utils/png.h"
25
 #endif
25
 #endif
26
 
26
 
27
-TextureManager::TextureManager() {
28
-    mFlags = 0;
27
+std::vector<unsigned int>& TextureManager::getIds(TextureStorage s) {
28
+    if (s == TextureStorage::GAME)
29
+        return mTextureIdsGame;
30
+    else
31
+        return mTextureIdsSystem;
29
 }
32
 }
30
 
33
 
31
 TextureManager::~TextureManager() {
34
 TextureManager::~TextureManager() {
32
-    reset();
33
-}
35
+    while (mTextureIdsSystem.size() > 0) {
36
+        unsigned int id = mTextureIdsSystem.at(mTextureIdsSystem.size() - 1);
37
+        glDeleteTextures(1, &id);
38
+        mTextureIdsSystem.pop_back();
39
+    }
34
 
40
 
35
-void TextureManager::reset() {
36
-    while (mTextureIds.size() > 0) {
37
-        unsigned int id = mTextureIds.at(mTextureIds.size() - 1);
41
+    while (mTextureIdsGame.size() > 0) {
42
+        unsigned int id = mTextureIdsGame.at(mTextureIdsGame.size() - 1);
38
         glDeleteTextures(1, &id);
43
         glDeleteTextures(1, &id);
39
-        mTextureIds.pop_back();
44
+        mTextureIdsGame.pop_back();
40
     }
45
     }
41
 }
46
 }
42
 
47
 
43
 int TextureManager::initialize() {
48
 int TextureManager::initialize() {
44
     unsigned char* image = generateColorTexture(WHITE, 32, 32, 32);
49
     unsigned char* image = generateColorTexture(WHITE, 32, 32, 32);
45
-    loadBufferSlot(image, 32, 32, RGBA, 32, mTextureIds.size());
50
+    int res = loadBufferSlot(image, 32, 32, RGBA, 32, TextureStorage::SYSTEM, TEXTURE_WHITE);
46
     delete [] image;
51
     delete [] image;
47
-
48
-    //! \fixme Temporary
49
-    std::string filename(getRunTime().getPakDir());
50
-    filename += "/tr2/TITLE.PCX";
51
-    if (loadPCX(filename.c_str()) < 0) {
52
-        //! \fixme Error Checking. Return negative error code, check in calling place too
53
-        filename = getRunTime().getDataDir();
54
-        filename += "/splash.tga";
55
-        loadTGA(filename.c_str());
52
+    if (res < 0) {
53
+        return -1;
56
     }
54
     }
57
 
55
 
58
-    return (mTextureIds.size() == 0) ? -1 : 0;
59
-}
60
-
61
-void TextureManager::setFlag(TextureFlag flag) {
62
-    mFlags |= flag;
63
-}
64
-
65
-void TextureManager::clearFlag(TextureFlag flag) {
66
-    mFlags &= ~flag;
67
-}
68
-
69
-int TextureManager::getTextureCount() {
70
-    return mTextureIds.size();
71
-}
72
-
73
-void TextureManager::disableMultiTexture() {
74
-    mFlags &= ~fUseMultiTexture;
75
-
76
-#ifdef MULTITEXTURE
77
-    glDisable(GL_TEXTURE_2D);
78
-    glActiveTextureARB(GL_TEXTURE0_ARB);
79
-#endif
80
-}
81
-
82
-void TextureManager::useMultiTexture(float aU, float aV, float bU, float bV) {
83
-    if (!(mFlags & fUseMultiTexture))
84
-        return;
85
-
86
-#ifdef MULTITEXTURE
87
-    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, aU, aV);
88
-    glMultiTexCoord2fARB(GL_TEXTURE1_ARB, bU, bV);
89
-#endif
90
-}
91
-
92
-void TextureManager::bindMultiTexture(int texture0, int texture1) {
93
-    assert(texture0 >= 0);
94
-    assert(texture1 >= 0);
95
-    assert((unsigned int)texture0 < mTextureIds.size());
96
-    assert((unsigned int)texture1 < mTextureIds.size());
97
-
98
-    mFlags |= fUseMultiTexture;
99
-
100
-#ifdef MULTITEXTURE
101
-    glActiveTextureARB(GL_TEXTURE0_ARB);
102
-    glEnable(GL_TEXTURE_2D);
103
-    glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture0));
56
+    //! \fixme Temporary?
57
+    std::string filename = getRunTime().getPakDir() + "/tr2/TITLE.PCX";
58
+    if (loadPCX(filename.c_str(), TextureStorage::SYSTEM, TEXTURE_SPLASH) < 0) {
59
+        filename = getRunTime().getDataDir() + "/splash.tga";
60
+        if (loadTGA(filename.c_str(), TextureStorage::SYSTEM, TEXTURE_SPLASH) < 0) {
61
+            return -2;
62
+        }
63
+    }
104
 
64
 
105
-    glActiveTextureARB(GL_TEXTURE1_ARB);
106
-    glEnable(GL_TEXTURE_2D);
107
-    glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture1));
108
-#endif
65
+    return 0;
109
 }
66
 }
110
 
67
 
111
 int TextureManager::loadBufferSlot(unsigned char* image,
68
 int TextureManager::loadBufferSlot(unsigned char* image,
112
                                    unsigned int width, unsigned int height,
69
                                    unsigned int width, unsigned int height,
113
                                    ColorMode mode, unsigned int bpp,
70
                                    ColorMode mode, unsigned int bpp,
114
-                                   unsigned int slot, bool filter) {
71
+                                   TextureStorage s, int slot, bool filter) {
115
     assert(image != NULL);
72
     assert(image != NULL);
116
     assert(width > 0);
73
     assert(width > 0);
117
     assert(height > 0);
74
     assert(height > 0);
120
            || (mode == RGBA) || (mode ==  BGRA));
77
            || (mode == RGBA) || (mode ==  BGRA));
121
     assert((bpp == 8) || (bpp == 24) || (bpp == 32));
78
     assert((bpp == 8) || (bpp == 24) || (bpp == 32));
122
 
79
 
123
-    while (mTextureIds.size() <= slot) {
80
+    if (slot == -1)
81
+        slot = getIds(s).size();
82
+
83
+    while (getIds(s).size() <= slot) {
124
         unsigned int id;
84
         unsigned int id;
125
         glGenTextures(1, &id);
85
         glGenTextures(1, &id);
126
-        mTextureIds.push_back(id);
86
+        getIds(s).push_back(id);
127
     }
87
     }
128
 
88
 
129
     unsigned int glcMode;
89
     unsigned int glcMode;
159
     glColor3ubv(WHITE);
119
     glColor3ubv(WHITE);
160
     glEnable(GL_DEPTH_TEST);
120
     glEnable(GL_DEPTH_TEST);
161
     glShadeModel(GL_SMOOTH);
121
     glShadeModel(GL_SMOOTH);
162
-
163
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
122
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
164
-
165
-    glBindTexture(GL_TEXTURE_2D, mTextureIds.at(slot));
123
+    glBindTexture(GL_TEXTURE_2D, getIds(s).at(slot));
166
 
124
 
167
     if (filter) {
125
     if (filter) {
168
         glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
126
         glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
177
 
135
 
178
     glTexImage2D(GL_TEXTURE_2D, 0, bpp / 8, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
136
     glTexImage2D(GL_TEXTURE_2D, 0, bpp / 8, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
179
 
137
 
180
-    //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
181
-
182
     return slot;
138
     return slot;
183
 }
139
 }
184
 
140
 
185
-void TextureManager::bindTextureId(unsigned int n) {
186
-    assert(n < mTextureIds.size());
141
+void TextureManager::bindTextureId(unsigned int n, TextureStorage s) {
142
+    assert(n < getIds(s).size());
187
 
143
 
188
     glEnable(GL_TEXTURE_2D);
144
     glEnable(GL_TEXTURE_2D);
189
-    //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
145
+    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
190
 
146
 
191
-    glBindTexture(GL_TEXTURE_2D, mTextureIds.at(n));
147
+    glBindTexture(GL_TEXTURE_2D, getIds(s).at(n));
192
 }
148
 }
193
 
149
 
194
-int TextureManager::loadImage(const char* filename) {
150
+int TextureManager::loadImage(const char* filename, TextureStorage s, int slot) {
195
     if (stringEndsWith(filename, ".pcx") || stringEndsWith(filename, ".PCX")) {
151
     if (stringEndsWith(filename, ".pcx") || stringEndsWith(filename, ".PCX")) {
196
-        return loadPCX(filename);
152
+        return loadPCX(filename, s, slot);
197
     } else if (stringEndsWith(filename, ".png") || stringEndsWith(filename, ".PNG")) {
153
     } else if (stringEndsWith(filename, ".png") || stringEndsWith(filename, ".PNG")) {
198
-        return loadPNG(filename);
154
+        return loadPNG(filename, s, slot);
199
     } else if (stringEndsWith(filename, ".tga") || stringEndsWith(filename, ".TGA")) {
155
     } else if (stringEndsWith(filename, ".tga") || stringEndsWith(filename, ".TGA")) {
200
-        return loadTGA(filename);
156
+        return loadTGA(filename, s, slot);
201
     } else {
157
     } else {
202
         getLog() << "No known image file type? (" << filename << ")" << Log::endl;
158
         getLog() << "No known image file type? (" << filename << ")" << Log::endl;
203
     }
159
     }
205
     return -1;
161
     return -1;
206
 }
162
 }
207
 
163
 
208
-int TextureManager::loadPCX(const char* filename) {
164
+int TextureManager::loadPCX(const char* filename, TextureStorage s, int slot) {
209
     assert(filename != NULL);
165
     assert(filename != NULL);
210
     assert(filename[0] != '\0');
166
     assert(filename[0] != '\0');
211
 
167
 
221
             delete [] image;
177
             delete [] image;
222
             image = image2;
178
             image = image2;
223
         }
179
         }
224
-        id = loadBufferSlot(image, w, h, c, bpp, mTextureIds.size());
180
+        id = loadBufferSlot(image, w, h, c, bpp, s, slot);
225
         delete [] image;
181
         delete [] image;
226
     }
182
     }
227
 
183
 
228
     return id;
184
     return id;
229
 }
185
 }
230
 
186
 
231
-int TextureManager::loadPNG(const char* filename) {
187
+int TextureManager::loadPNG(const char* filename, TextureStorage s, int slot) {
232
 #ifdef USING_PNG
188
 #ifdef USING_PNG
233
     assert(filename != NULL);
189
     assert(filename != NULL);
234
     assert(filename[0] != '\0');
190
     assert(filename[0] != '\0');
249
             delete [] image;
205
             delete [] image;
250
             image = image2;
206
             image = image2;
251
         }
207
         }
252
-        id = loadBufferSlot(image, w, h, c, bpp, mTextureIds.size());
208
+        id = loadBufferSlot(image, w, h, c, bpp, s, slot);
253
         delete [] image;
209
         delete [] image;
254
     }
210
     }
255
 
211
 
260
 #endif
216
 #endif
261
 }
217
 }
262
 
218
 
263
-int TextureManager::loadTGA(const char* filename) {
219
+int TextureManager::loadTGA(const char* filename, TextureStorage s, int slot) {
264
     assert(filename != NULL);
220
     assert(filename != NULL);
265
     assert(filename[0] != '\0');
221
     assert(filename[0] != '\0');
266
 
222
 
281
             id = loadBufferSlot(image, w, h,
237
             id = loadBufferSlot(image, w, h,
282
                                 (type == 2) ? RGBA : RGB,
238
                                 (type == 2) ? RGBA : RGB,
283
                                 (type == 2) ? 32 : 24,
239
                                 (type == 2) ? 32 : 24,
284
-                                mTextureIds.size());
240
+                                s, slot);
285
             delete [] image;
241
             delete [] image;
286
         }
242
         }
287
     }
243
     }

+ 10
- 99
src/TombRaider.cpp Ver fichero

113
     return _num_static_meshes;
113
     return _num_static_meshes;
114
 }
114
 }
115
 
115
 
116
-
116
+/*
117
 int TombRaider::NumSprites() {
117
 int TombRaider::NumSprites() {
118
     return _num_sprite_textures;
118
     return _num_sprite_textures;
119
 }
119
 }
120
-
120
+*/
121
 
121
 
122
 int TombRaider::NumSpriteSequences() {
122
 int TombRaider::NumSpriteSequences() {
123
     return _num_sprite_sequences;
123
     return _num_sprite_sequences;
144
     return _items;
144
     return _items;
145
 }
145
 }
146
 
146
 
147
-
147
+/*
148
 tr2_object_texture_t* TombRaider::ObjectTextures() {
148
 tr2_object_texture_t* TombRaider::ObjectTextures() {
149
     return _object_textures;
149
     return _object_textures;
150
 }
150
 }
151
 
151
 
152
-
153
 unsigned int TombRaider::getNumBoxes() {
152
 unsigned int TombRaider::getNumBoxes() {
154
     return _num_boxes;
153
     return _num_boxes;
155
 }
154
 }
156
-
155
+*/
157
 
156
 
158
 tr2_box_t* TombRaider::Box() {
157
 tr2_box_t* TombRaider::Box() {
159
     return _boxes;
158
     return _boxes;
251
 
250
 
252
 
251
 
253
 tr2_moveable_t* TombRaider::Moveable() {
252
 tr2_moveable_t* TombRaider::Moveable() {
254
-    /*
255
-       if (n > 0 || n > (int)_num_moveables)
256
-       return NULL;
257
-       */
258
-
259
     return _moveables;
253
     return _moveables;
260
 }
254
 }
261
 
255
 
262
 
256
 
263
 tr2_meshtree_t* TombRaider::MeshTree() {
257
 tr2_meshtree_t* TombRaider::MeshTree() {
264
-    /*
265
-       if (n > 0 || n > (int)_num_mesh_trees)
266
-       return NULL;
267
-       */
268
-
269
     return _mesh_trees;
258
     return _mesh_trees;
270
 }
259
 }
271
 
260
 
279
     return _sprite_sequences;
268
     return _sprite_sequences;
280
 }
269
 }
281
 
270
 
282
-unsigned char* TombRaider::SpecialTexTile(int texture) {
283
-    unsigned char* image;
284
-    unsigned char* ptr;
285
-
286
-
287
-    image = NULL;
288
-
289
-    if (texture >= 0 && texture < NumSpecialTextures()) {
290
-        // Get base and offset into 32bit special textures/bump maps
291
-        ptr = _tex_special;
292
-        ptr += 256 * 256 * 4 * texture;
293
-
294
-        // Clone it as a single 256x256 @ 32bpp image
295
-        image = new unsigned char[256 * 256 * 4];
296
-        memcpy(image, ptr, 256 * 256 * 4);
297
-    }
298
-
299
-    return image;
300
-}
301
-
302
 
271
 
303
 int TombRaider::NumSpecialTextures() {
272
 int TombRaider::NumSpecialTextures() {
304
     return _num_tex_special;
273
     return _num_tex_special;
319
 }
288
 }
320
 
289
 
321
 
290
 
322
-unsigned int* TombRaider::Palette16() {
323
-    return _palette16;
324
-}
325
-
326
-
327
-unsigned char* TombRaider::Palette8() {
328
-    return (unsigned char*)_palette8;
329
-}
330
-
331
-
332
-int TombRaider::checkMime(const char* filename) {
333
-    FILE* f;
334
-    unsigned int version;
335
-
336
-    if (!filename || !filename[0]) {
337
-        print("checkFile", "Given filename was empty string or NULL");
338
-        return -1;
339
-    }
340
-
341
-    f = fopen(filename, "rb");
342
-
343
-    if (!f) {
344
-        perror(filename);
345
-        return -1;
346
-    }
347
-
348
-    //! \fixme Endianess
349
-    fread(&version, sizeof(version), 1, f);
350
-    fclose(f);
351
-
352
-    switch (version) {
353
-        case 0x00000020:
354
-        case 0x0000002d:
355
-        case 0xff080038:
356
-        case 0xff180038:
357
-        case 0xfffffff0: // bogus
358
-        case 0x00345254: // "TR4\0"
359
-            return 0;
360
-        default:
361
-            return 1;
362
-    }
363
-}
364
-
365
-
366
 int TombRaider::Load(const char* filename) {
291
 int TombRaider::Load(const char* filename) {
367
     FILE* f;
292
     FILE* f;
368
     int i, j, l;
293
     int i, j, l;
369
     unsigned int num_mesh_data_words, num_mesh_pointers, data_size, data_offset;
294
     unsigned int num_mesh_data_words, num_mesh_pointers, data_size, data_offset;
370
     unsigned int* mesh_pointer_list;
295
     unsigned int* mesh_pointer_list;
371
     unsigned char* raw_mesh_data;
296
     unsigned char* raw_mesh_data;
372
-    bool tr5;
373
     long debugf;
297
     long debugf;
374
 
298
 
375
 
299
 
386
 
310
 
387
     printDebug("Load", "mPakVersion = %u", mPakVersion);
311
     printDebug("Load", "mPakVersion = %u", mPakVersion);
388
 
312
 
389
-    tr5 = false;
390
-
391
     switch (mPakVersion) {
313
     switch (mPakVersion) {
392
         case 0x00000020:
314
         case 0x00000020:
393
             mEngineVersion = TR_VERSION_1;
315
             mEngineVersion = TR_VERSION_1;
1744
 // Public Accessors
1666
 // Public Accessors
1745
 ////////////////////////////////////////////////////////////
1667
 ////////////////////////////////////////////////////////////
1746
 
1668
 
1747
-float TombRaider::adjustTexel(unsigned char texel, char offset) {
1748
-    if (offset >= 0)
1749
-        texel++;
1750
-    else
1751
-        texel--;
1752
-
1753
-    return ((float)texel / 255.0f);
1754
-}
1755
-
1756
 
1669
 
1757
 void TombRaider::computeRotationAngles(unsigned short** frame,
1670
 void TombRaider::computeRotationAngles(unsigned short** frame,
1758
                                        unsigned int* frame_offset,
1671
                                        unsigned int* frame_offset,
1847
     *v = (float)y / 255.0f;
1760
     *v = (float)y / 255.0f;
1848
 }
1761
 }
1849
 
1762
 
1850
-
1763
+/*
1851
 int TombRaider::getBumpMapCount() {
1764
 int TombRaider::getBumpMapCount() {
1852
     return _num_bump_map_textures / 2;
1765
     return _num_bump_map_textures / 2;
1853
 }
1766
 }
1854
-
1767
+*/
1855
 
1768
 
1856
 void TombRaider::getColor(int index, float color[4]) {
1769
 void TombRaider::getColor(int index, float color[4]) {
1857
     switch (getEngine()) {
1770
     switch (getEngine()) {
3480
     return skyMesh;
3393
     return skyMesh;
3481
 }
3394
 }
3482
 
3395
 
3483
-
3396
+#if 0
3484
 void TombRaider::getSprites() {
3397
 void TombRaider::getSprites() {
3485
-#ifdef FIXME
3486
     int i, j, k, l, x, y, s_index, width, height;
3398
     int i, j, k, l, x, y, s_index, width, height;
3487
     float scale, width2, height2;
3399
     float scale, width2, height2;
3488
     tr2_sprite_texture_t* sprite;
3400
     tr2_sprite_texture_t* sprite;
3577
     }
3489
     }
3578
 
3490
 
3579
     printf("\n");
3491
     printf("\n");
3580
-#endif
3581
 }
3492
 }
3582
-
3493
+#endif
3583
 
3494
 
3584
 void TombRaider::getSoundSample(unsigned int index,
3495
 void TombRaider::getSoundSample(unsigned int index,
3585
                                 unsigned int* bytes, unsigned char** data) {
3496
                                 unsigned int* bytes, unsigned char** data) {
3986
     _num_overlaps = 0;
3897
     _num_overlaps = 0;
3987
 }
3898
 }
3988
 
3899
 
3989
-
3900
+/*
3990
 void TombRaider::setDebug(bool toggle) {
3901
 void TombRaider::setDebug(bool toggle) {
3991
     mDebug = toggle;
3902
     mDebug = toggle;
3992
 }
3903
 }
3993
 
3904
 
3994
-
3995
 void TombRaider::setRoomVertexLightingFactor(float f) {
3905
 void TombRaider::setRoomVertexLightingFactor(float f) {
3996
     mRoomVertexLightingFactor = f;
3906
     mRoomVertexLightingFactor = f;
3997
 }
3907
 }
3999
 void TombRaider::setTexelScalingFactor(float f) {
3909
 void TombRaider::setTexelScalingFactor(float f) {
4000
     mTexelScale = f;
3910
     mTexelScale = f;
4001
 }
3911
 }
3912
+*/
4002
 
3913
 
4003
 ////////////////////////////////////////////////////////////
3914
 ////////////////////////////////////////////////////////////
4004
 // Private Accessors
3915
 // Private Accessors

+ 2
- 2
src/UI.cpp Ver fichero

75
 
75
 
76
     //! \fixme TODO use proper texture slot
76
     //! \fixme TODO use proper texture slot
77
     fontTex = getTextureManager().loadBufferSlot((unsigned char*)tex_data,
77
     fontTex = getTextureManager().loadBufferSlot((unsigned char*)tex_data,
78
-              tex_x, tex_y, RGBA, 32, 0, false);
78
+              tex_x, tex_y, RGBA, 32, TextureManager::TextureStorage::SYSTEM, -1, false);
79
 
79
 
80
     stbi_image_free(tex_data);
80
     stbi_image_free(tex_data);
81
 
81
 
282
     glEnableClientState(GL_COLOR_ARRAY);
282
     glEnableClientState(GL_COLOR_ARRAY);
283
 
283
 
284
     // Setup texture
284
     // Setup texture
285
-    getTextureManager().bindTextureId(fontTex);
285
+    getTextureManager().bindTextureId(fontTex, TextureManager::TextureStorage::SYSTEM);
286
 
286
 
287
     // Render command lists
287
     // Render command lists
288
     for (int n = 0; n < cmd_lists_count; n++) {
288
     for (int n = 0; n < cmd_lists_count; n++) {

Loading…
Cancelar
Guardar