From c02132400923628040b1fd3952b8428c832ec143 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 7 Jul 2009 06:34:07 +0000 Subject: [PATCH] Fixed non-square dds images. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3242 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/client/image.c b/engine/client/image.c index 0e1e356f8..5620629c5 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -1827,6 +1827,7 @@ int GL_LoadTextureDDS(unsigned char *buffer, int filesize) int datasize; int intfmt; int pad; + unsigned int w, h; ddsheader fmtheader; if (*(int*)buffer != *(int*)"DDS ") @@ -1873,7 +1874,13 @@ int GL_LoadTextureDDS(unsigned char *buffer, int filesize) // (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); if (datasize < pad) datasize = pad; - qglCompressedTexImage2DARB(GL_TEXTURE_2D, mipnum, intfmt, fmtheader.dwWidth>>mipnum, fmtheader.dwHeight>>mipnum, 0, datasize, buffer); + w = fmtheader.dwWidth>>mipnum; + if (w < 1) + w = 1; + h = fmtheader.dwHeight>>mipnum; + if (h < 1) + h = 1; + qglCompressedTexImage2DARB(GL_TEXTURE_2D, mipnum, intfmt, w, h, 0, datasize, buffer); if (qglGetError()) Con_Printf("Incompatible dds file (mip %i)\n", mipnum); buffer += datasize;