Thomas Buck пре 9 година
родитељ
комит
741083b757
8 измењених фајлова са 50 додато и 48 уклоњено
  1. 2
    2
      include/Mesh.h
  2. 4
    4
      include/Render.h
  3. 8
    8
      src/Mesh.cpp
  4. 5
    5
      src/Render.cpp
  5. 2
    2
      src/TextureManager.cpp
  6. 20
    19
      src/UI.cpp
  7. 8
    7
      src/loader/LoaderTR2.cpp
  8. 1
    1
      src/utils/binary.cpp

+ 2
- 2
include/Mesh.h Прегледај датотеку

32
     // Warning: texture is not the GL texture id,
32
     // Warning: texture is not the GL texture id,
33
     // it is an index into the object texture list!
33
     // it is an index into the object texture list!
34
     void addTexturedRectangle(struct vertex_t a, struct vertex_t b,
34
     void addTexturedRectangle(struct vertex_t a, struct vertex_t b,
35
-            struct vertex_t c, struct vertex_t d, uint16_t texture);
35
+                              struct vertex_t c, struct vertex_t d, uint16_t texture);
36
     void addTexturedTriangle(struct vertex_t a, struct vertex_t b,
36
     void addTexturedTriangle(struct vertex_t a, struct vertex_t b,
37
-            struct vertex_t c, uint16_t texture);
37
+                             struct vertex_t c, uint16_t texture);
38
 
38
 
39
     std::vector<struct rectangle_t> texturedRectangles;
39
     std::vector<struct rectangle_t> texturedRectangles;
40
     std::vector<struct rectangle_t> coloredRectangles;
40
     std::vector<struct rectangle_t> coloredRectangles;

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

117
     float getDistToSphereFromNear(float x, float y, float z, float radius);
117
     float getDistToSphereFromNear(float x, float y, float z, float radius);
118
 
118
 
119
     void debugDisplayTexture(int texture = -1,
119
     void debugDisplayTexture(int texture = -1,
120
-            TextureManager::TextureStorage s = TextureManager::TextureStorage::GAME,
121
-            float x = 0.0f, float y = 0.0f, float w = 256.0f, float h = 256.0f);
120
+                             TextureManager::TextureStorage s = TextureManager::TextureStorage::GAME,
121
+                             float x = 0.0f, float y = 0.0f, float w = 256.0f, float h = 256.0f);
122
 
122
 
123
     void debugDisplayTextile(int texture = -1,
123
     void debugDisplayTextile(int texture = -1,
124
-            float x = 0.0f, float y = 0.0f, float w = 64.0f, float h = 64.0f);
124
+                             float x = 0.0f, float y = 0.0f, float w = 64.0f, float h = 64.0f);
125
 
125
 
126
   private:
126
   private:
127
 
127
 
128
     void drawTexture(float x, float y, float w, float h,
128
     void drawTexture(float x, float y, float w, float h,
129
-            unsigned int texture, TextureManager::TextureStorage s);
129
+                     unsigned int texture, TextureManager::TextureStorage s);
130
 
130
 
131
     void drawTextile(float x, float y, float w, float h, unsigned int textile);
131
     void drawTextile(float x, float y, float w, float h, unsigned int textile);
132
 
132
 

+ 8
- 8
src/Mesh.cpp Прегледај датотеку

12
 #include "Mesh.h"
12
 #include "Mesh.h"
13
 
13
 
14
 void Mesh::addTexturedRectangle(struct vertex_t a, struct vertex_t b,
14
 void Mesh::addTexturedRectangle(struct vertex_t a, struct vertex_t b,
15
-        struct vertex_t c, struct vertex_t d, uint16_t texture) {
15
+                                struct vertex_t c, struct vertex_t d, uint16_t texture) {
16
     struct rectangle_t r;
16
     struct rectangle_t r;
17
     r.a = a;
17
     r.a = a;
18
     r.b = b;
18
     r.b = b;
23
 }
23
 }
24
 
24
 
