Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


SOIL: new lightweight image loading lib


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
130 replies to this topic

#61 lonesock   Members   -  Reputation: 799

Like
0Likes
Like

Posted 27 October 2007 - 06:35 AM

OK, new SOIL release with some fixes and some new features. Here is a Copy-n-Paste of the changelog:

* correctly reports when there is no OpenGL context (thanks Merick Zero!)
* upgraded to stb_image 1.03 with support for loading the HDR image format
* fixed loading JPEG images while forcing the number of channels (e.g. to RGBA)
* changed SOIL_DDS_CUBEMAP_FACE_ORDER to a #define (thanks Dancho!)
* reorganized my additions to stb_image (you can define STBI_NO_DDS to compile SOIL without DDS support)
* added SOIL_FLAG_CoCg_Y, will convert RGB or RGBA to YCoCg color space (link)

Thanks again to everyone for your feedback and helping find bugs!

Sponsor:

#62 Dancho   Members   -  Reputation: 151

Like
0Likes
Like

Posted 27 October 2007 - 07:41 AM

@lonesock

that snippet is now working ok with your lib,
but when I try to compile a VC8 SOIL.sln I get this error:

1>LIB : fatal error LNK1181: cannot open input file '.\lib\stb_image.obj'

regards,
Dancho





#63 lonesock   Members   -  Reputation: 799

Like
0Likes
Like

Posted 27 October 2007 - 08:31 AM

Quote:
Original post by Dancho
...when I try to compile a VC8 SOIL.sln...

Argh! I renamed a few files in my quest to make DDS loading easy to compile in/out of SOIL, and forgot to update all the Visual Studio projects (I do all my hobby stuff on CodeBlocks). I'm so sorry, I'll get that updated soon.

Thanks,


#64 Mogui   Members   -  Reputation: 139

Like
0Likes
Like

Posted 27 October 2007 - 11:45 PM

Hey Lonesock,

Your SOIL is great, thanks. Just a couple problems building on OSx.

Soil.c line 1428 should be

CFRelease( extensionName ); (I think)


and SOIL.c line 78 (I just deleted APIENTRY)

after that, it builds and works fine (I only tried SOIL_load_OGL_texture with PNGs)


Matt

#65 Merick Zero   Members   -  Reputation: 151

Like
0Likes
Like

Posted 28 October 2007 - 10:55 AM

Once I've used SOIL_load_OGL_texture to load a texture, how do I remove it from memory? SOIL_free_image_data doesn't seem to do anything

#66 LaurentGom   Members   -  Reputation: 186

Like
0Likes
Like

Posted 28 October 2007 - 05:48 PM

Hi

Thanks for this great library, I'm probably going to integrate it into my own library to get rid of DevIL for image loading. As in public domain, I should be able to include the SOIL files directly into my project instead of building it as a separate library, right (my library is open-source, under the zlib/png license) ?

Just a few suggestions to improve integration of SOIL into other libraries :

- You should split the functions into 2 separate sets of files : those for pure image loading / saving, and those related to OpenGL textures. Then you can add the ability to use the first subset of the whole library with a define, like SOIL_USE_OPENGL or SOIL_DONT_USE_OPENGL. Your library is very useful to add image loading to higher-level libraries (like mine), but not everybody will want the OpenGL stuff.

- There are still a lot of warnings when compiling (I use level 4 in Visual Studio), mainly due to implicit casts or signed/unsigned mismatches. They can be easily corrected, so I think it would be a good idea to fix them to make compiling cleaner.

- There is a bug (or at least an inconsistent behavior) when loading a DDS : if the source image has no alpha, it will convert the output to 3 components even when the caller requested 4.

- Do you think PNG and JPEG formats can be supported for saving ? Or maybe I should rather contact the author of stb_image ?

#67 lonesock   Members   -  Reputation: 799

Like
0Likes
Like

Posted 28 October 2007 - 06:21 PM

@Mogui: Thanks for letting me know. I was pointed towards another error I had with that segment of code, which might fix this problem too. The next release will have the fix and I'll try to PM you to see if it fixed the issue.

