Subversion Repositories gelsvn

Rev

Rev 449 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 449 Rev 594
1
/**
1
/**
-
 
2
 * @file SOIL.h
-
 
3
 * @brief Simple OpenGL Image Library
-
 
4
 */
-
 
5
/**
2
	@mainpage SOIL
6
	@mainpage SOIL
3

7

4
	Jonathan Dummer
8
	Jonathan Dummer
5
	2007-07-26-10.36
9
	2007-07-26-10.36
6

10

7
	Simple OpenGL Image Library
11
	Simple OpenGL Image Library
8

12

9
	A tiny c library for uploading images as
13
	A tiny c library for uploading images as
10
	textures into OpenGL.  Also saving and
14
	textures into OpenGL.  Also saving and
11
	loading of images is supported.
15
	loading of images is supported.
12

16

13
	I'm using Sean's Tool Box image loader as a base:
17
	I'm using Sean's Tool Box image loader as a base:
14
	http://www.nothings.org/
18
	http://www.nothings.org/
15

19

16
	I'm upgrading it to load TGA and DDS files, and a direct
20
	I'm upgrading it to load TGA and DDS files, and a direct
17
	path for loading DDS files straight into OpenGL textures,
21
	path for loading DDS files straight into OpenGL textures,
18
	when applicable.
22
	when applicable.
19

23

20
	Image Formats:
24
	Image Formats:
21
	- BMP		load & save
25
	- BMP		load & save
22
	- TGA		load & save
26
	- TGA		load & save
23
	- DDS		load & save
27
	- DDS		load & save
24
	- PNG		load
28
	- PNG		load
25
	- JPG		load
29
	- JPG		load
26

30

27
	OpenGL Texture Features:
31
	OpenGL Texture Features:
28
	- resample to power-of-two sizes
32
	- resample to power-of-two sizes
29
	- MIPmap generation
33
	- MIPmap generation
30
	- compressed texture S3TC formats (if supported)
34
	- compressed texture S3TC formats (if supported)
31
	- can pre-multiply alpha for you, for better compositing
35
	- can pre-multiply alpha for you, for better compositing
32
	- can flip image about the y-axis (except pre-compressed DDS files)
36
	- can flip image about the y-axis (except pre-compressed DDS files)
33

37

34
	Thanks to:
38
	Thanks to:
35
	* Sean Barret - for the awesome stb_image
39
	* Sean Barret - for the awesome stb_image
36
	* Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts
40
	* Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts
37
	* everybody at gamedev.net
41
	* everybody at gamedev.net
38
**/
42
**/
39
 
43
 
40
#ifndef HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
44
#ifndef HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
41
#define HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
45
#define HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
42
 
46
 
