|
@@ -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)
|