25
 void Mesh::addTexturedTriangle(struct vertex_t a, struct vertex_t b,
25
 void Mesh::addTexturedTriangle(struct vertex_t a, struct vertex_t b,
26
-        struct vertex_t c, uint16_t texture) {
26
+                               struct vertex_t c, uint16_t texture) {
27
     struct rectangle_t r;
27
     struct rectangle_t r;
28
     r.a = a;
28
     r.a = a;
29
     r.b = b;
29
     r.b = b;
34
 
34
 
35
 void Mesh::drawAlpha() {
35
 void Mesh::drawAlpha() {
36
     if ((texturedRectangles.size() == 0)
36
     if ((texturedRectangles.size() == 0)
37
-            && (texturedTriangles.size() == 0)
38
-            && (coloredRectangles.size() == 0)
39
-            && (coloredTriangles.size() == 0)) {
37
+        && (texturedTriangles.size() == 0)
38
+        && (coloredRectangles.size() == 0)
39
+        && (coloredTriangles.size() == 0)) {
40
         drawAlphaOld();
40
         drawAlphaOld();
41
         return;
41
         return;
42
     }
42
     }
46
 
46
 
47
 void Mesh::drawSolid() {
47
 void Mesh::drawSolid() {
48
     if ((texturedRectangles.size() == 0)
48
     if ((texturedRectangles.size() == 0)
49
-            && (texturedTriangles.size() == 0)
50
-            && (coloredRectangles.size() == 0)
51
-            && (coloredTriangles.size() == 0)) {
49
+        && (texturedTriangles.size() == 0)
50
+        && (coloredRectangles.size() == 0)
51
+        && (coloredTriangles.size() == 0)) {
52
         drawSolidOld();
52
         drawSolidOld();
53
         return;
53
         return;
54
     }
54
     }

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

175
         case Render::modeSolid:
175
         case Render::modeSolid:
176
         case Render::modeWireframe:
176
         case Render::modeWireframe:
177
             glClearColor(PURPLE[0] / 256.0f, PURPLE[1] / 256.0f,
177
             glClearColor(PURPLE[0] / 256.0f, PURPLE[1] / 256.0f,
178
-                    PURPLE[2] / 256.0f, PURPLE[3] / 256.0f);
178
+                         PURPLE[2] / 256.0f, PURPLE[3] / 256.0f);
179
             glDisable(GL_TEXTURE_2D);
179
             glDisable(GL_TEXTURE_2D);
180
             break;
180
             break;
181
         default:
181
         default:
186
             }
186
             }
187
 
187
 
188
             glClearColor(BLACK[0] / 256.0f, BLACK[1] / 256.0f,
188
             glClearColor(BLACK[0] / 256.0f, BLACK[1] / 256.0f,
189
-                    BLACK[2] / 256.0f, BLACK[3] / 256.0f);
189
+                         BLACK[2] / 256.0f, BLACK[3] / 256.0f);
190
 
190
 
191
             glEnable(GL_TEXTURE_2D);
191
             glEnable(GL_TEXTURE_2D);
192
     }
192
     }
355
     getWindow().glEnter2D();
355
     getWindow().glEnter2D();
356
 
356
 
357
     drawTexture(0.0f, 0.0f, getWindow().getWidth(), getWindow().getHeight(),
357
     drawTexture(0.0f, 0.0f, getWindow().getWidth(), getWindow().getHeight(),
358
-            TEXTURE_SPLASH, TextureManager::TextureStorage::SYSTEM);
358
+                TEXTURE_SPLASH, TextureManager::TextureStorage::SYSTEM);
359
 
359
 
360
     if (debugTexture >= 0)
360
     if (debugTexture >= 0)
361
         drawTexture(debugX, debugY, debugW, debugH, debugTexture, debugTextureStorage);
361
         drawTexture(debugX, debugY, debugW, debugH, debugTexture, debugTextureStorage);
486
 }
486
 }
487
 
487
 
488
 void Render::debugDisplayTexture(int texture, TextureManager::TextureStorage s,
488
 void Render::debugDisplayTexture(int texture, TextureManager::TextureStorage s,
489
-        float x, float y, float w, float h) {
489
+                                 float x, float y, float w, float h) {
490
     debugTexture = texture;
490
     debugTexture = texture;
491
     debugTextureStorage = s;
491
     debugTextureStorage = s;
492
     debugX = x;
492
     debugX = x;
497
 }
497
 }
498
 
498
 