@Merick Zero: Sorry if the docs are unclear. The SOIL_free_image_data() function is actually for use with SOIL_load_image() or similar which returns an array of unsigned chars. If you are done with the OpenGL texture, simply call the glDeleteTextures() function, like this:
glDeleteTextures( 1, &my_tex_ID );

@LaurentGom: You're welcome! "Public Domain" as in if you want to take the code, rename it LOIS and sell it as a closed source project to Microsoft, that's OK with me [8^) Your suggestions are excellent. If I may comment on them very quickly:
1) People can just use stb_image if they want image loading only (with my DDS additions if so desired). What other functionality does SOIL offer that you would want with the image loading stuff?
2) I am leaving the stb_image code mostly untouched, but if you find any of those warning in any other piece of code, please PM or email the list to me and I would be happy to fix them!
3) Ouch! I'll look into that.
4) I think contacting Sean (see his site here) would be a good idea.

Again, thank you all for your feedback & bug reports!

#68 LaurentGom   Members   -  Reputation: 186

Like
0Likes
Like

Posted 28 October 2007 - 08:10 PM

Thanks for the informations.

Just a few precisions for 1) : in the version I downloaded (a few days ago), DDS and PNG was not part of stb_image. Same for the general load / save functions (they were mixed with the OpenGL ones in SOIL.h).
It seems to have changed, so I should just get the latest version.

#69 Merick Zero   Members   -  Reputation: 151

Like
0Likes
Like

Posted 29 October 2007 - 04:45 PM

when using soil to load an image, is there any way to get the alpha value from a certain pixel inside the image, either from the image buffer created by SOIL_load_image or from the gl texture itself? Basically what I want to do is create an array with 0's and 1's to use as data for pixel perfect collision in 2d games

#70 D J Peters   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 October 2007 - 12:34 AM

has anywhere libSoil.a for Linux?

Joshy
Sorry about my bad English.

#71 lonesock   Members   -  Reputation: 799

Like
0Likes
Like

Posted 30 October 2007 - 08:45 AM

Hi, All. There is a new release of SOIL; here's the changelog:

* upgraded to stb_image 1.04, some tiny bug fixes
* there is now a makefile (under projects) for ease of building under Linux (thanks D J Peters!)
* Visual Studio 6/2003/2005 projects are working again (thanks Dancho!)
* patched SOIL for better pointer handling of the glCompressedTexImage2D extension (thanks Peter Sperl!)
* fixed DDS loading when force_channels=4 but there was no alpha; it was returning 3 channels. (Thanks LaurentGom!)
* fixed a bunch of channel issues in general. (Thanks Sean Barrett!)

@Mogui: could you check and see if the compilation issue is gone now?

@LaurentGom: DDS loading and saving (and the DXT compression) code is still separate from the stb_image code, but hopefully modular enough that you can just include those files in your projects. Also, I fixed the 3-channel DDS loading issue.

@Merick Zero: you can load the image using SOIL_load_image(), forcing 4 channels by using SOIL_LOAD_RGBA, then make a copy of only the alpha channel (every 4th byte). You could then upload the image as an OpenGL texture using SOIL_create_OGL_texture() with the image data you just loaded.

@D J Peters: The latest SOIL release has a makefile under the projects directory so you can make the library easily under Linux. Just go to the projects/makefile directory and run 'make'. I haven't been able to test it under Linux, but it works under MSYS on Windows. Please let me know if you have any problems.

#72 D J Peters   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 October 2007 - 04:58 PM

Quote:
Original post by lonesock@D J Peters: ...Please let me know if you have any problems.

first thanx for this fine short lib
and no problems to build the lib on linux.

can i use it for http://fsr.sf.net Free Speed Racer is it open source ?

Joshy
Sorry about my bad English.

#73 lonesock   Members   -  Reputation: 799

Like
0Likes
Like

Posted 31 October 2007 - 04:07 AM

Quote:
Original post by D J Peters
first thanx for this fine short lib
and no problems to build the lib on linux.

can i use it for http://fsr.sf.net Free Speed Racer is it open source ?

Joshy

You are welcome! I'm glad to hear there were no build problems. SOIL is released to the Public Domain, so yes, you can use it for free in any project you want, even commercial closed-source projects.