43
#ifdef __cplusplus
47
#ifdef __cplusplus
44
extern "C" {
48
extern "C" {
45
#endif
49
#endif
46
 
50
 
47
/**
51
/**
48
	The format of images that may be loaded (force_channels).
52
	The format of images that may be loaded (force_channels).
49
	SOIL_LOAD_AUTO leaves the image in whatever format it was found.
53
	SOIL_LOAD_AUTO leaves the image in whatever format it was found.
50
	SOIL_LOAD_L forces the image to load as Luminous (greyscale)
54
	SOIL_LOAD_L forces the image to load as Luminous (greyscale)
51
	SOIL_LOAD_LA forces the image to load as Luminous with Alpha
55
	SOIL_LOAD_LA forces the image to load as Luminous with Alpha
52
	SOIL_LOAD_RGB forces the image to load as Red Green Blue
56
	SOIL_LOAD_RGB forces the image to load as Red Green Blue
53
	SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha
57
	SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha
54
**/
58
**/
55
enum
59
enum
56
{
60
{
57
	SOIL_LOAD_AUTO = 0,
61
	SOIL_LOAD_AUTO = 0,
58
	SOIL_LOAD_L = 1,
62
	SOIL_LOAD_L = 1,
59
	SOIL_LOAD_LA = 2,
63
	SOIL_LOAD_LA = 2,
60
	SOIL_LOAD_RGB = 3,
64
	SOIL_LOAD_RGB = 3,
61
	SOIL_LOAD_RGBA = 4
65
	SOIL_LOAD_RGBA = 4
62
};
66
};
63
 
67
 
64
/**
68
/**
65
	Passed in as reuse_texture_ID, will cause SOIL to
69
	Passed in as reuse_texture_ID, will cause SOIL to
66
	register a new texture ID using glGenTextures().
70
	register a new texture ID using glGenTextures().
67
	If the value passed into reuse_texture_ID > 0 then
71
	If the value passed into reuse_texture_ID > 0 then
68
	SOIL will just re-use that texture ID (great for
72
	SOIL will just re-use that texture ID (great for
69
	reloading image assets in-game!)
73
	reloading image assets in-game!)
70
**/
74
**/
71
enum
75
enum
72
{
76
{
73
	SOIL_CREATE_NEW_ID = 0
77
	SOIL_CREATE_NEW_ID = 0
74
};
78
};
75
 
79
 
76
/**
80
/**
77
	flags you can pass into SOIL_load_OGL_texture()
81
	flags you can pass into SOIL_load_OGL_texture()
78
	and SOIL_create_OGL_texture().
82
	and SOIL_create_OGL_texture().
79
	(note that if SOIL_FLAG_DDS_LOAD_DIRECT is used
83
	(note that if SOIL_FLAG_DDS_LOAD_DIRECT is used
80
	the rest of the flags with the exception of
84
	the rest of the flags with the exception of
81
	SOIL_FLAG_TEXTURE_REPEATS will be ignored while
85
	SOIL_FLAG_TEXTURE_REPEATS will be ignored while
82
	loading already-compressed DDS files.)
86
	loading already-compressed DDS files.)
83

87

84
	SOIL_FLAG_POWER_OF_TWO: force the image to be POT
88
	SOIL_FLAG_POWER_OF_TWO: force the image to be POT
85
	SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
89
	SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
86
	SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
90
	SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
87
	SOIL_FLAG_MULTIPLY_ALPHA: for using (GL_ONE,GL_ONE_MINUS_SRC_ALPHA) blending
91
	SOIL_FLAG_MULTIPLY_ALPHA: for using (GL_ONE,GL_ONE_MINUS_SRC_ALPHA) blending
88
	SOIL_FLAG_INVERT_Y: flip the image vertically
92
	SOIL_FLAG_INVERT_Y: flip the image vertically
89
	SOIL_FLAG_COMPRESS_TO_DXT: if the card can display them, will convert RGB to DXT1, RGBA to DXT5
93
	SOIL_FLAG_COMPRESS_TO_DXT: if the card can display them, will convert RGB to DXT1, RGBA to DXT5
90
	SOIL_FLAG_DDS_LOAD_DIRECT: will load DDS files directly without _ANY_ additional processing
94
	SOIL_FLAG_DDS_LOAD_DIRECT: will load DDS files directly without _ANY_ additional processing
91
	SOIL_FLAG_NTSC_SAFE_RGB: clamps RGB components to the range [16,235]
95
	SOIL_FLAG_NTSC_SAFE_RGB: clamps RGB components to the range [16,235]
92
	SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY
96
	SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY
93
	SOIL_FLAG_TEXTURE_RECTANGE: uses ARB_texture_rectangle ; pixel indexed & no repeat or MIPmaps or cubemaps
97
	SOIL_FLAG_TEXTURE_RECTANGE: uses ARB_texture_rectangle ; pixel indexed & no repeat or MIPmaps or cubemaps
94
**/
98
**/
95
enum
99
enum
96
{
100
{
97
	SOIL_FLAG_POWER_OF_TWO = 1,
101
	SOIL_FLAG_POWER_OF_TWO = 1,
98
	SOIL_FLAG_MIPMAPS = 2,
102
	SOIL_FLAG_MIPMAPS = 2,
99
	SOIL_FLAG_TEXTURE_REPEATS = 4,
103
	SOIL_FLAG_TEXTURE_REPEATS = 4,
100
	SOIL_FLAG_MULTIPLY_ALPHA = 8,
104
	SOIL_FLAG_MULTIPLY_ALPHA = 8,
101
	SOIL_FLAG_INVERT_Y = 16,
105
	SOIL_FLAG_INVERT_Y = 16,
102
	SOIL_FLAG_COMPRESS_TO_DXT = 32,
106
	SOIL_FLAG_COMPRESS_TO_DXT = 32,
103
	SOIL_FLAG_DDS_LOAD_DIRECT = 64,
107
	SOIL_FLAG_DDS_LOAD_DIRECT = 64,
104
	SOIL_FLAG_NTSC_SAFE_RGB = 128,
108
	SOIL_FLAG_NTSC_SAFE_RGB = 128,
105
	SOIL_FLAG_CoCg_Y = 256,
109
	SOIL_FLAG_CoCg_Y = 256,
106
	SOIL_FLAG_TEXTURE_RECTANGLE = 512
110
	SOIL_FLAG_TEXTURE_RECTANGLE = 512
107
};
111
};
108
 
112
 
109
/**
113
/**
110
	The types of images that may be saved.
114
	The types of images that may be saved.
111
	(TGA supports uncompressed RGB / RGBA)
115
	(TGA supports uncompressed RGB / RGBA)
112
	(BMP supports uncompressed RGB)
116
	(BMP supports uncompressed RGB)
113
	(DDS supports DXT1 and DXT5)
117
	(DDS supports DXT1 and DXT5)
114
**/
118
**/
115
enum
119
enum
116
{
120
{
117
	SOIL_SAVE_TYPE_TGA = 0,
121
	SOIL_SAVE_TYPE_TGA = 0,
118
	SOIL_SAVE_TYPE_BMP = 1,
122
	SOIL_SAVE_TYPE_BMP = 1,
119
	SOIL_SAVE_TYPE_DDS = 2
123
	SOIL_SAVE_TYPE_DDS = 2
120
};
124
};
121
 
125
 
122
/**
126
/**
123
	Defines the order of faces in a DDS cubemap.
127
	Defines the order of faces in a DDS cubemap.
124
	I recommend that you use the same order in single
128
	I recommend that you use the same order in single
125
	image cubemap files, so they will be interchangeable
129
	image cubemap files, so they will be interchangeable
126
	with DDS cubemaps when using SOIL.
130
	with DDS cubemaps when using SOIL.
127
**/
131
**/
128
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
132
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
129
 
133
 
130
/**
134
/**
131
	The types of internal fake HDR representations
135
	The types of internal fake HDR representations
132

136

133
	SOIL_HDR_RGBE:		RGB * pow( 2.0, A - 128.0 )
137
	SOIL_HDR_RGBE:		RGB * pow( 2.0, A - 128.0 )
134
	SOIL_HDR_RGBdivA:	RGB / A
138
	SOIL_HDR_RGBdivA:	RGB / A
135
	SOIL_HDR_RGBdivA2:	RGB / (A*A)
139
	SOIL_HDR_RGBdivA2:	RGB / (A*A)
136
**/
140
**/
137
enum
141
enum
138
{
142
{
139
	SOIL_HDR_RGBE = 0,
143
	SOIL_HDR_RGBE = 0,
140
	SOIL_HDR_RGBdivA = 1,
144
	SOIL_HDR_RGBdivA = 1,
141
	SOIL_HDR_RGBdivA2 = 2
145
	SOIL_HDR_RGBdivA2 = 2
142
};
146
};
143
 
147
 
144
/**
148
/**
145
	Loads an image from disk into an OpenGL texture.
149
	Loads an image from disk into an OpenGL texture.
146
	\param filename the name of the file to upload as a texture
150
	\param filename the name of the file to upload as a texture
147
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
151
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
148
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
152
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
149
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
153
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
150
	\return 0-failed, otherwise returns the OpenGL texture handle
154
	\return 0-failed, otherwise returns the OpenGL texture handle
151
**/
155
**/
152
unsigned int
156
unsigned int
153
	SOIL_load_OGL_texture
157
	SOIL_load_OGL_texture
154
	(
158
	(
155
		const char *filename,
159
		const char *filename,
156
		int force_channels,
160
		int force_channels,
157
		unsigned int reuse_texture_ID,
161
		unsigned int reuse_texture_ID,
158
		unsigned int flags
162
		unsigned int flags
159
	);
163
	);
160
 
164
 
161
/**
165
/**
162
	Loads 6 images from disk into an OpenGL cubemap texture.
166
	Loads 6 images from disk into an OpenGL cubemap texture.
163
	\param x_pos_file the name of the file to upload as the +x cube face
167
	\param x_pos_file the name of the file to upload as the +x cube face
164
	\param x_neg_file the name of the file to upload as the -x cube face
168
	\param x_neg_file the name of the file to upload as the -x cube face
165
	\param y_pos_file the name of the file to upload as the +y cube face
169
	\param y_pos_file the name of the file to upload as the +y cube face
166
	\param y_neg_file the name of the file to upload as the -y cube face
170
	\param y_neg_file the name of the file to upload as the -y cube face
167
	\param z_pos_file the name of the file to upload as the +z cube face
171
	\param z_pos_file the name of the file to upload as the +z cube face
168
	\param z_neg_file the name of the file to upload as the -z cube face
172
	\param z_neg_file the name of the file to upload as the -z cube face
169
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
173
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
170
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
174
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
171
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
175
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
172
	\return 0-failed, otherwise returns the OpenGL texture handle
176
	\return 0-failed, otherwise returns the OpenGL texture handle
173
**/
177
**/
174
unsigned int
178
unsigned int
175
	SOIL_load_OGL_cubemap
179
	SOIL_load_OGL_cubemap
176
	(
180
	(
177
		const char *x_pos_file,
181
		const char *x_pos_file,
178
		const char *x_neg_file,
182
		const char *x_neg_file,
179
		const char *y_pos_file,
183
		const char *y_pos_file,
180
		const char *y_neg_file,
184
		const char *y_neg_file,
181
		const char *z_pos_file,
185
		const char *z_pos_file,
182
		const char *z_neg_file,
186
		const char *z_neg_file,
183
		int force_channels,
187
		int force_channels,
184
		unsigned int reuse_texture_ID,
188
		unsigned int reuse_texture_ID,
185
		unsigned int flags
189
		unsigned int flags
186
	);
190
	);
187
 
191
 
188
/**
192
/**
189
	Loads 1 image from disk and splits it into an OpenGL cubemap texture.
193
	Loads 1 image from disk and splits it into an OpenGL cubemap texture.
190
	\param filename the name of the file to upload as a texture
194
	\param filename the name of the file to upload as a texture
191
	\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
195
	\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
192
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
196
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
193
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
197
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
194
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
198
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
195
	\return 0-failed, otherwise returns the OpenGL texture handle
199
	\return 0-failed, otherwise returns the OpenGL texture handle
196
**/
200
**/
197
unsigned int
201
unsigned int
198
	SOIL_load_OGL_single_cubemap
202
	SOIL_load_OGL_single_cubemap
199
	(
203
	(
200
		const char *filename,
204
		const char *filename,
201
		const char face_order[6],
205
		const char face_order[6],
202
		int force_channels,
206
		int force_channels,
203
		unsigned int reuse_texture_ID,
207
		unsigned int reuse_texture_ID,
204
		unsigned int flags
208
		unsigned int flags
205
	);
209
	);
206
 
210
 
207
/**
211
/**
208
	Loads an HDR image from disk into an OpenGL texture.
212
	Loads an HDR image from disk into an OpenGL texture.
209
	\param filename the name of the file to upload as a texture
213
	\param filename the name of the file to upload as a texture
210
	\param fake_HDR_format SOIL_HDR_RGBE, SOIL_HDR_RGBdivA, SOIL_HDR_RGBdivA2
214
	\param fake_HDR_format SOIL_HDR_RGBE, SOIL_HDR_RGBdivA, SOIL_HDR_RGBdivA2
211
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
215
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
212
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
216
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
213
	\return 0-failed, otherwise returns the OpenGL texture handle
217
	\return 0-failed, otherwise returns the OpenGL texture handle
214
**/
218
**/
215
unsigned int
219
unsigned int
216
	SOIL_load_OGL_HDR_texture
220
	SOIL_load_OGL_HDR_texture
217
	(
221
	(
218
		const char *filename,
222
		const char *filename,
219
		int fake_HDR_format,
223
		int fake_HDR_format,
220
		int rescale_to_max,
224
		int rescale_to_max,
221
		unsigned int reuse_texture_ID,
225
		unsigned int reuse_texture_ID,
222
		unsigned int flags
226
		unsigned int flags
223
	);
227
	);
224
 
228
 
225
/**
229
/**
226
	Loads an image from RAM into an OpenGL texture.
230
	Loads an image from RAM into an OpenGL texture.
227
	\param buffer the image data in RAM just as if it were still in a file
231
	\param buffer the image data in RAM just as if it were still in a file
228
	\param buffer_length the size of the buffer in bytes
232
	\param buffer_length the size of the buffer in bytes
229
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
233
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
230
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
234
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
231
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
235
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
232
	\return 0-failed, otherwise returns the OpenGL texture handle
236
	\return 0-failed, otherwise returns the OpenGL texture handle
233
**/
237
**/
234
unsigned int
238
unsigned int
235
	SOIL_load_OGL_texture_from_memory
239
	SOIL_load_OGL_texture_from_memory
236
	(
240
	(
237
		const unsigned char *const buffer,
241
		const unsigned char *const buffer,
238
		int buffer_length,
242
		int buffer_length,
239
		int force_channels,
243
		int force_channels,
240
		unsigned int reuse_texture_ID,
244
		unsigned int reuse_texture_ID,
241
		unsigned int flags
245
		unsigned int flags
242
	);
246
	);
243
 
247
 
244
/**
248
/**
245
	Loads 6 images from memory into an OpenGL cubemap texture.
249
	Loads 6 images from memory into an OpenGL cubemap texture.
246
	\param x_pos_buffer the image data in RAM to upload as the +x cube face
250
	\param x_pos_buffer the image data in RAM to upload as the +x cube face
247
	\param x_pos_buffer_length the size of the above buffer
251
	\param x_pos_buffer_length the size of the above buffer
248
	\param x_neg_buffer the image data in RAM to upload as the +x cube face
252
	\param x_neg_buffer the image data in RAM to upload as the +x cube face
249
	\param x_neg_buffer_length the size of the above buffer
253
	\param x_neg_buffer_length the size of the above buffer
250
	\param y_pos_buffer the image data in RAM to upload as the +x cube face
254
	\param y_pos_buffer the image data in RAM to upload as the +x cube face
251
	\param y_pos_buffer_length the size of the above buffer
255
	\param y_pos_buffer_length the size of the above buffer
252
	\param y_neg_buffer the image data in RAM to upload as the +x cube face
256
	\param y_neg_buffer the image data in RAM to upload as the +x cube face
253
	\param y_neg_buffer_length the size of the above buffer
257
	\param y_neg_buffer_length the size of the above buffer
254
	\param z_pos_buffer the image data in RAM to upload as the +x cube face
258
	\param z_pos_buffer the image data in RAM to upload as the +x cube face
255
	\param z_pos_buffer_length the size of the above buffer
259
	\param z_pos_buffer_length the size of the above buffer
256
	\param z_neg_buffer the image data in RAM to upload as the +x cube face
260
	\param z_neg_buffer the image data in RAM to upload as the +x cube face
257
	\param z_neg_buffer_length the size of the above buffer
261
	\param z_neg_buffer_length the size of the above buffer
258
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
262
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
259
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
263
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
260
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
264
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
261
	\return 0-failed, otherwise returns the OpenGL texture handle
265
	\return 0-failed, otherwise returns the OpenGL texture handle
262
**/
266
**/
263
unsigned int
267
unsigned int
264
	SOIL_load_OGL_cubemap_from_memory
268
	SOIL_load_OGL_cubemap_from_memory
265
	(
269
	(
266
		const unsigned char *const x_pos_buffer,
270
		const unsigned char *const x_pos_buffer,
267
		int x_pos_buffer_length,
271
		int x_pos_buffer_length,
268
		const unsigned char *const x_neg_buffer,
272
		const unsigned char *const x_neg_buffer,
269
		int x_neg_buffer_length,
273
		int x_neg_buffer_length,
270
		const unsigned char *const y_pos_buffer,
274
		const unsigned char *const y_pos_buffer,
271
		int y_pos_buffer_length,
275
		int y_pos_buffer_length,
272
		const unsigned char *const y_neg_buffer,
276
		const unsigned char *const y_neg_buffer,
273
		int y_neg_buffer_length,
277
		int y_neg_buffer_length,
274
		const unsigned char *const z_pos_buffer,
278
		const unsigned char *const z_pos_buffer,
275
		int z_pos_buffer_length,
279
		int z_pos_buffer_length,
276
		const unsigned char *const z_neg_buffer,
280
		const unsigned char *const z_neg_buffer,
277
		int z_neg_buffer_length,
281
		int z_neg_buffer_length,
278
		int force_channels,
282
		int force_channels,
279
		unsigned int reuse_texture_ID,
283
		unsigned int reuse_texture_ID,
280
		unsigned int flags
284
		unsigned int flags
281
	);
285
	);
282
 
286
 
283
/**
287
/**
284
	Loads 1 image from RAM and splits it into an OpenGL cubemap texture.
288
	Loads 1 image from RAM and splits it into an OpenGL cubemap texture.
285
	\param buffer the image data in RAM just as if it were still in a file
289
	\param buffer the image data in RAM just as if it were still in a file
286
	\param buffer_length the size of the buffer in bytes
290
	\param buffer_length the size of the buffer in bytes
287
	\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
291
	\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
288
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
292
	\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
289
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
293
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
290
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
294
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
291
	\return 0-failed, otherwise returns the OpenGL texture handle
295
	\return 0-failed, otherwise returns the OpenGL texture handle
292
**/
296
**/
293
unsigned int
297
unsigned int
294
	SOIL_load_OGL_single_cubemap_from_memory
298
	SOIL_load_OGL_single_cubemap_from_memory
295
	(
299
	(
296
		const unsigned char *const buffer,
300
		const unsigned char *const buffer,
297
		int buffer_length,
301
		int buffer_length,
298
		const char face_order[6],
302
		const char face_order[6],
299
		int force_channels,
303
		int force_channels,
300
		unsigned int reuse_texture_ID,
304
		unsigned int reuse_texture_ID,
301
		unsigned int flags
305
		unsigned int flags
302
	);
306
	);
303
 
307
 
304
/**
308
/**
305
	Creates a 2D OpenGL texture from raw image data.  Note that the raw data is
309
	Creates a 2D OpenGL texture from raw image data.  Note that the raw data is
306
	_NOT_ freed after the upload (so the user can load various versions).
310
	_NOT_ freed after the upload (so the user can load various versions).
307
	\param data the raw data to be uploaded as an OpenGL texture
311
	\param data the raw data to be uploaded as an OpenGL texture
308
	\param width the width of the image in pixels
312
	\param width the width of the image in pixels
309
	\param height the height of the image in pixels
313
	\param height the height of the image in pixels
310
	\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
314
	\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
311
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
315
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
312
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
316
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
313
	\return 0-failed, otherwise returns the OpenGL texture handle
317
	\return 0-failed, otherwise returns the OpenGL texture handle
314
**/
318
**/
315
unsigned int
319
unsigned int
316
	SOIL_create_OGL_texture
320
	SOIL_create_OGL_texture
317
	(
321
	(
318
		const unsigned char *const data,
322
		const unsigned char *const data,
319
		int width, int height, int channels,
323
		int width, int height, int channels,
320
		unsigned int reuse_texture_ID,
324
		unsigned int reuse_texture_ID,
321
		unsigned int flags
325
		unsigned int flags
322
	);
326
	);
323
 
327
 
324
/**
328
/**
325
	Creates an OpenGL cubemap texture by splitting up 1 image into 6 parts.
329
	Creates an OpenGL cubemap texture by splitting up 1 image into 6 parts.
326
	\param data the raw data to be uploaded as an OpenGL texture
330
	\param data the raw data to be uploaded as an OpenGL texture
327
	\param width the width of the image in pixels
331
	\param width the width of the image in pixels
328
	\param height the height of the image in pixels
332
	\param height the height of the image in pixels
329
	\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
333
	\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
330
	\param face_order the order of the faces in the file, and combination of NSWEUD, for North, South, Up, etc.
334
	\param face_order the order of the faces in the file, and combination of NSWEUD, for North, South, Up, etc.
331
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
335
	\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
332
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
336
	\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
333
	\return 0-failed, otherwise returns the OpenGL texture handle
337
	\return 0-failed, otherwise returns the OpenGL texture handle
334
**/
338
**/
335
unsigned int
339
unsigned int
336
	SOIL_create_OGL_single_cubemap
340
	SOIL_create_OGL_single_cubemap
337
	(
341
	(
338
		const unsigned char *const data,
342
		const unsigned char *const data,
339
		int width, int height, int channels,
343
		int width, int height, int channels,
340
		const char face_order[6],
344
		const char face_order[6],
341
		unsigned int reuse_texture_ID,
345
		unsigned int reuse_texture_ID,
342
		unsigned int flags
346
		unsigned int flags
343
	);
347
	);
344
 
348
 
345
/**
349
/**
346
	Captures the OpenGL window (RGB) and saves it to disk
350
	Captures the OpenGL window (RGB) and saves it to disk
347
	\return 0 if it failed, otherwise returns 1
351
	\return 0 if it failed, otherwise returns 1
348
**/
352
**/
349
int
353
int
350
	SOIL_save_screenshot
354
	SOIL_save_screenshot
351
	(
355
	(
352
		const char *filename,
356
		const char *filename,
353
		int image_type,
357
		int image_type,
354
		int x, int y,
358
		int x, int y,
355
		int width, int height
359
		int width, int height
356
	);
360
	);
357
 
361
 
358
/**
362
/**
359
	Loads an image from disk into an array of unsigned chars.
363
	Loads an image from disk into an array of unsigned chars.
360
	Note that *channels return the original channel count of the
364
	Note that *channels return the original channel count of the
361
	image.  If force_channels was other than SOIL_LOAD_AUTO,
365
	image.  If force_channels was other than SOIL_LOAD_AUTO,
362
	the resulting image has force_channels, but *channels may be
366
	the resulting image has force_channels, but *channels may be
363
	different (if the original image had a different channel
367
	different (if the original image had a different channel
364
	count).
368
	count).
365
	\return 0 if failed, otherwise returns pointer to data
369
	\return 0 if failed, otherwise returns pointer to data
366
**/
370
**/
367
unsigned char*
371
unsigned char*
368
	SOIL_load_image
372
	SOIL_load_image
369
	(
373
	(
370
		const char *filename,
374
		const char *filename,
371
		int *width, int *height, int *channels,
375
		int *width, int *height, int *channels,
372
		int force_channels
376
		int force_channels
373
	);
377
	);
374
 
378
 
375
/**
379
/**
376
	Loads an HDR image from disk into an array of unsigned chars.
380
	Loads an HDR image from disk into an array of unsigned chars.
377
	Note that *channels return the original channel count of the
381
	Note that *channels return the original channel count of the
378
	image.  If force_channels was other than SOIL_LOAD_AUTO,
382
	image.  If force_channels was other than SOIL_LOAD_AUTO,
379
	the resulting image has force_channels, but *channels may be
383
	the resulting image has force_channels, but *channels may be
380
	different (if the original image had a different channel
384
	different (if the original image had a different channel
381
	count).
385
	count).
382
	\return 0 if failed, otherwise returns pointer to data
386
	\return 0 if failed, otherwise returns pointer to data
383
**/
387
**/
384
unsigned char*
388
unsigned char*
385
	SOIL_load_HDR_image
389
	SOIL_load_HDR_image
386
	(
390
	(
387
		const char *filename,
391
		const char *filename,
388
		int *width, int *height, int *channels,
392
		int *width, int *height, int *channels,
389
		int force_channels
393
		int force_channels
390
	);
394
	);
391
 
395
 
392
/**
396
/**
393
	Loads an image from memory into an array of unsigned chars.
397
	Loads an image from memory into an array of unsigned chars.
394
	Note that *channels return the original channel count of the
398
	Note that *channels return the original channel count of the
395
	image.  If force_channels was other than SOIL_LOAD_AUTO,
399
	image.  If force_channels was other than SOIL_LOAD_AUTO,
396
	the resulting image has force_channels, but *channels may be
400
	the resulting image has force_channels, but *channels may be
397
	different (if the original image had a different channel
401
	different (if the original image had a different channel
398
	count).
402
	count).
399
	\return 0 if failed, otherwise returns 1
403
	\return 0 if failed, otherwise returns 1
400
**/
404
**/
401
unsigned char*
405
unsigned char*
402
	SOIL_load_image_from_memory
406
	SOIL_load_image_from_memory
403
	(
407
	(
404
		const unsigned char *const buffer,
408
		const unsigned char *const buffer,
405
		int buffer_length,
409
		int buffer_length,
406
		int *width, int *height, int *channels,
410
		int *width, int *height, int *channels,
407
		int force_channels
411
		int force_channels
408
	);
412
	);
409
 
413
 
410
/**
414
/**
411
	Saves an image from an array of unsigned chars (RGBA) to disk
415
	Saves an image from an array of unsigned chars (RGBA) to disk
412
	\return 0 if failed, otherwise returns 1
416
	\return 0 if failed, otherwise returns 1
413
**/
417
**/
414
int
418
int
415
	SOIL_save_image
419
	SOIL_save_image
416
	(
420
	(
417
		const char *filename,
421
		const char *filename,
418
		int image_type,
422
		int image_type,
419
		int width, int height, int channels,
423
		int width, int height, int channels,
420
		const unsigned char *const data
424
		const unsigned char *const data
421
	);
425
	);
422
 
426
 
423
/**
427
/**
424
	Frees the image data (note, this is just C's "free()"...this function is
428
	Frees the image data (note, this is just C's "free()"...this function is
425
	present mostly so C++ programmers don't forget to use "free()" and call
429
	present mostly so C++ programmers don't forget to use "free()" and call
426
	"delete []" instead [8^)
430
	"delete []" instead [8^)
427
**/
431
**/
428
void
432
void
429
	SOIL_free_image_data
433
	SOIL_free_image_data
430
	(
434
	(
431
		unsigned char *img_data
435
		unsigned char *img_data
432
	);
436
	);
433
 
437
 
434
/**
438
/**
435
	This function resturn a pointer to a string describing the last thing
439
	This function resturn a pointer to a string describing the last thing
436
	that happened inside SOIL.  It can be used to determine why an image
440
	that happened inside SOIL.  It can be used to determine why an image
437
	failed to load.
441
	failed to load.
438
**/
442
**/
439
const char*
443
const char*
440
	SOIL_last_result
444
	SOIL_last_result
441
	(
445
	(
442
		void
446
		void
443
	);
447
	);
444
 
448
 
445
 
449
 
446
#ifdef __cplusplus
450
#ifdef __cplusplus
447
}
451
}
448
#endif
452
#endif
449
 
453
 
450
#endif /* HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY	*/
454
#endif /* HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY	*/
451
 
455