499
 void Render::drawTexture(float x, float y, float w, float h,
499
 void Render::drawTexture(float x, float y, float w, float h,
500
-        unsigned int texture, TextureManager::TextureStorage s) {
500
+                         unsigned int texture, TextureManager::TextureStorage s) {
501
     float z = 0.0f;
501
     float z = 0.0f;
502
 
502
 
503
     glColor3ubv(WHITE);
503
     glColor3ubv(WHITE);

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

25
 #endif
25
 #endif
26
 
26
 
27
 TextureTileVertex::TextureTileVertex(uint8_t xc, uint8_t xp, uint8_t yc, uint8_t yp)
27
 TextureTileVertex::TextureTileVertex(uint8_t xc, uint8_t xp, uint8_t yc, uint8_t yp)
28
-        : xCoordinate(xc), xPixel(xp), yCoordinate(yc), yPixel(yp) { }
28
+    : xCoordinate(xc), xPixel(xp), yCoordinate(yc), yPixel(yp) { }
29
 
29
 
30
 // ----------------------------------------------------------------------------
30
 // ----------------------------------------------------------------------------
31
 
31
 
110
     glBegin(GL_TRIANGLE_STRIP);
110
     glBegin(GL_TRIANGLE_STRIP);
111
     for (int i = 0; i < 3; i++) {
111
     for (int i = 0; i < 3; i++) {
112
         glTexCoord2f(vertices.at(i)->xPixel / 256.0f,
112
         glTexCoord2f(vertices.at(i)->xPixel / 256.0f,
113
-                vertices.at(i)->yPixel / 256.0f);
113
+                     vertices.at(i)->yPixel / 256.0f);
114
 
114
 
115
         if (vertices.at(i)->xCoordinate == 255) {
115
         if (vertices.at(i)->xCoordinate == 255) {
116
             if (vertices.at(i)->yCoordinate == 255) {
116
             if (vertices.at(i)->yCoordinate == 255) {

+ 20
- 19
src/UI.cpp Прегледај датотеку

197
                     if (offset > 10)
197
                     if (offset > 10)
198
                         offset = 10;
198
                         offset = 10;
199
                     ImGui::PlotLines("FPS", &getRunTime().getHistoryFPS()[1],
199
                     ImGui::PlotLines("FPS", &getRunTime().getHistoryFPS()[1],
200
-                            getRunTime().getHistoryFPS().size() - 1,
201
-                            getRunTime().getHistoryFPS().size() - offset - 1);
200
+                                     getRunTime().getHistoryFPS().size() - 1,
201
+                                     getRunTime().getHistoryFPS().size() - offset - 1);
202
                 } else {
202
                 } else {
203
                     ImGui::PlotLines("FPS", &getRunTime().getHistoryFPS()[1],
203
                     ImGui::PlotLines("FPS", &getRunTime().getHistoryFPS()[1],
204
-                            getRunTime().getHistoryFPS().size() - 1);
204
+                                     getRunTime().getHistoryFPS().size() - 1);
205
                 }
205
                 }
206
                 ImGui::SameLine();
206
                 ImGui::SameLine();
207
                 ImGui::Checkbox("Scroll##fpsscroll", &scroll);
207
                 ImGui::Checkbox("Scroll##fpsscroll", &scroll);
230
             }
230
             }
231
 
231
 
232
             float vol = getSound().getVolume();
232
             float vol = getSound().getVolume();
233
-            if (ImGui::InputFloat("Volume##runtime", &vol, 0.0f, 0.0f, 3, ImGuiInputTextFlags_EnterReturnsTrue)) {
233
+            if (ImGui::InputFloat("Volume##runtime", &vol, 0.0f, 0.0f, 3,
234
+                                  ImGuiInputTextFlags_EnterReturnsTrue)) {
234
                 if (vol < 0.0f)
235
                 if (vol < 0.0f)
235
                     vol = 0.0f;
236
                     vol = 0.0f;
236
                 if (vol > 1.0f)
237
                 if (vol > 1.0f)
312
             static int index = 0;
313
             static int index = 0;
313
             ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
314
             ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
314
             ImGui::SliderInt("##texslide", &index, 0, getTextureManager().numTextures(
315
             ImGui::SliderInt("##texslide", &index, 0, getTextureManager().numTextures(
315
-                        game ? TextureManager::TextureStorage::GAME
316
-                        : TextureManager::TextureStorage::SYSTEM) - 1);
316
+                                 game ? TextureManager::TextureStorage::GAME
317
+                                 : TextureManager::TextureStorage::SYSTEM) - 1);
317
             ImGui::PopItemWidth();
318
             ImGui::PopItemWidth();
318
             ImGui::SameLine();
319
             ImGui::SameLine();
319
             if (ImGui::Button("+##texplus", ImVec2(0, 0), true)) {
320
             if (ImGui::Button("+##texplus", ImVec2(0, 0), true)) {
320
                 if (index < (getTextureManager().numTextures(
321
                 if (index < (getTextureManager().numTextures(
321
-                                game ? TextureManager::TextureStorage::GAME
322
-                                : TextureManager::TextureStorage::SYSTEM) - 1))
322
+                                 game ? TextureManager::TextureStorage::GAME
323
+                                 : TextureManager::TextureStorage::SYSTEM) - 1))
323
                     index++;
324
                     index++;
324
                 else
325
                 else
325
                     index = 0;
326
                     index = 0;
352
             }
353
             }
353
             if (visibleTex) {
354
             if (visibleTex) {
354
                 getRender().debugDisplayTexture(index,
355
                 getRender().debugDisplayTexture(index,
355
-                        game ? TextureManager::TextureStorage::GAME
356
-                        : TextureManager::TextureStorage::SYSTEM,
357
-                        ImGui::GetWindowPos().x - ImGui::GetWindowWidth(),
358
-                        ImGui::GetWindowPos().y,
359
-                        ImGui::GetWindowWidth(), ImGui::GetWindowWidth());
356
+                                                game ? TextureManager::TextureStorage::GAME
357
+                                                : TextureManager::TextureStorage::SYSTEM,
358
+                                                ImGui::GetWindowPos().x - ImGui::GetWindowWidth(),
359
+                                                ImGui::GetWindowPos().y,
360
+                                                ImGui::GetWindowWidth(), ImGui::GetWindowWidth());
360
             }
361
             }
361
         }
362
         }
362
 
363
 
396
                 }
397
                 }
397
                 if (visibleTile) {
398
                 if (visibleTile) {
398
                     getRender().debugDisplayTextile(index,
399
                     getRender().debugDisplayTextile(index,
399
-                            ImGui::GetWindowPos().x - (ImGui::GetWindowWidth() / 2),
400
-                            ImGui::GetWindowPos().y,
401
-                            (ImGui::GetWindowWidth() / 2), (ImGui::GetWindowWidth() / 2));
400
+                                                    ImGui::GetWindowPos().x - (ImGui::GetWindowWidth() / 2),
401
+                                                    ImGui::GetWindowPos().y,
402
+                                                    (ImGui::GetWindowWidth() / 2), (ImGui::GetWindowWidth() / 2));
402
                 }
403
                 }
403
             } else {
404
             } else {
404
                 ImGui::Text("Please load a level using the new loader!");
405
                 ImGui::Text("Please load a level using the new loader!");
447
                         fr--;
448
                         fr--;
448
                     } else {
449
                     } else {
449
                         getRender().debugDisplayTextile(tile,
450
                         getRender().debugDisplayTextile(tile,
450
-                                ImGui::GetWindowPos().x - (ImGui::GetWindowWidth() / 2),
451
-                                ImGui::GetWindowPos().y,
452
-                                (ImGui::GetWindowWidth() / 2), (ImGui::GetWindowWidth() / 2));
451
+                                                        ImGui::GetWindowPos().x - (ImGui::GetWindowWidth() / 2),
452
+                                                        ImGui::GetWindowPos().y,
453
+                                                        (ImGui::GetWindowWidth() / 2), (ImGui::GetWindowWidth() / 2));
453
                         fr = getRunTime().getFPS() / 2;
454
                         fr = getRunTime().getFPS() / 2;
454
                         tile = getTextureManager().getNextTileAnimation(tile);
455
                         tile = getTextureManager().getNextTileAnimation(tile);
455
                     }
456
                     }

