SOIL: new lightweight image loading lib

Started by
129 comments, last by GenPFault 13 years, 10 months ago
Quote:Original post by Davian_
Hi. The library is looking good so far. Thanks!
...
I'm using VS.NET 2003, have the project linked to libSOIL.a, and the file in question includes SOIL.h.

Thanks! When using VS.NET 2k3, I'd recommend linking against one of the MS compiler generated *.lib files. (The libSOIL.a file is meant for the MinGW compiler.) I'd try SOIL_vc7.lib first to verify that it works.

If that doesn't fix the issue, I'd try including "math.h" in that same source file and try doing a "temp = sqrtf( temp );" and see if that causes any problems.
Advertisement
Sorry, browser hiccup caused a double post.
Hi. Switching to SOIL_vc7.lib produces the following errors:

error LNK2019: unresolved external symbol _convert_image_to_DXT1 referenced in function _SOIL_internal_create_OGL_texture
error LNK2019: unresolved external symbol _convert_image_to_DXT5 referenced in function _SOIL_internal_create_OGL_texture
error LNK2019: unresolved external symbol _save_image_as_DDS referenced in function _SOIL_save_image

It doesn't seem that there is any difference in including math.h or not, and using a function like sqrt() does not cause an error.
Quote:Original post by Davian_
Hi. Switching to SOIL_vc7.lib produces the following errors:

error LNK2019: unresolved external symbol _convert_image_to_DXT1 referenced in function _SOIL_internal_create_OGL_texture
error LNK2019: unresolved external symbol _convert_image_to_DXT5 referenced in function _SOIL_internal_create_OGL_texture
error LNK2019: unresolved external symbol _save_image_as_DDS referenced in function _SOIL_save_image

It doesn't seem that there is any difference in including math.h or not, and using a function like sqrt() does not cause an error.

Hey, as it turns out, I'm a moron! In the VS projects I forgot to include the DXT code. And in VS2k3 I can use sqrt(), but not sqrtf(), so I'll make the changes to the code, recompile everything, and upload the new version by tonight. Thanks so much for finding and reporting these errors!
Quote:Original post by lonesock
...so I'll make the changes to the code, recompile everything, and upload the new version by tonight...

I ran into a small problem. I'm trying to have just a single one of the compiled libraries for MS compilers in the distribution. The VC6 version of the lib is now working with all MS compilers. The 2k3 version of the lib is unfortunately the largest. The 2k5 version of the lib is the smallest & fastest, so I wanted to use that, however when I try to use it with 2k3 I get an error about ftol2_sse not being defined.

So I have uploaded the fixed (for MS compilers) version of SOIL with the VC6 version of SOIL.lib. If anybody knows what I should be doing to get 2k5 to compile without the _sse version of the function, I'll update the "one true lib" to using the 2005 compiler's version. I will update the website documentation after I've ironed all this out, but at least the current version should get you up and running, Davian_!

thanks for you patience, everybody.
I've uploaded a new version of SOIL:
* upgraded to stb_image version 1.00
* only including 1 prebuilt library file (libSOIL.a) which works for MinGW and Microsoft compilers (including VS 2003)
* added the DXT source files to the MS projects so you can recompile the lib if you wish
* updated the Usage section of the SOIL website with an example of SOIL_load_OGL_texture_from_memory

Please let me know if the new version works for all'y'all. Thanks so much for testing SOIL and reporting problems.
Quote:Original post by shotgunnutter
This will allow the code to compile on gcc 4.0.2 and on MSC. I haven't tested it on a Linux system but the headers are the same as for OS X.


I thought I'd let you know: the headers definitely aren't the same. The OpenGL headers are in a GL/ directory on most UN*X-like systems. Mac OS X is an exception.
I just used swig to translate soil.h for FreeBasic. I don't really know enough about ogl to really use it yet, but by plugging it into some FB ogl examples I was able to verify that libSOIL.a does work when linked statically in FB.

