All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ktxint.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 /* Define this to include the ETC unpack software in the library. */
6 #ifndef SUPPORT_SOFTWARE_ETC_UNPACK
7 //#define SUPPORT_SOFTWARE_ETC_UNPACK 1
8 #endif
9 
10 #ifdef __cplusplus
11 
12 #endif
13 
14 
15 #define KTX_IDENTIFIER_REF { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }
16 #define KTX_ENDIAN_REF (0x04030201)
17 #define KTX_ENDIAN_REF_REV (0x01020304)
18 #define KTX_HEADER_SIZE (64)
19 
27 typedef struct KTX_header_t {
28  khronos_uint8_t identifier[12];
29  khronos_uint32_t endianness;
30  khronos_uint32_t glType;
31  khronos_uint32_t glTypeSize;
32  khronos_uint32_t glFormat;
33  khronos_uint32_t glInternalFormat;
34  khronos_uint32_t glBaseInternalFormat;
35  khronos_uint32_t pixelWidth;
36  khronos_uint32_t pixelHeight;
37  khronos_uint32_t pixelDepth;
38  khronos_uint32_t numberOfArrayElements;
39  khronos_uint32_t numberOfFaces;
40  khronos_uint32_t numberOfMipmapLevels;
41  khronos_uint32_t bytesOfKeyValueData;
42 } KTX_header;
43 
44 /* This will cause compilation to fail if the struct size doesn't match */
45 typedef int KTX_header_SIZE_ASSERT [sizeof(KTX_header) == KTX_HEADER_SIZE];
46 
53 typedef struct KTX_texinfo_t {
54  /* Data filled in by _ktxCheckHeader() */
55  khronos_uint32_t textureDimensions;
56  khronos_uint32_t glTarget;
57  khronos_uint32_t compressed;
58  khronos_uint32_t generateMipmaps;
59 } KTX_texinfo;
60 
61 #ifndef GL_TEXTURE_1D
62 #define GL_TEXTURE_1D 0x0DE0
63 #endif
64 #ifndef GL_TEXTURE_3D
65 #define GL_TEXTURE_3D 0x806F
66 #endif
67 #ifndef GL_TEXTURE_CUBE_MAP
68 #define GL_TEXTURE_CUBE_MAP 0x8513
69 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
70 #endif
71 /* from GL_EXT_texture_array */
72 #ifndef GL_TEXTURE_1D_ARRAY_EXT
73 #define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
74 #define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
75 #endif
76 #ifndef GL_GENERATE_MIPMAP
77 #define GL_GENERATE_MIPMAP 0x8191
78 #endif
79 
80 #ifndef GL_UNSIGNED_SHORT_5_6_5
81 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
82 #endif
83 #ifndef GL_UNSIGNED_SHORT_4_4_4_4
84 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
85 #endif
86 #ifndef GL_UNSIGNED_SHORT_5_5_5_1
87 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
88 #endif
89 
90 #ifndef GL_ETC1_RGB8_OES
91 #define GL_ETC1_RGB8_OES 0x8D64
92 #endif
93 
94 
95 #ifndef MAX
96 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
97 #endif
98 
99 /* CheckHeader
100  *
101  * Reads the KTX file header and performs some sanity checking on the values
102  */
103 KTX_error_code _ktxCheckHeader(KTX_header* header, KTX_texinfo* texinfo);
104 
105 /*
106  * SwapEndian16: Swaps endianness in an array of 16-bit values
107  */
108 void _ktxSwapEndian16(khronos_uint16_t* pData16, int count);
109 
110 /*
111  * SwapEndian32: Swaps endianness in an array of 32-bit values
112  */
113 void _ktxSwapEndian32(khronos_uint32_t* pData32, int count);
114 
115 /*
116  * UncompressETC: uncompresses an ETC compressed texture image
117  */
118 KTX_error_code _ktxUnpackETC(const GLubyte *srcETC, GLubyte **dstImage,
119  khronos_uint32_t active_width,
120  khronos_uint32_t active_height);
121 
122 #ifdef __cplusplus
123 // }
124 #endif
125