summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenton Woods <denton.woods@gmail.com>2017-01-02 12:48:33 -0600
committerDenton Woods <denton.woods@gmail.com>2017-01-02 12:48:33 -0600
commit978bcfd9a0f4d68bbd0219ebd0c0a6b10c1a89ff (patch)
treea6919a555ad059bac83eb02644a1ac6ca615a6b3
parenta2d9193fed0c7f93519c0c4c28b3348e0cb5759b (diff)
downloaddevil-978bcfd9a0f4d68bbd0219ebd0c0a6b10c1a89ff.tar.gz
- Added half type support to KTX reading
-rw-r--r--DevIL/TODO12
-rw-r--r--DevIL/cmake/cmake_build.bat2
-rw-r--r--DevIL/src-IL/src/il_ktx.cpp60
3 files changed, 53 insertions, 21 deletions
diff --git a/DevIL/TODO b/DevIL/TODO
index f830e6c6..a4229e77 100644
--- a/DevIL/TODO
+++ b/DevIL/TODO
@@ -9,6 +9,16 @@ Bugs:
- Conversion to IL_ALPHA can be flipped?
+File formats:
+
+
+Interfaces:
+- Newer DirectX
+- Newer OpenGL
+- Newer Windows
+- Vulkan
+
+
By next release:
- https://www.cvedetails.com/vulnerability-list/vendor_id-8981/product_id-15876/version_id-67926/Devil-Developers-Image-Library-1.7.4.html
@@ -28,6 +38,7 @@ By next release:
Easier:
+- PAM file format (http://netpbm.sourceforge.net/doc/pam.html)
- Find out what is different in the VTF headers that are 64 bytes.
- Make DXT1 decompression function that does not do alpha.
- Implement ilIsValid calls for ROT.
@@ -170,6 +181,7 @@ More involved:
Lots of work:
- Go through forks on GitHub to see what needs to be included in the main release
- Thread safe version: look at https://github.com/gscept/DevIL/commit/a8bbbb934344237c362a15164b536f97f54d2cd8
+- Half precision floating point type
- Linux Unicode support is partially broken.
- Write own .exr routines.
- Native WDP support
diff --git a/DevIL/cmake/cmake_build.bat b/DevIL/cmake/cmake_build.bat
index a6ed402a..caceb8b4 100644
--- a/DevIL/cmake/cmake_build.bat
+++ b/DevIL/cmake/cmake_build.bat
@@ -1,5 +1,7 @@
rem @echo off
+cd ..
+
rem BUILD 1 - 32-BIT ANSI
rem =====================
diff --git a/DevIL/src-IL/src/il_ktx.cpp b/DevIL/src-IL/src/il_ktx.cpp
index 130c01aa..c8890aa3 100644
--- a/DevIL/src-IL/src/il_ktx.cpp
+++ b/DevIL/src-IL/src/il_ktx.cpp
@@ -57,6 +57,7 @@ typedef struct KTX_HEAD
//#define I_GL_3_BYTES 0x1408
//#define I_GL_4_BYTES 0x1409
#define I_GL_DOUBLE 0x140A
+#define I_GL_HALF 0x140B
#define I_GL_ALPHA 0x1906
#define I_GL_RGB 0x1907
#define I_GL_RGBA 0x1908
@@ -169,8 +170,8 @@ ILboolean iLoadKtxInternal()
{
KTX_HEAD Header;
ILuint imageSize;
- ILenum Format;
- ILubyte Bpp;
+ ILenum Format, Type;
+ ILubyte Bpp, Bpc;
char FileIdentifier[12] = {
//0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
'«', 'K', 'T', 'X', ' ', '1', '1', '»', '\r', '\n', '\x1A', '\n'
@@ -207,11 +208,13 @@ ILboolean iLoadKtxInternal()
return IL_FALSE;
}
//@TODO: Additional types
- if (Header.glType != I_GL_UNSIGNED_BYTE || Header.glTypeSize != 1) {
+ //@TODO: Really needed with the switch statements below?
+ if ((Header.glType != I_GL_UNSIGNED_BYTE && Header.glType != I_GL_HALF) || Header.glTypeSize != 1) {
ilSetError(IL_ILLEGAL_FILE_VALUE);
return IL_FALSE;
}
//@TODO: Additional formats
+ //@TODO: Really needed with the switch statements below?
if (Header.glFormat <= I_GL_ALPHA || Header.glFormat >= I_GL_LUMINANCE_ALPHA || Header.glInternalFormat != Header.glFormat /*|| Header.glBaseInternalFormat != Header.glFormat*/) {
ilSetError(IL_ILLEGAL_FILE_VALUE);
return IL_FALSE;
@@ -226,42 +229,57 @@ ILboolean iLoadKtxInternal()
if (iseek(Header.bytesOfKeyValueData, IL_SEEK_CUR))
return IL_FALSE;
- switch (Header.glFormat)
+ switch (Header.glType)
{
- case I_GL_LUMINANCE:
- Bpp = 1;
- Format = IL_LUMINANCE;
- break;
- case IL_LUMINANCE_ALPHA:
- Bpp = 2;
- Format = IL_LUMINANCE_ALPHA;
- break;
- case I_GL_RGB:
- Bpp = 3;
- Format = IL_RGB;
+ case I_GL_UNSIGNED_BYTE:
+ Bpc = 1;
+ Type = IL_UNSIGNED_BYTE;
break;
- case I_GL_RGBA:
- Bpp = 4;
- Format = IL_RGBA;
+ case I_GL_HALF:
+ Bpc = 2;
+ Type = IL_HALF;
break;
default:
ilSetError(IL_ILLEGAL_FILE_VALUE);
return IL_FALSE;
}
+ switch (Header.glFormat)
+ {
+ case I_GL_LUMINANCE:
+ Bpp = 1;
+ Format = IL_LUMINANCE;
+ break;
+ case I_GL_LUMINANCE_ALPHA:
+ Bpp = 2;
+ Format = IL_LUMINANCE_ALPHA;
+ break;
+ case I_GL_RGB:
+ Bpp = 3;
+ Format = IL_RGB;
+ break;
+ case I_GL_RGBA:
+ Bpp = 4;
+ Format = IL_RGBA;
+ break;
+ default:
+ ilSetError(IL_ILLEGAL_FILE_VALUE);
+ return IL_FALSE;
+ }
+
//@TODO: More than just RGBA
- if (!ilTexImage(Header.pixelWidth, Header.pixelHeight, 1, Bpp, Format, IL_UNSIGNED_BYTE, NULL)) {
+ if (!ilTexImage(Header.pixelWidth, Header.pixelHeight, 1, Bpp, Format, Type, NULL)) {
return IL_FALSE;
}
iCurImage->Origin = IL_ORIGIN_UPPER_LEFT;
imageSize = GetLittleUInt();
- if (imageSize != Header.pixelWidth * Header.pixelHeight * Bpp) {
+ if (imageSize != Header.pixelWidth * Header.pixelHeight * Bpp * Bpc) {
ilSetError(IL_ILLEGAL_FILE_VALUE);
return IL_FALSE;
}
- if (iread(iCurImage->Data, Bpp, Header.pixelWidth * Header.pixelHeight) != Header.pixelWidth * Header.pixelHeight)
+ if (iread(iCurImage->Data, Bpp*Bpc, Header.pixelWidth * Header.pixelHeight) != Header.pixelWidth * Header.pixelHeight)
return IL_FALSE;
return ilFixImage();