Fix twiddling code. Fixes #37
This commit is contained in:
parent
2e33dc0718
commit
1e18fbc527
10
GL/texture.c
10
GL/texture.c
|
@ -940,15 +940,17 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
||||||
|
|
||||||
if(needsTwiddling) {
|
if(needsTwiddling) {
|
||||||
assert(type == GL_UNSIGNED_BYTE); // Anything else needs this loop adjusting
|
assert(type == GL_UNSIGNED_BYTE); // Anything else needs this loop adjusting
|
||||||
GLuint x, y, min, min2, mask;
|
GLuint x, y, min, mask;
|
||||||
|
|
||||||
|
GLubyte *pixels = (GLubyte*) data;
|
||||||
|
GLushort *vtex = (GLushort*) targetData;
|
||||||
|
|
||||||
min = MIN(w, h);
|
min = MIN(w, h);
|
||||||
min2 = min * min;
|
|
||||||
mask = min - 1;
|
mask = min - 1;
|
||||||
|
|
||||||
for(y = 0; y < h; y++) {
|
for(y = 0; y < h; y += 2) {
|
||||||
for(x = 0; x < w; x++) {
|
for(x = 0; x < w; x++) {
|
||||||
targetData[TWIDOUT(x & mask, y & mask) + (x / min + y / min) * min2] = ((GLubyte*) data)[y * w + x];
|
vtex[TWIDOUT((y & mask) / 2, x & mask) + (x / min + y / min)*min * min / 2] = pixels[y * w + x] | (pixels[(y + 1) * w + x] << 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user