369 |
jab |
1 |
/**
|
594 |
jab |
2 |
* @file SOIL.h
|
|
|
3 |
* @brief Simple OpenGL Image Library
|
|
|
4 |
*/
|
|
|
5 |
/**
|
369 |
jab |
6 |
@mainpage SOIL
|
|
|
7 |
|
|
|
8 |
Jonathan Dummer
|
|
|
9 |
2007-07-26-10.36
|
|
|
10 |
|
|
|
11 |
Simple OpenGL Image Library
|
|
|
12 |
|
|
|
13 |
A tiny c library for uploading images as
|
|
|
14 |
textures into OpenGL. Also saving and
|
|
|
15 |
loading of images is supported.
|
|
|
16 |
|
|
|
17 |
I'm using Sean's Tool Box image loader as a base:
|
|
|
18 |
http://www.nothings.org/
|
|
|
19 |
|
|
|
20 |
I'm upgrading it to load TGA and DDS files, and a direct
|
|
|
21 |
path for loading DDS files straight into OpenGL textures,
|
|
|
22 |
when applicable.
|
|
|
23 |
|
|
|
24 |
Image Formats:
|
|
|
25 |
- BMP load & save
|
|
|
26 |
- TGA load & save
|
|
|
27 |
- DDS load & save
|
|
|
28 |
- PNG load
|
|
|
29 |
- JPG load
|
|
|
30 |
|
|
|
31 |
OpenGL Texture Features:
|
|
|
32 |
- resample to power-of-two sizes
|
|
|
33 |
- MIPmap generation
|
|
|
34 |
- compressed texture S3TC formats (if supported)
|
|
|
35 |
- can pre-multiply alpha for you, for better compositing
|
|
|
36 |
- can flip image about the y-axis (except pre-compressed DDS files)
|
|
|
37 |
|
|
|
38 |
Thanks to:
|
|
|
39 |
* Sean Barret - for the awesome stb_image
|
|
|
40 |
* Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts
|
|
|
41 |
* everybody at gamedev.net
|
|
|
42 |
**/
|
|
|
43 |
|
|
|
44 |
#ifndef HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
|
|
|
45 |
#define HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
|
|
|
46 |
|
|
|
47 |
#ifdef __cplusplus
|
|
|
48 |
extern "C" {
|
|
|
49 |
#endif
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
The format of images that may be loaded (force_channels).
|
|
|
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)
|
|
|
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
|
|
|
57 |
SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha
|
|
|
58 |
**/
|
|
|
59 |
enum
|
|
|
60 |
{
|
|
|
61 |
SOIL_LOAD_AUTO = 0,
|
|
|
62 |
SOIL_LOAD_L = 1,
|
|
|
63 |
SOIL_LOAD_LA = 2,
|
|
|
64 |
SOIL_LOAD_RGB = 3,
|
|
|
65 |
SOIL_LOAD_RGBA = 4
|
|
|
66 |
};
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
Passed in as reuse_texture_ID, will cause SOIL to
|
|
|
70 |
register a new texture ID using glGenTextures().
|
|
|
71 |
If the value passed into reuse_texture_ID > 0 then
|
|
|
72 |
SOIL will just re-use that texture ID (great for
|
|
|
73 |
reloading image assets in-game!)
|
|
|
74 |
**/
|
|
|
75 |
enum
|
|
|
76 |
{
|
|
|
77 |
SOIL_CREATE_NEW_ID = 0
|
|
|
78 |
};
|
|
|
79 |
|
|
|
80 |
/**
|
|
|
81 |
flags you can pass into SOIL_load_OGL_texture()
|
|
|
82 |
and SOIL_create_OGL_texture().
|
|
|
83 |
(note that if SOIL_FLAG_DDS_LOAD_DIRECT is used
|
|
|
84 |
the rest of the flags with the exception of
|
|
|
85 |
SOIL_FLAG_TEXTURE_REPEATS will be ignored while
|
|
|
86 |
loading already-compressed DDS files.)
|
|
|
87 |
|
|
|
88 |
SOIL_FLAG_POWER_OF_TWO: force the image to be POT
|
|
|
89 |
SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
|
|
|
90 |
SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
|
|
|
91 |
SOIL_FLAG_MULTIPLY_ALPHA: for using (GL_ONE,GL_ONE_MINUS_SRC_ALPHA) blending
|
|
|
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
|
|
|
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]
|
|
|
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
|
|
|
98 |
**/
|
|
|
99 |
enum
|
|
|
100 |
{
|
|
|
101 |
SOIL_FLAG_POWER_OF_TWO = 1,
|
|
|
102 |
SOIL_FLAG_MIPMAPS = 2,
|
|
|
103 |
SOIL_FLAG_TEXTURE_REPEATS = 4,
|
|
|
104 |
SOIL_FLAG_MULTIPLY_ALPHA = 8,
|
|
|
105 |
SOIL_FLAG_INVERT_Y = 16,
|
|
|
106 |
SOIL_FLAG_COMPRESS_TO_DXT = 32,
|
|
|
107 |
SOIL_FLAG_DDS_LOAD_DIRECT = 64,
|
|
|
108 |
SOIL_FLAG_NTSC_SAFE_RGB = 128,
|
|
|
109 |
SOIL_FLAG_CoCg_Y = 256,
|
|
|
110 |
SOIL_FLAG_TEXTURE_RECTANGLE = 512
|
|
|
111 |
};
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
The types of images that may be saved.
|
|
|
115 |
(TGA supports uncompressed RGB / RGBA)
|
|
|
116 |
(BMP supports uncompressed RGB)
|
|
|
117 |
(DDS supports DXT1 and DXT5)
|
|
|
118 |
**/
|
|
|
119 |
enum
|
|
|
120 |
{
|
|
|
121 |
SOIL_SAVE_TYPE_TGA = 0,
|
|
|
122 |
SOIL_SAVE_TYPE_BMP = 1,
|
|
|
123 |
SOIL_SAVE_TYPE_DDS = 2
|
|
|
124 |
};
|
|
|
125 |
|
|
|
126 |
/**
|
|
|
127 |
Defines the order of faces in a DDS cubemap.
|
|
|
128 |
I recommend that you use the same order in single
|
|
|
129 |
image cubemap files, so they will be interchangeable
|
|
|
130 |
with DDS cubemaps when using SOIL.
|
|
|
131 |
**/
|
|
|
132 |
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
|
|
|
133 |
|
|
|
134 |
/**
|
|
|
135 |
The types of internal fake HDR representations
|
|
|
136 |
|
|
|
137 |
SOIL_HDR_RGBE: RGB * pow( 2.0, A - 128.0 )
|
|
|
138 |
SOIL_HDR_RGBdivA: RGB / A
|
|
|
139 |
SOIL_HDR_RGBdivA2: RGB / (A*A)
|
|
|
140 |
**/
|
|
|
141 |
enum
|
|
|
142 |
{
|
|
|
143 |
SOIL_HDR_RGBE = 0,
|
|
|
144 |
SOIL_HDR_RGBdivA = 1,
|
|
|
145 |
SOIL_HDR_RGBdivA2 = 2
|
|
|
146 |
};
|
|
|
147 |
|
|
|
148 |
/**
|
|
|
149 |
Loads an image from disk into an OpenGL texture.
|
|
|
150 |
\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 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 |
\return 0-failed, otherwise returns the OpenGL texture handle
|
|
|
155 |
**/
|
|
|
156 |
unsigned int
|
|
|
157 |
SOIL_load_OGL_texture
|
|
|
158 |
(
|
|
|
159 |
const char *filename,
|
|
|
160 |
int force_channels,
|
|
|
161 |
unsigned int reuse_texture_ID,
|
|
|
162 |
unsigned int flags
|
|
|
163 |
);
|
|
|
164 |
|
|
|
165 |
/**
|
|
|
166 |
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_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_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_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 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 |
\return 0-failed, otherwise returns the OpenGL texture handle
|
|
|
177 |
**/
|
|
|
178 |
unsigned int
|
|
|
179 |
SOIL_load_OGL_cubemap
|
|
|
180 |
(
|
|
|
181 |
const char *x_pos_file,
|
|
|
182 |
const char *x_neg_file,
|
|
|
183 |
const char *y_pos_file,
|
|
|
184 |
const char *y_neg_file,
|
|
|
185 |
const char *z_pos_file,
|
|
|
186 |
const char *z_neg_file,
|
|
|
187 |
int force_channels,
|
|
|
188 |
unsigned int reuse_texture_ID,
|
|
|
189 |
unsigned int flags
|
|
|
190 |
);
|
|
|
191 |
|
|
|
192 |
/**
|
|
|
193 |
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 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 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 |
\return 0-failed, otherwise returns the OpenGL texture handle
|
|
|
200 |
**/
|
|
|
201 |
unsigned int
|
|
|
202 |
SOIL_load_OGL_single_cubemap
|
|
|
203 |
(
|
|
|
204 |
const char *filename,
|
|
|
205 |
const char face_order[6],
|
|
|
206 |
int force_channels,
|
|
|
207 |
unsigned int reuse_texture_ID,
|
|
|
208 |
unsigned int flags
|
|
|
209 |
);
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
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 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 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 |
**/
|
|
|
219 |
unsigned int
|
|
|
220 |
SOIL_load_OGL_HDR_texture
|
|
|
221 |
(
|
|
|
222 |
const char *filename,
|
|
|
223 |
int fake_HDR_format,
|
|
|
224 |
int rescale_to_max,
|
|
|
225 |
unsigned int reuse_texture_ID,
|
|
|
226 |
unsigned int flags
|
|
|
227 |
);
|
|
|
228 |
|
|
|
229 |
/**
|
|
|
230 |
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_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 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 |
\return 0-failed, otherwise returns the OpenGL texture handle
|
|
|
237 |
**/
|
|
|
238 |
unsigned int
|
|
|
239 |
SOIL_load_OGL_texture_from_memory
|
|
|
240 |
(
|
|
|
241 |
const unsigned char *const buffer,
|
|
|
242 |
int buffer_length,
|
|
|
243 |
int force_channels,
|
|
|
244 |
unsigned int reuse_texture_ID,
|
|
|
245 |
unsigned int flags
|
|
|
246 |
);
|
|
|
247 |
|
|
|
248 |
/**
|
|
|
249 |
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_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_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_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_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_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_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 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 |
\return 0-failed, otherwise returns the OpenGL texture handle
|
|
|
266 |
**/
|
|
|
267 |
unsigned int
|
|
|
268 |
SOIL_load_OGL_cubemap_from_memory
|
|
|
269 |
(
|
|
|
270 |
const unsigned char *const x_pos_buffer,
|
|
|
271 |
int x_pos_buffer_length,
|
|
|
272 |
const unsigned char *const x_neg_buffer,
|
|
|
273 |
int x_neg_buffer_length,
|
|
|
274 |
const unsigned char *const y_pos_buffer,
|
|
|
275 |
int y_pos_buffer_length,
|
|
|
276 |
const unsigned char *const y_neg_buffer,
|
|
|
277 |
int y_neg_buffer_length,
|
|
|
278 |
const unsigned char *const z_pos_buffer,
|
|
|
279 |
int z_pos_buffer_length,
|
|
|
280 |
const unsigned char *const z_neg_buffer,
|
|
|
281 |
int z_neg_buffer_length,
|
|
|
282 |
int force_channels,
|
|
|
283 |
unsigned int reuse_texture_ID,
|
|
|
284 |
unsigned int flags
|
|
|
285 |
);
|
|
|
286 |
|
|
|
287 |
/**
|
|
|
288 |
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_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 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 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 |
**/
|
|
|
297 |
unsigned int
|
|
|
298 |
SOIL_load_OGL_single_cubemap_from_memory
|
|
|
299 |
(
|
|
|
300 |
const unsigned char *const buffer,
|
|
|
301 |
int buffer_length,
|
|
|
302 |
const char face_order[6],
|
|
|
303 |
int force_channels,
|
|
|
304 |
unsigned int reuse_texture_ID,
|
|
|
305 |
unsigned int flags
|
|
|
306 |
);
|
|
|
307 |
|
|
|
308 |
/**
|
|
|
309 |
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 |
\param data the raw data to be uploaded as an OpenGL texture
|
|
|
312 |
\param width the width of the image in pixels
|
|
|
313 |
\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 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 |
\return 0-failed, otherwise returns the OpenGL texture handle
|
|
|
318 |
**/
|
|
|
319 |
unsigned int
|
|
|
320 |
SOIL_create_OGL_texture
|
|
|
321 |
(
|
|
|
322 |
const unsigned char *const data,
|
|
|
323 |
int width, int height, int channels,
|
|
|
324 |
unsigned int reuse_texture_ID,
|
|
|
325 |
unsigned int flags
|
|
|
326 |
);
|
|
|
327 |
|
|
|
328 |
/**
|
|
|
329 |
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 width the width of the image in pixels
|
|
|
332 |
\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 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 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 |
**/
|
|
|
339 |
unsigned int
|
|
|
340 |
SOIL_create_OGL_single_cubemap
|
|
|
341 |
(
|
|
|
342 |
const unsigned char *const data,
|
|
|
343 |
int width, int height, int channels,
|
|
|
344 |
const char face_order[6],
|
|
|
345 |
unsigned int reuse_texture_ID,
|
|
|
346 |
unsigned int flags
|
|
|
347 |
);
|
|
|
348 |
|
|
|
349 |
/**
|
|
|
350 |
Captures the OpenGL window (RGB) and saves it to disk
|
|
|
351 |
\return 0 if it failed, otherwise returns 1
|
|
|
352 |
**/
|
|
|
353 |
int
|
|
|
354 |
SOIL_save_screenshot
|
|
|
355 |
(
|
|
|
356 |
const char *filename,
|
|
|
357 |
int image_type,
|
|
|
358 |
int x, int y,
|
|
|
359 |
int width, int height
|
|
|
360 |
);
|
|
|
361 |
|
|
|
362 |
/**
|
|
|
363 |
Loads an image from disk into an array of unsigned chars.
|
|
|
364 |
Note that *channels return the original channel count of the
|
|
|
365 |
image. If force_channels was other than SOIL_LOAD_AUTO,
|
|
|
366 |
the resulting image has force_channels, but *channels may be
|
|
|
367 |
different (if the original image had a different channel
|
|
|
368 |
count).
|
449 |
jrf |
369 |
\return 0 if failed, otherwise returns pointer to data
|
369 |
jab |
370 |
**/
|
|
|
371 |
unsigned char*
|
|
|
372 |
SOIL_load_image
|
|
|
373 |
(
|
|
|
374 |
const char *filename,
|
|
|
375 |
int *width, int *height, int *channels,
|
|
|
376 |
int force_channels
|
|
|
377 |
);
|
|
|
378 |
|
|
|
379 |
/**
|
449 |
jrf |
380 |
Loads an HDR image from disk into an array of unsigned chars.
|
|
|
381 |
Note that *channels return the original channel count of the
|
|
|
382 |
image. If force_channels was other than SOIL_LOAD_AUTO,
|
|
|
383 |
the resulting image has force_channels, but *channels may be
|
|
|
384 |
different (if the original image had a different channel
|
|
|
385 |
count).
|
|
|
386 |
\return 0 if failed, otherwise returns pointer to data
|
|
|
387 |
**/
|
|
|
388 |
unsigned char*
|
|
|
389 |
SOIL_load_HDR_image
|
|
|
390 |
(
|
|
|
391 |
const char *filename,
|
|
|
392 |
int *width, int *height, int *channels,
|
|
|
393 |
int force_channels
|
|
|
394 |
);
|
|
|
395 |
|
|
|
396 |
/**
|
369 |
jab |
397 |
Loads an image from memory into an array of unsigned chars.
|
|
|
398 |
Note that *channels return the original channel count of the
|
|
|
399 |
image. If force_channels was other than SOIL_LOAD_AUTO,
|
|
|
400 |
the resulting image has force_channels, but *channels may be
|
|
|
401 |
different (if the original image had a different channel
|
|
|
402 |
count).
|
|
|
403 |
\return 0 if failed, otherwise returns 1
|
|
|
404 |
**/
|
|
|
405 |
unsigned char*
|
|
|
406 |
SOIL_load_image_from_memory
|
|
|
407 |
(
|
|
|
408 |
const unsigned char *const buffer,
|
|
|
409 |
int buffer_length,
|
|
|
410 |
int *width, int *height, int *channels,
|
|
|
411 |
int force_channels
|
|
|
412 |
);
|
|
|
413 |
|
|
|
414 |
/**
|
|
|
415 |
Saves an image from an array of unsigned chars (RGBA) to disk
|
|
|
416 |
\return 0 if failed, otherwise returns 1
|
|
|
417 |
**/
|
|
|
418 |
int
|
|
|
419 |
SOIL_save_image
|
|
|
420 |
(
|
|
|
421 |
const char *filename,
|
|
|
422 |
int image_type,
|
|
|
423 |
int width, int height, int channels,
|
|
|
424 |
const unsigned char *const data
|
|
|
425 |
);
|
|
|
426 |
|
|
|
427 |
/**
|
|
|
428 |
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 |
"delete []" instead [8^)
|
|
|
431 |
**/
|
|
|
432 |
void
|
|
|
433 |
SOIL_free_image_data
|
|
|
434 |
(
|
|
|
435 |
unsigned char *img_data
|
|
|
436 |
);
|
|
|
437 |
|
|
|
438 |
/**
|
|
|
439 |
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 |
failed to load.
|
|
|
442 |
**/
|
|
|
443 |
const char*
|
|
|
444 |
SOIL_last_result
|
|
|
445 |
(
|
|
|
446 |
void
|
|
|
447 |
);
|
|
|
448 |
|
|
|
449 |
|
|
|
450 |
#ifdef __cplusplus
|
|
|
451 |
}
|
|
|
452 |
#endif
|
|
|
453 |
|
|
|
454 |
#endif /* HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY */
|