diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-10-25 16:54:16 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-10-25 16:54:16 +0400 |
commit | aab78de27cf070dac1d5b07120e871415d45687c (patch) | |
tree | 2da90c9d16f95b1303bbba239a993a46c3f37684 /source/blender/gpu/intern/gpu_draw.c | |
parent | 0405406280027b93d390f91047502fc53da20ebc (diff) |
Better fix for #32837: DDS compressed textures now no longer need to be flipped
when saving, rather we flip the compressed texture during load. The code used
here comes from the chromium O3D project:
http://src.chromium.org/chrome/trunk/o3d/core/cross/bitmap_dds.cc
Also made it only load compressed for power-of-two resolution images, it doesn't
seem to work for other resolutions, just falls back to non-compressed then.
Diffstat (limited to 'source/blender/gpu/intern/gpu_draw.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 96ba0bf0ec7..fd8dd562c02 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -730,12 +730,17 @@ int GPU_upload_dxt_texture(ImBuf *ibuf) return FALSE; } + if(!is_power_of_2_i(width) || !is_power_of_2_i(height)) { + printf("Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); + return FALSE; + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - blocksize = (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16; + blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16; for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) { if (width == 0) width = 1; |