Subversion Repositories gelsvn

Rev

Rev 594 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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

7

8
	Jonathan Dummer
8
	Jonathan Dummer
9
	2007-07-26-10.36
9
	2007-07-26-10.36
10

10

11
	Simple OpenGL Image Library
11
	Simple OpenGL Image Library
12

12

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

16

17
	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:
18
	http://www.nothings.org/
18
	http://www.nothings.org/
19

19

20
	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
21
	path for loading DDS files straight into OpenGL textures,
21
	path for loading DDS files straight into OpenGL textures,
22
	when applicable.
22
	when applicable.
23

23

24
	Image Formats:
24
	Image Formats:
25
	- BMP		load & save
25
	- BMP		load & save
26
	- TGA		load & save
26
	- TGA		load & save
27
	- DDS		load & save
27
	- DDS		load & save
28
	- PNG		load
28
	- PNG		load
29
	- JPG		load
29
	- JPG		load
30

30

31
	OpenGL Texture Features:
31
	OpenGL Texture Features:
32
	- resample to power-of-two sizes
32
	- resample to power-of-two sizes
33
	- MIPmap generation
33
	- MIPmap generation
34
	- compressed texture S3TC formats (if supported)
34
	- compressed texture S3TC formats (if supported)
35
	- can pre-multiply alpha for you, for better compositing
35
	- can pre-multiply alpha for you, for better compositing
36
	- 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)
37

37

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

87

88
	SOIL_FLAG_POWER_OF_TWO: force the image to be POT
88
	SOIL_FLAG_POWER_OF_TWO: force the image to be POT
89
	SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
89
	SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
90
	SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
90
	SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
91
	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
92
	SOIL_FLAG_INVERT_Y: flip the image vertically
92
	SOIL_FLAG_INVERT_Y: flip the image vertically
93
	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
94
	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
95
	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]
96
	SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY
96
	SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY
97
	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
98
**/
98
**/
99
enum
99
enum
100
{
100
{
101
	SOIL_FLAG_POWER_OF_TWO = 1,
101
	SOIL_FLAG_POWER_OF_TWO = 1,
102
	SOIL_FLAG_MIPMAPS = 2,
102
	SOIL_FLAG_MIPMAPS = 2,
103
	SOIL_FLAG_TEXTURE_REPEATS = 4,
103
	SOIL_FLAG_TEXTURE_REPEATS = 4,
104
	SOIL_FLAG_MULTIPLY_ALPHA = 8,
104
	SOIL_FLAG_MULTIPLY_ALPHA = 8,
105
	SOIL_FLAG_INVERT_Y = 16,
105
	SOIL_FLAG_INVERT_Y = 16,
106
	SOIL_FLAG_COMPRESS_TO_DXT = 32,
106
	SOIL_FLAG_COMPRESS_TO_DXT = 32,
107
	SOIL_FLAG_DDS_LOAD_DIRECT = 64,
107
	SOIL_FLAG_DDS_LOAD_DIRECT = 64,
108
	SOIL_FLAG_NTSC_SAFE_RGB = 128,
108
	SOIL_FLAG_NTSC_SAFE_RGB = 128,
109
	SOIL_FLAG_CoCg_Y = 256,
109
	SOIL_FLAG_CoCg_Y = 256,
110
	SOIL_FLAG_TEXTURE_RECTANGLE = 512
110
	SOIL_FLAG_TEXTURE_RECTANGLE = 512
111
};
111
};
112
 
112
 
113
/**
113
/**
114
	The types of images that may be saved.
114
	The types of images that may be saved.
115
	(TGA supports uncompressed RGB / RGBA)
115
	(TGA supports uncompressed RGB / RGBA)
116
	(BMP supports uncompressed RGB)
116
	(BMP supports uncompressed RGB)
117
	(DDS supports DXT1 and DXT5)
117
	(DDS supports DXT1 and DXT5)
118
**/
118
**/
119
enum
119
enum
120
{
120
{
121
	SOIL_SAVE_TYPE_TGA = 0,
121
	SOIL_SAVE_TYPE_TGA = 0,
122
	SOIL_SAVE_TYPE_BMP = 1,
122
	SOIL_SAVE_TYPE_BMP = 1,
123
	SOIL_SAVE_TYPE_DDS = 2
123
	SOIL_SAVE_TYPE_DDS = 2,
-
 
124
    SOIL_SAVE_TYPE_PNG = 3
124
};
125
};
125
 
126
 
126
/**
127
/**
127
	Defines the order of faces in a DDS cubemap.
128
	Defines the order of faces in a DDS cubemap.
128
	I recommend that you use the same order in single
129
	I recommend that you use the same order in single
129
	image cubemap files, so they will be interchangeable
130
	image cubemap files, so they will be interchangeable
130
	with DDS cubemaps when using SOIL.
131
	with DDS cubemaps when using SOIL.
131
**/
132
**/
132
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
133
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
133
 
134
 
134
/**
135
/**
135
	The types of internal fake HDR representations
136
	The types of internal fake HDR representations
136

137

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