+ 8
- 7
src/loader/LoaderTR2.cpp Прегледај датотеку

90
         // Convert 16bit textile to 32bit textile
90
         // Convert 16bit textile to 32bit textile
91
         unsigned char* img = argb16to32(&arr[0], 256, 256);
91
         unsigned char* img = argb16to32(&arr[0], 256, 256);
92
         int r = getTextureManager().loadBufferSlot(img, 256, 256, ARGB, 32,
92
         int r = getTextureManager().loadBufferSlot(img, 256, 256, ARGB, 32,
93
-                    TextureManager::TextureStorage::GAME, i);
93
+                TextureManager::TextureStorage::GAME, i);
94
         assert(r >= 0); //! \fixme properly handle error when texture could not be loaded!
94
         assert(r >= 0); //! \fixme properly handle error when texture could not be loaded!
95
         delete [] img;
95
         delete [] img;
96
     }
96
     }
146
         int count = animatedTextures.at(pos) + 1;
146
         int count = animatedTextures.at(pos) + 1;
147
         if ((pos + count) >= numWords) {
147
         if ((pos + count) >= numWords) {
148
             getLog() << "LoaderTR2: Invalid AnimatedTextures ("
148
             getLog() << "LoaderTR2: Invalid AnimatedTextures ("
149
-                << pos + count << " >= " << numWords << ")!" << Log::endl;
149
+                     << pos + count << " >= " << numWords << ")!" << Log::endl;
150
             return;
150
             return;
151
         }
151
         }
