2
* gltc: GL Texture Compression library.
3
* Copyright (c) 2007 Nicolas Martyanoff <khaelin@gmail.com>
5
* Permission is hereby granted, free of charge, to any person obtaining
6
* a copy of this software and associated documentation files (the
7
* "Software"), to deal in the Software without restriction, including
8
* without limitation the rights to use, copy, modify, merge, publish,
9
* distribute, sublicense, and/or sell copies of the Software, and to
10
* permit persons to whom the Software is furnished to do so, subject to
11
* the following conditions:
13
* The above copyright notice and this permission notice shall be
14
* included in all copies or substantial portions of the Software.
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
#ifndef __GLTC_GLTC_H__
26
#define __GLTC_GLTC_H__
28
/* -------------------------------------------------------------------
29
* The features supported by this version.
30
* ------------------------------------------------------------------- */
31
/* Uncompressed formats */
32
#define GLTC_HAS_A4_R4_G4_B4 1
33
#define GLTC_HAS_A1_R5_G5_B5 1
34
#define GLTC_HAS_R5_G6_B5 1
35
#define GLTC_HAS_R8_G8_B8 1
36
#define GLTC_HAS_A8_R8_G8_B8 1
39
#define GLTC_HAS_DXT1C 1
40
#define GLTC_HAS_DXT1A 1
41
#define GLTC_HAS_DXT3 1
42
#define GLTC_HAS_DXT5 1
44
/* -------------------------------------------------------------------
46
* ------------------------------------------------------------------- */
47
typedef unsigned char gltc_byte;
48
typedef unsigned short gltc_word;
49
typedef unsigned long gltc_dword;
51
/* -------------------------------------------------------------------
52
* Texture compression formats.
53
* ------------------------------------------------------------------- */
54
/* Raw uncompressed formats */
55
#define GLTC_A4_R4_G4_B4 0 /* 16 bits alpha uncompressed. */
56
#define GLTC_A1_R5_G5_B5 1 /* 16 bits alpha uncompressed. */
57
#define GLTC_R5_G6_B5 2 /* 16 bits alpha-less uncompressed. */
58
#define GLTC_R8_G8_B8 3 /* 24 bits uncompressed. */
59
#define GLTC_A8_R8_G8_B8 4 /* 32 bits alpha uncompressed. */
61
/* S3TC compressed formats */
62
#define GLTC_DXT1C 5 /* Alpha-less. */
63
#define GLTC_DXT1A 6 /* 1bit alpha. */
64
#define GLTC_DXT3 7 /* Direct alpha encoding. */
65
#define GLTC_DXT5 8 /* Interpolated alpha encoding. */
67
/* -------------------------------------------------------------------
69
* ------------------------------------------------------------------- */
70
#define GLTC_DDS 0 /* The DirectDraw Surface format. */
72
/* -------------------------------------------------------------------
74
* ------------------------------------------------------------------- */
80
#define GLTC_BADFILE 5
83
const char* gltc_error_string(gltc_dword error);
85
void gltc_dlog(const char *filename, ...);
87
/* -------------------------------------------------------------------
88
* A mipmap level in an image.
89
* ------------------------------------------------------------------- */
98
/* -------------------------------------------------------------------
100
* ------------------------------------------------------------------- */
103
struct gltc_level *mipmap;
104
gltc_dword num_levels;
106
void (*get_texel)(const struct gltc_image*, gltc_dword,
107
gltc_dword, gltc_dword, gltc_byte[4]);
110
gltc_dword gltc_image_width(const struct gltc_image *img,
112
gltc_dword gltc_image_height(const struct gltc_image *img,
114
gltc_byte* gltc_image_data(const struct gltc_image *img,
116
gltc_dword gltc_image_size(const struct gltc_image *img,
118
gltc_dword gltc_image_num_levels(const struct gltc_image *img);
119
gltc_dword gltc_image_bpp(const struct gltc_image *img,
122
gltc_dword gltc_image_create(struct gltc_image *img, gltc_dword format,
123
gltc_dword width, gltc_dword height, gltc_dword num_levels);
124
void gltc_image_delete(struct gltc_image *img);
126
void gltc_image_get_texel(const struct gltc_image *img,
127
gltc_dword level, gltc_dword x, gltc_dword y, gltc_byte col[4]);
129
gltc_dword gltc_image_convert(struct gltc_image *src,
130
struct gltc_image *dst, gltc_dword format);
132
gltc_dword gltc_file_load(const char *filename,
133
struct gltc_image *img, gltc_dword format);
134
gltc_dword gltc_file_save(const char *filename,
135
const struct gltc_image *img, gltc_dword format);
137
gltc_dword gltc_has_format(gltc_dword format);