~ubuntu-branches/ubuntu/jaunty/mesa/jaunty

« back to all changes in this revision

Viewing changes to progs/demos/gltc.h

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-04-03 12:42:06 UTC
  • mfrom: (1.2.16 upstream) (3.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20090403124206-0oo9dl0tcmd0qr38
Tags: 7.4-0ubuntu1
* New upstream release, merge from debian-experimental
  (LP: #330476, #347171, #349127)
* Drop 103_rs600_support.patch, included in this version.
* Drop 104_swrast_fbconfigs.patch, included in this version.
* Add 103_bump_965_texture_limit.diff. (LP: #146298)
* Add 104_fix_dri2_ext_tfp.diff. (LP: #324854)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * gltc: GL Texture Compression library.
3
 
 * Copyright (c) 2007 Nicolas Martyanoff <khaelin@gmail.com>
4
 
 *
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:
12
 
 *
13
 
 * The above copyright notice and this permission notice shall be 
14
 
 * included in all copies or substantial portions of the Software.
15
 
 *
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.
23
 
 */
24
 
 
25
 
#ifndef __GLTC_GLTC_H__
26
 
#define __GLTC_GLTC_H__
27
 
 
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
37
 
 
38
 
/* S3TC formats */
39
 
#define GLTC_HAS_DXT1C           1
40
 
#define GLTC_HAS_DXT1A           1
41
 
#define GLTC_HAS_DXT3            1
42
 
#define GLTC_HAS_DXT5            1
43
 
 
44
 
/* -------------------------------------------------------------------
45
 
 *  Known-size types.
46
 
 * ------------------------------------------------------------------- */
47
 
typedef unsigned char gltc_byte;
48
 
typedef unsigned short gltc_word;
49
 
typedef unsigned long gltc_dword;
50
 
 
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. */
60
 
 
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. */
66
 
 
67
 
/* -------------------------------------------------------------------
68
 
 *  File formats.
69
 
 * ------------------------------------------------------------------- */
70
 
#define GLTC_DDS 0 /*  The DirectDraw Surface format. */
71
 
 
72
 
/* -------------------------------------------------------------------
73
 
 *  Errors.
74
 
 * ------------------------------------------------------------------- */
75
 
#define GLTC_OK 0
76
 
#define GLTC_MEM 1
77
 
#define GLTC_NOSUP 2
78
 
#define GLTC_BADARG 3
79
 
#define GLTC_IO 4
80
 
#define GLTC_BADFILE 5
81
 
#define GLTC_COMP 6
82
 
 
83
 
const char* gltc_error_string(gltc_dword error);
84
 
 
85
 
void gltc_dlog(const char *filename, ...);
86
 
 
87
 
/* -------------------------------------------------------------------
88
 
 *  A mipmap level in an image.
89
 
 * ------------------------------------------------------------------- */
90
 
struct gltc_level {
91
 
   gltc_dword width;
92
 
   gltc_dword height;
93
 
   gltc_dword size;
94
 
 
95
 
   gltc_byte *data;
96
 
};
97
 
 
98
 
/* -------------------------------------------------------------------
99
 
 *  A generic image.
100
 
 * ------------------------------------------------------------------- */
101
 
struct gltc_image {
102
 
   gltc_dword format;
103
 
   struct gltc_level *mipmap;
104
 
   gltc_dword num_levels;
105
 
 
106
 
   void (*get_texel)(const struct gltc_image*, gltc_dword,
107
 
         gltc_dword, gltc_dword, gltc_byte[4]);
108
 
};
109
 
 
110
 
gltc_dword gltc_image_width(const struct gltc_image *img,
111
 
      gltc_dword level);
112
 
gltc_dword gltc_image_height(const struct gltc_image *img,
113
 
      gltc_dword level);
114
 
gltc_byte* gltc_image_data(const struct gltc_image *img,
115
 
      gltc_dword level);
116
 
gltc_dword gltc_image_size(const struct gltc_image *img,
117
 
      gltc_dword level);
118
 
gltc_dword gltc_image_num_levels(const struct gltc_image *img);
119
 
gltc_dword gltc_image_bpp(const struct gltc_image *img,
120
 
      gltc_dword level);
121
 
 
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);
125
 
 
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]);
128
 
 
129
 
gltc_dword gltc_image_convert(struct gltc_image *src,
130
 
      struct gltc_image *dst, gltc_dword format);
131
 
 
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);
136
 
 
137
 
gltc_dword gltc_has_format(gltc_dword format);
138
 
 
139
 
#endif