#74 Merick Zero   Members   -  Reputation: 151

Like
0Likes
Like

Posted 04 November 2007 - 01:15 AM

When using the SOIL_LOAD_RGBA flag, how about adding another argument that can let you specify a color value for a transparency mask for images that don't normally have transparency like bmp?

#75 swiftcoder   Senior Moderators   -  Reputation: 10234

Like
0Likes
Like

Posted 04 November 2007 - 02:05 AM

SOIL seems to work fine in OS X, apart from a couple of updates to the includes, etc.

Here is the diff of the changes I had to make to get it to work (updates to the right):

Quote:

23c23
< #include <GL/gl.h>
---
> #include <OpenGL/gl.h>
24a25
> #define APIENTRY
1529c1530
< CFRelease( functionName );
---
> CFRelease( extensionName );


Edit: I love this library! If you need a long-term OS X maintainer, I am available... just drop me an email (swiftcoder@gmail.com) whenever you need a new release testing ;)

[Edited by - swiftcoder on November 4, 2007 2:05:03 PM]

#76 swiftcoder   Senior Moderators   -  Reputation: 10234

Like
0Likes
Like

Posted 04 November 2007 - 08:04 AM

How about modifying the texture creation code with a SOIL_FLAG_TEXTURE_RECTANGE flag? This would allow us to use the same function to load GUI textures, etc.

#77 lonesock   Members   -  Reputation: 799

Like
0Likes
Like

Posted 05 November 2007 - 05:13 PM

@Merick Zero: I like that idea! I'm not sure of an elegant way to specify the color to be converted to transparency, but I'll try to come up with something. Did you mean like the exact color RGB will become alpha=0, or more like the "Color to Alpha" function of The GIMP (and I assume PhotoShop) where it maps a range of alpha values?

@swiftcoder: Thanks for being willing to do OS X testing! I'd really appreciate it. I've fixed the lines you (and Mogui) indicated for the soon-to-be-out next release, so hopefully now my claims of "cross-platform" will be out of the box, not "after extensive tweaking" [8^). Regarding the NPOT textures, what if the user does not specify SOIL_FLAG_POWER_OF_TWO or SOIL_FLAG_MIPMAPS (do I understand correctly that MIPmaps are forbidden to non-power-of-two textures?) and the texture is not already a POT, then SOIL could use GL_TEXTURE_RECTANGLE_ARB automatically?

Thanks

#78 Starfox   Members   -  Reputation: 504

Like
0Likes
Like

Posted 05 November 2007 - 06:06 PM

Re: Mipmaps and NPOT:
From the OpenGL Extension registry for ARB_texture_non_power_of_two:
"When this extension is supported, mipmapping, automatic mipmap
generation, and all the conventional wrap modes are supported for
non-power-of-two textures".
For mip generation rules, check the registry entry: http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt

#79 swiftcoder   Senior Moderators   -  Reputation: 10234

Like
0Likes
Like

Posted 06 November 2007 - 12:45 AM

Quote:
Original post by lonesock
Regarding the NPOT textures, what if the user does not specify SOIL_FLAG_POWER_OF_TWO or SOIL_FLAG_MIPMAPS (do I understand correctly that MIPmaps are forbidden to non-power-of-two textures?) and the texture is not already a POT, then SOIL could use GL_TEXTURE_RECTANGLE_ARB automatically?

Thanks


This was my initial idea, but I scrapped it because I wasn't sure whether such a strange beast as TEXTURE_RECTANGLE should ever be the default? I certainly wouldn't mind it that way though.

(note that you also need to exclude SOIL_FLAG_TEXTURE_REPEATS, as repeating is not supported)

#80 Merick Zero   Members   -  Reputation: 151

Like
0Likes
Like

Posted 06 November 2007 - 11:31 PM

What I was thinking about was just something to remove solid-color background from images to make sprites for 2d.

I'm not too familiar with how the gimp function works, but why not do both and have it accept an array for the argument? Then you could determine which method to use by the structure of the array

something like

myarray = (255,0,255)

or

myarray = ( (123,50,45), (100,200,200), (0,0,155))




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS