Ver código fonte

Added texture debugging

Thomas Buck 10 anos atrás
pai
commit
f570706e20
7 arquivos alterados com 88 adições e 13 exclusões
  1. 1
    0
      README.md
  2. 7
    0
      include/Render.h
  3. 17
    0
      include/Texture.h
  4. 3
    3
      src/CMakeLists.txt
  5. 8
    0
      src/OpenRaider.cpp
  6. 7
    0
      src/Render.cpp
  7. 45
    10
      src/Texture.cpp

+ 1
- 0
README.md Ver arquivo

@@ -152,6 +152,7 @@ Pressing <UP> will go back to last command entered (saves typing).
152 152
 
153 153
 | Command          | Action                                       |
154 154
 | ----------------:|:-------------------------------------------- |
155
+| texture INT      | Display the specified 2D texture for 2s      |
155 156
 | wireframe        | Render in wireframe (for debugging)          |
156 157
 | solid            | Render solid color polygons                  |
157 158
 | texture          | Render with textures                         |

+ 7
- 0
include/Render.h Ver arquivo

@@ -232,6 +232,13 @@ public:
232 232
 
233 233
     void addSkeletalModel(SkeletalModel *mdl);
234 234
 
235
+    /*!
236
+     * \brief Show a texture for a second, for debugging
237
+     * \param textureId texture id to show
238
+     * \returns GL texture id on success, < 0 on error
239
+     */
240
+    int showTextureDebug(int textureId);
241
+
235 242
 private:
236 243
 
237 244
     /*!

+ 17
- 0
include/Texture.h Ver arquivo

@@ -231,6 +231,20 @@ public:
231 231
 
232 232
     void useMultiTexture(float aU, float aV, float bU, float bV);
233 233
 
234
+    /*!
235
+     * \brief Show a texture for a second, for debugging
236
+     * \param textureId texture id to show
237
+     * \returns GL texture id on success, < 0 on error
238
+     */
239
+    int showTextureDebug(int textureId);
240
+
241
+    /*!
242
+     * \brief Renders debug texture.
243
+     *
244
+     * Called in 2D mode from Texture::Display().
245
+     */
246
+    void debugTextureRender(int width, int height);
247
+
234 248
 private:
235 249
 
236 250
     int nextPower(int seed);
@@ -238,6 +252,9 @@ private:
238 252
     unsigned char *scaleBuffer(unsigned char *image, int width, int height,
239 253
                                 int components);
240 254
 
255
+    int textureDebug;
256
+    int textureDebugFrames;
257
+
241 258
     unsigned int *mTextureIds;  //!< GL texture list
242 259
     unsigned int mTextureCount; //!< Texture counter
243 260
     unsigned int mTextureLimit; //!< The texture limit

+ 3
- 3
src/CMakeLists.txt Ver arquivo

@@ -26,10 +26,10 @@ if (APPLE)
26 26
     set (MACOSX_BUNDLE_INFO_STRING "OpenSource TombRaider Game Engine")
27 27
     set (MACOSX_BUNDLE_ICON_FILE "AppIcon")
28 28
     set (MACOSX_BUNDLE_GUI_IDENTIFIER "de.xythobuz.OpenRaider")
29
-    set (MACOSX_BUNDLE_LONG_VERSION_STRING "${OpenRaider_VERSION_MAJOR}.${OpenRaider_VERSION_MINOR}.${OpenRaider_VERSION_MICRO}-${OpenRaider_VERSION_RELEASE}")
30 29
     set (MACOSX_BUNDLE_BUNDLE_NAME "OpenRaider")
31
-    set (MACOSX_BUNDLE_SHORT_VERSION_STRING "${OpenRaider_VERSION_MAJOR}.${OpenRaider_VERSION_MINOR}.${OpenRaider_VERSION_MICRO}-${OpenRaider_VERSION_RELEASE}")
32
-    set (MACOSX_BUNDLE_BUNDLE_VERSION "${OpenRaider_VERSION_MAJOR}.${OpenRaider_VERSION_MINOR}.${OpenRaider_VERSION_MICRO}-${OpenRaider_VERSION_RELEASE}")
30
+    set (MACOSX_BUNDLE_SHORT_VERSION_STRING "${OpenRaider_VERSION_MAJOR}.${OpenRaider_VERSION_MINOR}.${OpenRaider_VERSION_MICRO}${OpenRaider_VERSION_RELEASE}")
31
+    set (MACOSX_BUNDLE_LONG_VERSION_STRING "${OpenRaider_VERSION_MAJOR}.${OpenRaider_VERSION_MINOR}.${OpenRaider_VERSION_MICRO}${OpenRaider_VERSION_RELEASE} (${CMAKE_BUILD_TYPE})")
32
+    set (MACOSX_BUNDLE_BUNDLE_VERSION "${OpenRaider_VERSION_MAJOR}.${OpenRaider_VERSION_MINOR}.${OpenRaider_VERSION_MICRO}${OpenRaider_VERSION_RELEASE} (${CMAKE_BUILD_TYPE})")
33 33
     set (MACOSX_BUNDLE_COPYRIGHT "2001 - 2014")
34 34
 
35 35
     # Copy Icon

+ 8
- 0
src/OpenRaider.cpp Ver arquivo

@@ -2762,6 +2762,14 @@ void OpenRaider::consoleCommand(char *cmd)
2762 2762
     {
2763 2763
         m_mouseY = static_cast<float>(atof(cmd));
2764 2764
     }
2765
+    else if (rc_command("texture", cmd))
2766
+    {
2767
+        int error, tex = atoi(cmd);
2768
+        if ((error = m_render.showTextureDebug(tex)) < 0)
2769
+            print(false, "Could not load texture %d (%d)!", tex, error);
2770
+        else
2771
+            print(false, "Displaying texture %d in %d...", tex, error);
2772
+    }
2765 2773
     else if (rc_command("r_pigtails", cmd))
2766 2774
     {
2767 2775
         if (gLaraModel)

+ 7
- 0
src/Render.cpp Ver arquivo

@@ -161,6 +161,12 @@ void Render::screenShot(char *filenameBase)
161 161
 // Public Mutators
162 162
 ////////////////////////////////////////////////////////////
163 163
 
164
+
165
+int Render::showTextureDebug(int textureId) {
166
+    return mTexture.showTextureDebug(textureId);
167
+}
168
+
169
+
164 170
 void Render::addRoom(RenderRoom *room)
165 171
 {
166 172
     mRooms.pushBack(room);
@@ -959,6 +965,7 @@ void Render::Display()
959 965
     glEnterMode2d(mWidth, mHeight);
960 966
     glColor3fv(OR_BLUE);
961 967
     mString.Render();
968
+    mTexture.debugTextureRender(mWidth, mHeight);
962 969
     glExitMode2d();
963 970
 
964 971
 #ifdef USING_EMITTER

+ 45
- 10
src/Texture.cpp Ver arquivo

@@ -44,6 +44,8 @@ Texture::Texture()
44 44
     //gTextureManager = this;
45 45
 
46 46
     initSDL_TTF();
47
+
48
+    textureDebug = -1;
47 49
 }
48 50
 
49 51
 
@@ -210,6 +212,42 @@ void glPrint3d(float x, float y, float z,
210 212
 }
211 213
 
212 214
 
215
+int Texture::showTextureDebug(int textureId) {
216
+    if (textureId >= getTextureCount())
217
+        return -1;
218
+
219
+    textureDebug = textureId;
220
+    textureDebugFrames = 100;
221
+
222
+    return mTextureIds[textureId];
223
+}
224
+
225
+
226
+void Texture::debugTextureRender(int width, int height) {
227
+    int xMin, xMax, yMin, yMax;
228
+
229
+    xMin = yMin = 0;
230
+    xMax = width;
231
+    yMax = height;
232
+
233
+    if ((textureDebug >= 0) && (textureDebugFrames > 0)) {
234
+        glColor3f(1, 1, 1);
235
+        bindTextureId(textureDebug);
236
+
237
+        // Draw a textured quad
238
+        glBegin(GL_QUADS);
239
+        glTexCoord2f(0, 0); glVertex3f(xMin, yMin, 0);
240
+        glTexCoord2f(0, 1); glVertex3f(xMin, yMax, 0);
241
+        glTexCoord2f(1, 1); glVertex3f(xMax, yMax, 0);
242
+        glTexCoord2f(1, 0); glVertex3f(xMax, yMin, 0);
243
+
244
+        glEnd();
245
+
246
+        textureDebugFrames--;
247
+    }
248
+}
249
+
250
+
213 251
 int Texture::loadFontTTF(const char *filename,
214 252
         unsigned int utf8Offset, unsigned int count)
215 253
 {
@@ -653,7 +691,13 @@ void convertARGB32bppToRGBA32bpp(unsigned char *image,
653 691
     }
654 692
 }
655 693
 
656
-GLint deprecated_gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
694
+// http://mmmovania.blogspot.de/2011/01/opengl-30-and-above-deprecated-func-and.html
695
+// http://www.g-truc.net/post-0256.html
696
+GLint deprecated_gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data) {
697
+    glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
698
+    glTexImage2D(target, 0, internalFormat, width, height, 0, format, type, data);
699
+    return 0;
700
+}
657 701
 
658 702
 int Texture::loadBufferSlot(unsigned char *image,
659 703
         unsigned int width, unsigned int height,
@@ -758,15 +802,6 @@ int Texture::loadBufferSlot(unsigned char *image,
758 802
 }
759 803
 
760 804
 
761
-// http://mmmovania.blogspot.de/2011/01/opengl-30-and-above-deprecated-func-and.html
762
-// http://www.g-truc.net/post-0256.html
763
-GLint deprecated_gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data) {
764
-    glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
765
-    glTexImage2D(target, 0, internalFormat, width, height, 0, format, type, data);
766
-    return 0;
767
-}
768
-
769
-
770 805
 void Texture::bindTextureId(unsigned int n)
771 806
 {
772 807
     if ((int)n == mTextureId || !mTextureIds || n > mTextureCount)

Carregando…
Cancelar
Salvar