'''''' soil -- header translated with help of SWIG FB wrapper'''' NOTICE: This file is part of the FreeBASIC Compiler package and can't''         be included in other distributions without authorization.''''#ifndef __soil_bi__#define __soil_bi__#inclib "SOIL"enum 	SOIL_LOAD_AUTO = 0	SOIL_LOAD_L = 1	SOIL_LOAD_LA = 2	SOIL_LOAD_RGB = 3	SOIL_LOAD_RGBA = 4end enumenum 	SOIL_CREATE_NEW_ID = 0end enumenum 	SOIL_FLAG_POWER_OF_TWO = 1	SOIL_FLAG_MIPMAPS = 2	SOIL_FLAG_TEXTURE_REPEATS = 4	SOIL_FLAG_MULTIPLY_ALPHA = 8	SOIL_FLAG_INVERT_Y = 16	SOIL_FLAG_COMPRESS_TO_DXT = 32	SOIL_FLAG_DDS_LOAD_DIRECT = 64end enumenum 	SOIL_SAVE_TYPE_TGA = 0	SOIL_SAVE_TYPE_BMP	SOIL_SAVE_TYPE_DDSend enumdeclare function SOIL_load_OGL_texture cdecl alias "SOIL_load_OGL_texture" (byval filename as zstring ptr, byval force_channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_load_OGL_cubemap cdecl alias "SOIL_load_OGL_cubemap" (byval x_pos_file as zstring ptr, byval x_neg_file as zstring ptr, byval y_pos_file as zstring ptr, byval y_neg_file as zstring ptr, byval z_pos_file as zstring ptr, byval z_neg_file as zstring ptr, byval force_channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_load_OGL_single_cubemap cdecl alias "SOIL_load_OGL_single_cubemap" (byval filename as zstring ptr, byval face_order as zstring ptr, byval force_channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_load_OGL_texture_from_memory cdecl alias "SOIL_load_OGL_texture_from_memory" (byval buffer as ubyte ptr, byval buffer_length as integer, byval force_channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_load_OGL_cubemap_from_memory cdecl alias "SOIL_load_OGL_cubemap_from_memory" (byval x_pos_buffer as ubyte ptr, byval x_pos_buffer_length as integer, byval x_neg_buffer as ubyte ptr, byval x_neg_buffer_length as integer, byval y_pos_buffer as ubyte ptr, byval y_pos_buffer_length as integer, byval y_neg_buffer as ubyte ptr, byval y_neg_buffer_length as integer, byval z_pos_buffer as ubyte ptr, byval z_pos_buffer_length as integer, byval z_neg_buffer as ubyte ptr, byval z_neg_buffer_length as integer, byval force_channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_load_OGL_single_cubemap_from_memory cdecl alias "SOIL_load_OGL_single_cubemap_from_memory" (byval buffer as ubyte ptr, byval buffer_length as integer, byval face_order as zstring ptr, byval force_channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_create_OGL_texture cdecl alias "SOIL_create_OGL_texture" (byval data as ubyte ptr, byval width as integer, byval height as integer, byval channels as integer, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_create_OGL_single_cubemap cdecl alias "SOIL_create_OGL_single_cubemap" (byval data as ubyte ptr, byval width as integer, byval height as integer, byval channels as integer, byval face_order as zstring ptr, byval reuse_texture_ID as uinteger, byval flags as uinteger) as uintegerdeclare function SOIL_save_screenshot cdecl alias "SOIL_save_screenshot" (byval filename as zstring ptr, byval image_type as integer, byval x as integer, byval y as integer, byval width as integer, byval height as integer) as integerdeclare function SOIL_load_image cdecl alias "SOIL_load_image" (byval filename as zstring ptr, byval width as integer ptr, byval height as integer ptr, byval channels as integer ptr, byval force_channels as integer) as ubyte ptrdeclare function SOIL_load_image_from_memory cdecl alias "SOIL_load_image_from_memory" (byval buffer as ubyte ptr, byval buffer_length as integer, byval width as integer ptr, byval height as integer ptr, byval channels as integer ptr, byval force_channels as integer) as ubyte ptrdeclare function SOIL_save_image cdecl alias "SOIL_save_image" (byval filename as zstring ptr, byval image_type as integer, byval width as integer, byval height as integer, byval channels as integer, byval data as ubyte ptr) as integerdeclare sub SOIL_free_image_data cdecl alias "SOIL_free_image_data" (byval img_data as ubyte ptr)declare function SOIL_last_result cdecl alias "SOIL_last_result" () as zstring ptr#endif


*edit*

Is there a function to get the pixel width and height of the image?

[Edited by - Merick Zero on September 21, 2007 9:39:32 PM]
Quote:Original post by Merick Zero
I just used swig to translate soil.h for FreeBasic. I don't really know enough about ogl to really use it yet, but by plugging it into some FB ogl examples I was able to verify that libSOIL.a does work when linked statically in FB.

*** Source Snippet Removed ***

*edit*

Is there a function to get the pixel width and height of the image?

Awesome! Do you mind if I include this file in the SOIL distribution zip?

As to getting the image size, you have 2 options:
1) use the OpenGL function glGetTexLevelParameter (see here) once the texture object is bound (which it is right after a call to SOIL's upload functions)
2) use a 2-step process where you call SOIL_load_image and get the image data (including size), then call SOIL_create_OGL_texture with the image data you just loaded.
Quote:Original post by lonesock
Awesome! Do you mind if I include this file in the SOIL distribution zip?


Sure thing. After all, all I did was just run it through the FB version of swig to get a machine translation. -- And as such, it should be noted that all the functions should be tested with FB to make sure that there are no glitches in the translation (I actually only tested one function, SOIL_load_OGL_texture). I'd do it myself, but as I said before I'm still trying to figure out opengl and it'll probably be a while before I can really do anything with it.

This topic is closed to new replies.

Advertisement