152
 
152
 
215
             uint16_t texture = file.readU16();
215
             uint16_t texture = file.readU16();
216
 
216
 
217
             room->getMesh().addTexturedRectangle(vertices.at(vertex1), vertices.at(vertex2),
217
             room->getMesh().addTexturedRectangle(vertices.at(vertex1), vertices.at(vertex2),
218
-                    vertices.at(vertex3), vertices.at(vertex4), texture);
218
+                                                 vertices.at(vertex3), vertices.at(vertex4), texture);
219
         }
219
         }
220
 
220
 
221
         uint16_t numTriangles = file.readU16();
221
         uint16_t numTriangles = file.readU16();
229
             uint16_t texture = file.readU16();
229
             uint16_t texture = file.readU16();
230
 
230
 
231
             room->getMesh().addTexturedTriangle(vertices.at(vertex1), vertices.at(vertex2),
231
             room->getMesh().addTexturedTriangle(vertices.at(vertex1), vertices.at(vertex2),
232
-                    vertices.at(vertex3), texture);
232
+                                                vertices.at(vertex3), texture);
233
         }
233
         }
234
 
234
 
235
         uint16_t numSprites = file.readU16();
235
         uint16_t numSprites = file.readU16();
684
 
684
 
685
         if (std::string("RIFF") != std::string(test)) {
685
         if (std::string("RIFF") != std::string(test)) {
686
             getLog() << "LoaderTR2: External SFX invalid! (" << riffCount
686
             getLog() << "LoaderTR2: External SFX invalid! (" << riffCount
687
-                << ", \"" << test << "\" != \"RIFF\")" << Log::endl;
687
+                     << ", \"" << test << "\" != \"RIFF\")" << Log::endl;
688
             return;
688
             return;
689
         }
689
         }
690
 
690
 
743
 
743
 
744
     if (numCinematicFrames > 0)
744
     if (numCinematicFrames > 0)
745
         getLog() << "LoaderTR2: Found " << numCinematicFrames
745
         getLog() << "LoaderTR2: Found " << numCinematicFrames
746
-            << " CinematicFrames, not yet implemented!" << Log::endl;
746
+                 << " CinematicFrames, not yet implemented!" << Log::endl;
747
 }
747
 }
748
 
748
 
749
 void LoaderTR2::loadDemoData() {
749
 void LoaderTR2::loadDemoData() {
753
 
753
 
754
     // TODO store demo data somewhere, find out meaning
754
     // TODO store demo data somewhere, find out meaning
755
     if (numDemoData > 0)
755
     if (numDemoData > 0)
756
-        getLog() << "LoaderTR2: Found " << numDemoData << " bytes DemoData, not yet implemented!" << Log::endl;
756
+        getLog() << "LoaderTR2: Found " << numDemoData << " bytes DemoData, not yet implemented!" <<
757
+                 Log::endl;
757
 }
758
 }
758
 
759
 

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

192
     if ((offset + c) > max) {
192
     if ((offset + c) > max) {
193
         std::ostringstream ss;
193
         std::ostringstream ss;
194
         ss << "BinaryMemory read out of bounds ("
194
         ss << "BinaryMemory read out of bounds ("
195
-            << offset << " + " << c << " > " << max;
195
+           << offset << " + " << c << " > " << max;
196
         throw new Exception(ss.str());
196
         throw new Exception(ss.str());
197
     }
197
     }
198
 
198
 

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