diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-11-17 15:57:31 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-11-17 15:57:31 +0000 |
commit | 8f28453987ab0d38897be6d0cbbfa0d3d0eb05d9 (patch) | |
tree | eb846af5fb6af159ad2452da9a46081838dad135 /src/glu/sgi | |
parent | a4806c994e796f06675ebf8860fafc3dffe9ed05 (diff) |
fix some gluBuild2DMipmap bugs (Greg McGarragh)
Diffstat (limited to 'src/glu/sgi')
-rw-r--r-- | src/glu/sgi/libutil/mipmap.c | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/glu/sgi/libutil/mipmap.c b/src/glu/sgi/libutil/mipmap.c index 5c28c858ec..5a622767ff 100644 --- a/src/glu/sgi/libutil/mipmap.c +++ b/src/glu/sgi/libutil/mipmap.c @@ -377,6 +377,7 @@ static void halveImage_ubyte(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLubyte *s; const char *t; @@ -390,6 +391,7 @@ static void halveImage_ubyte(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -405,6 +407,7 @@ static void halveImage_ubyte(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -476,6 +479,7 @@ static void halveImage_byte(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLbyte *s; const char *t; @@ -489,6 +493,7 @@ static void halveImage_byte(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -504,6 +509,7 @@ static void halveImage_byte(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -573,6 +579,7 @@ static void halveImage_ushort(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLushort *s; const char *t; @@ -586,6 +593,7 @@ static void halveImage_ushort(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -602,6 +610,7 @@ static void halveImage_ushort(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } else @@ -616,6 +625,7 @@ static void halveImage_ushort(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -708,6 +718,7 @@ static void halveImage_short(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLshort *s; const char *t; @@ -721,6 +732,7 @@ static void halveImage_short(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -737,6 +749,7 @@ static void halveImage_short(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } else @@ -758,6 +771,7 @@ static void halveImage_short(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -850,6 +864,7 @@ static void halveImage_uint(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLuint *s; const char *t; @@ -863,6 +878,7 @@ static void halveImage_uint(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -881,6 +897,7 @@ static void halveImage_uint(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } else @@ -899,6 +916,7 @@ static void halveImage_uint(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -990,6 +1008,7 @@ static void halveImage_int(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLint *s; const char *t; @@ -1003,6 +1022,7 @@ static void halveImage_int(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -1019,6 +1039,7 @@ static void halveImage_int(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } else @@ -1041,6 +1062,7 @@ static void halveImage_int(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -1134,6 +1156,7 @@ static void halveImage_float(GLint components, GLuint width, GLuint height, { int i, j, k; int newwidth, newheight; + int padBytes; GLfloat *s; const char *t; @@ -1147,6 +1170,7 @@ static void halveImage_float(GLint components, GLuint width, GLuint height, newwidth = width / 2; newheight = height / 2; + padBytes = ysize - (width*group_size); s = dataout; t = (const char *)datain; @@ -1163,6 +1187,7 @@ static void halveImage_float(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } else @@ -1183,6 +1208,7 @@ static void halveImage_float(GLint components, GLuint width, GLuint height, } t += group_size; } + t += padBytes; t += ysize; } } @@ -3837,7 +3863,10 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); +#if 0 + /* don't change ROW_LENGTH until the non-power-of-two path below */ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); +#endif level = userLevel; @@ -4086,6 +4115,10 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, /* level userLevel+1 is in srcImage; level userLevel already saved */ level = userLevel+1; } else { /* user's image is *not* nice power-of-2 sized square */ +#if 1 + /* see above */ + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); +#endif memreq = image_size(newwidth, newheight, format, type); switch(type) { case GL_UNSIGNED_BYTE: @@ -8643,7 +8676,8 @@ static void halveImageSlice(int components, int halfHeight= height / 2; int halfDepth= depth / 2; const char *src= (const char *)dataIn; - int padBytes= rowSizeInBytes - (width * groupSizeInBytes); + int rowPadBytes= rowSizeInBytes - (width * groupSizeInBytes); + int imagePadBytes= imageSizeInBytes - (width*height*groupSizeInBytes); int outIndex= 0; assert((width == 1 || height == 1) && depth >= 2); @@ -8727,7 +8761,7 @@ static void halveImageSlice(int components, /* skip over to next horizontal square of 4 */ src+= groupSizeInBytes; } /* for jj */ - src+= padBytes; + src+= rowPadBytes; src+= rowSizeInBytes; } /* for ii */ @@ -8772,11 +8806,12 @@ static void halveImageSlice(int components, src+= elementSizeInBytes; } /* for cc */ - src+= padBytes; + src+= rowPadBytes; /* skip over to next vertical square of 4 */ src+= rowSizeInBytes; } /* for jj */ + src+= imagePadBytes; src+= imageSizeInBytes; } /* for ii */ @@ -8816,7 +8851,8 @@ static void halveImage3D(int components, int halfHeight= height / 2; int halfDepth= depth / 2; const char *src= (const char *) dataIn; - int padBytes= rowSizeInBytes - (width*groupSizeInBytes); + int rowPadBytes= rowSizeInBytes - (width*groupSizeInBytes); + int imagePadBytes= imageSizeInBytes - (width*height*groupSizeInBytes); int outIndex= 0; for (dd= 0; dd < halfDepth; dd++) { @@ -8872,7 +8908,7 @@ static void halveImage3D(int components, src+= groupSizeInBytes; } /* for jj */ /* skip past pad bytes, if any, to get to next row */ - src+= padBytes; + src+= rowPadBytes; /* src is at beginning of a row here, but it's the second row of * the square block of 4 pixels that we just worked on so we @@ -8887,6 +8923,9 @@ static void halveImage3D(int components, src+= rowSizeInBytes; } /* for ii */ + /* skip past pad bytes, if any, to get to next image */ + src+= imagePadBytes; + src+= imageSizeInBytes; } /* for dd */ |