SOIL: new lightweight image loading lib

Started by
129 comments, last by GenPFault 13 years, 11 months ago
Well, Ive just read the header file and was astonished to find that it supports loading and saving files, and can automaticaly generate a screenshot. I'll definitely be using this for the next few days. Good Job!
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Advertisement
ye lonesock its becoming more and more interesting, keep up the good work!
I'm happy to be your BacKdoOrMaaan
@ speciesUnknown & ForestMaster: thanks!

Updated SOIL a bit:
* now has the SOIL_CREATE_NEW_ID enum in SOIL.h (as shown in the usage examples)
* can now load uncompressed DDS files (directly which will preserve MIPmaps, or via stb_image which will ignore the MIPmaps, then regenerate them if requested)

The next thing I'm going to implement is loading cubemaps from single image files. This would include DDS cubemap files, and also any other format where the width is 6x the height (or vice versa). This way you could stitch together your 6 265x265 cubemap faces side to side into a single 1536x256 texture, or vertically to form a 256x1536 texture, then save it as png/jpg(make sure that your image size is a multiple of 8 so the jpeg blocks don't cross image boundaries)/dds(ditto, but multiples of 4)/whatever.

I'd like to just add a flag to SOIL_load_OGL_texture(), SOIL_FLAG_SPLIT_CUBEMAPS. This way SOIL would automatically split any image texture where the width is 6x the height and load it as a cubemap. Here's my question...does that make sense to everybody, or should I introduce a new function (SOIL_load_OGL_single_cubemap() or similar)? I'm not sure which way would be more intuitive.

Please cast your votes!

P.S. this version of the zip only has the library built with MinGW and VC2k5 Express...the VC6 and VC2k3 versions will have to wait till I get back to work. But the project files are still there, so you can easily perform the build if necessary.
Quote:Original post by lonesock
I'd like to just add a flag to SOIL_load_OGL_texture(), SOIL_FLAG_SPLIT_CUBEMAPS. This way SOIL would automatically split any image texture where the width is 6x the height and load it as a cubemap. Here's my question...does that make sense to everybody, or should I introduce a new function (SOIL_load_OGL_single_cubemap() or similar)? I'm not sure which way would be more intuitive.

Please cast your votes!


you can make two functions with the same name:
unsigned int	SOIL_load_OGL_texture	(		const char *filename,		int force_channels,		unsigned int reuse_texture_ID,		unsigned int flags	);unsigned int	SOIL_load_OGL_texture	(		const char *filename,		int force_channels,		unsigned int reuse_texture_ID,		unsigned int flags,                unsigned int cubemapflag	);

that can work either this way
SOIL_load_OGL_texture	(		"img.png",		SOIL_LOAD_AUTO,		SOIL_CREATE_NEW_ID,		SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT	);

or this way
SOIL_load_OGL_texture	(		"img.png",		SOIL_LOAD_AUTO,		SOIL_CREATE_NEW_ID,		SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT, SOIL_FLAG_SPLIT_CUBEMAPS	);


so you have one function 'name' only that can work ordinarily without specifying the flag or using the cubemap if the last parameter is added
similarly you can make 2 versions of the soil load ogl cube map function
unsigned int	SOIL_load_OGL_cubemap	(		const char *x_pos_file,		const char *x_neg_file,		const char *y_pos_file,		const char *y_neg_file,		const char *z_pos_file,		const char *z_neg_file,		int force_channels,		unsigned int reuse_texture_ID,		unsigned int flags	);unsigned int	SOIL_load_OGL_cubemap	(		const char *filename,		int force_channels,		unsigned int reuse_texture_ID,		unsigned int flags	);

and you have two different definitions of the function, the one with one char* prameter only will have to be split.
hope its clear

forest
I'm happy to be your BacKdoOrMaaan
ForestMaster: I think author is making SOIL as C not C++ library. So function overloading is not available.
Quote:Original post by bubu LV
ForestMaster: I think author is making SOIL as C not C++ library. So function overloading is not available.


oh what a pity :D in this case id vote for the separate function
I'm happy to be your BacKdoOrMaaan
How much work do you think it would be to add functions for loading images from raw data?

I'm asking as I'm implementing my game's data file access using physfs, which means I need to extract the file's raw data into a char[] before I can do anything with it. I know stb_image has functions for loading from data, but it looks like SOIL keeps the filename around through most of the process.
I'll have a look to see if I can find an easy way to abstract the back end from whether the input type, but I'm doubting it's going to be trivial.

Thanks.

EDIT: I guess I could just use stb_image myself to convert the image data and then call SOIL_create_OGL_texture =)

[Edited by - DeathCarrot on August 29, 2007 5:36:49 AM]
Quote:Original post by DeathCarrot
How much work do you think it would be to add functions for loading images from raw data?
...I guess I could just use stb_image myself to convert the image data and then call SOIL_create_OGL_texture =)

That works [8^)

Also, the newest version of stb_image allows you to register your own file-loader. If you can wait till this weekend I should be able to upgrade SOIL by then to use the newest version, and the DDS loader will be implemented using that interface, so there should be a decent bit of example code.

In other news, the single file to cubemap function is almost done...I just need to read DDS cubemaps...so that should be out this weekend too (thanks for casting the deciding vote, ForestMaster ;-)
SOIL can now load cubemaps from a single image file, either a DDS cubemap or any other image type with the six cube faces stitched together. It can now handle uncompressed DDS files too.

Sorry to anyone who downloaded SOIL between yesterday afternoon and now, I had a temp version up with some bugs, fixed now.

I really appreciate everyone who has tested SOIL, thanks for trying it out. Has anyone tried compiling SOIL under OS X?
Quote:Original post by lonesock
SOIL can now load cubemaps from a single image file, either a DDS cubemap or any other image type with the six cube faces stitched together. It can now handle uncompressed DDS files too.

Sorry to anyone who downloaded SOIL between yesterday afternoon and now, I had a temp version up with some bugs, fixed now.

I really appreciate everyone who has tested SOIL, thanks for trying it out. Has anyone tried compiling SOIL under OS X?


HI,

I've got SOIL compiling under OS X on gcc 4.2. I'm going to test the different file format loaders, and will probably use calls to these functions in my resource loader library.

Many thanks for an excellent library.




I just wanted to see if he would actually do it. Also, this test will rule out any problems with system services.

This topic is closed to new replies.

Advertisement