Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-06-30 08:34:34 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-06-30 08:34:34 +0400
commit436f02ab9cdf58d8b68f124be0d974a5de0d9308 (patch)
tree55394116b8e2a7c84899e389acda1e725c61a744 /source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
parent2d7efed014539e5b7193f9a73ccfa61ea3ed0838 (diff)
Finally committing support for compressed textures on the GPU (DDS+DXT). This patch started out as a patch by me, then cleaned up by Kupoman during his work on Cucumber.
One important thing to keep in mind when using this feature is that you'll need to flip your textures vertically (both the GIMP and Photoshop DDS tools I've seen have support for this on export). This is a quirk in using a texture format originally made for DirectX/DirectDraw, and flipping the compressed data is a real headache. Another quick fix for this issue is to change the Y value for the Size in the Mapping panel in the Texture properties to -1 (default is 1).
Diffstat (limited to 'source/blender/imbuf/intern/dds/DirectDrawSurface.cpp')
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 438988fbe48..82f355e1bb2 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -1016,6 +1016,10 @@ uint DirectDrawSurface::mipmapCount() const
else return 1;
}
+uint DirectDrawSurface::fourCC() const
+{
+ return header.pf.fourcc;
+}
uint DirectDrawSurface::width() const
{
@@ -1131,6 +1135,29 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap)
}
}
+// It was easier to copy this function from upstream than to resync.
+// This should be removed if a resync ever occurs.
+void* DirectDrawSurface::readData(uint &rsize)
+{
+ uint header_size = 128; // sizeof(DDSHeader);
+ if (header.hasDX10Header())
+ {
+ header_size += 20; // sizeof(DDSHeader10);
+ }
+
+ uint size = stream.size - header_size;
+ rsize = size;
+
+ unsigned char *data = new unsigned char[size];
+
+ stream.seek(header_size);
+ mem_read(stream, data, size);
+
+ // Maybe check if size == rsize? assert() isn't in this scope...
+
+ return data;
+}
+
void DirectDrawSurface::readLinearImage(Image * img)
{