SOIL: new lightweight image loading lib

Started by
129 comments, last by GenPFault 13 years, 11 months ago
Quote:Original post by shotgunnutter
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.

Great, thanks! I have 0 access to any Mac machines, so thanks for verifying it at least compiles [8^)

Quote:Original post by shotgunnutter
Many thanks for an excellent library.

You're welcome! Feel free to hit me with any suggestions or requests for making it better.
Advertisement
Looks like a very interesting library, I'll have to try it out when I get home :). D3DX-esque texture loading for OpenGL, yay!

I, too, am using PhysFS, so being able to load from a custom file source would be great. :)

Good work.

- Thomas Cowellwebsite | journal | engine video

Quote:Original post by DeathCarrot
How much work do you think it would be to add functions for loading images from raw data?

Quote:Original post by cow_in_the_well
I, too, am using PhysFS, so being able to load from a custom file source would be great. :)

Ah, sorry I misunderstood you earlier, DeathCarrot. As you saw, stb_image already supports decoding images from a block of RAM, so this feature will not be too hard to implement. I'll add in the interface to decompress images from memory as I upgrade to stb_image 0.98, so expect the next SOIL release in a few days.

Thanks so much for your feedback!
Quote:Original post by lonesock
Quote:Original post by shotgunnutter
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.

Great, thanks! I have 0 access to any Mac machines, so thanks for verifying it at least compiles [8^)

Quote:Original post by shotgunnutter
Many thanks for an excellent library.

You're welcome! Feel free to hit me with any suggestions or requests for making it better.


Your library is so easy to use that I would like to rate you up again, if only I hadn't done so twice already.

Ok, initial tests on my MBP running OS X 10.4.10, and gcc 4.0.2 are successful. I can load .tga files, and .bmp files. I haven't yet tested screen shots, I'll do that next.

Here is an OS generated screen shot from my quake 3 clone:



























OK, I cheated. Here is what I actually managed to do:



I'm writing my own renderer; My code at the moment is the result of a year of reading tutorials and copy / pasting code from examples on the web. The class which handles the MD2 character also renders him. Thanks to your library, I can now design a better system far more quickly.


I did have to make a change to the compiler macros in soil.c, to ensure platform cross- compatibility:

in soil.c, where you have
#ifdef _MSC_VER	#define WIN32_LEAN_AND_MEAN	#include <windows.h>#endif#include "SOIL.h"#include "stb_image.h"#include "image_helper.h"#include <stdlib.h>#include <string.h>#include <GL/gl.h>//	for using DXT compression#define SOIL_RGB_S3TC_DXT1_EXT		0x83F0#define SOIL_RGBA_S3TC_DXT1_EXT		0x83F1#define SOIL_RGBA_S3TC_DXT3_EXT		0x83F2#define SOIL_RGBA_S3TC_DXT5_EXT		0x83F3


i changed this to

#ifdef _MSC_VER	#define WIN32_LEAN_AND_MEAN	#include <windows.h>	#include <GL/gl.h>#else	#include <OpenGL/gl.h>	#include <OpenGL/glu.h>#endif#include "SOIL.h"#include "stb_image.h"#include "image_helper.h"#include <stdlib.h>#include <string.h>//	for using DXT compression#define SOIL_RGB_S3TC_DXT1_EXT		0x83F0#define SOIL_RGBA_S3TC_DXT1_EXT		0x83F1#define SOIL_RGBA_S3TC_DXT3_EXT		0x83F2#define SOIL_RGBA_S3TC_DXT5_EXT		0x83F3


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.

[update: png files work. Alpha transparency on .tga and .png also works]

[Edited by - shotgunnutter on September 5, 2007 11:31:27 PM]
I just wanted to see if he would actually do it. Also, this test will rule out any problems with system services.
hey good library but i was solwed image loading problem.
so we need a 3d image loader like 3ds or any other.

can you do that.
but anyway i dont need it but dds support is good.
i can use your source for this.
but i like open source things.
© Loading... !!!
Please Wait...!
Quote:Original post by RSC_x
hey good library but i was solwed image loading problem.
so we need a 3d image loader like 3ds or any other.

can you do that.
but anyway i dont need it but dds support is good.
i can use your source for this.
but i like open source things.


Why not write your own?
I just wanted to see if he would actually do it. Also, this test will rule out any problems with system services.
Hi, All.

SOIL has 2 updates:
* it can now handle some non-compliant DDS files (which did not specify a pitch or linear size)
* it can now decompress images from memory for you PhysicsFS users (note, this is mostly untested, especially the DDS direct upload version...I'd really appreciate any feedback!)

@shotgunnutter: Thanks for the heads-up regarding the includes. I think the includes you mentioned were from a previous version, would you mind testing the latest version? If there are still issues I'd be happy to make changes [8^)

@RSC_x: I'm not sure I understood. Are you requesting that SOIL be able to load DDS files with 3D (volume) textures in them? Or are you looking for some mesh-loading libraries with licenses similar to Public Domain? (if so, there are many libraries out there, like Trimeshloader...I recommend checking this list as a first step).
Quote:Original post by lonesock

@RSC_x: I'm not sure I understood. Are you requesting that SOIL be able to load DDS files with 3D (volume) textures in them? Or are you looking for some mesh-loading libraries with licenses similar to Public Domain? (if so, there are many libraries out there, like Trimeshloader...I recommend checking this list as a first step).


Nobody except me and a few other people understand RSC_x. he was asking you could write him a loader for a 3d model format, and gave .3ds as an example.
I told him to write his own.
I just wanted to see if he would actually do it. Also, this test will rule out any problems with system services.
@shotgunnutter: Thanks for the clarification. Quick question, did the new includes work for you on your various platforms?

Has anybody tried SOIL with PhysicsFS? I'd like to verify that it works, or fix it in the other case [8^)
Hi. The library is looking good so far. Thanks!

I'm having a small problem, though, and I was hoping you could point me in the right direction. I'm using VS.NET 2003, have the project linked to libSOIL.a, and the file in question includes SOIL.h. When I build the project, the following linker error comes up:

error LNK2019: unresolved external symbol _sqrtf referenced in function _compute_color_line_STDEV

The error goes away when I comment out the SOIL_load_OGL_texture_from_memory line. Are there any other libraries I need to link to or settings I need to change to get it working? The code for the function in question is below.

Thanks a lot!

const unsigned int getTexture(string fileName) {	PHYSFS_File* filePtr;	int fileLength;	unsigned char* imageData;	unsigned int textureID;	map<unsigned int, PNTexture>::iterator textureIter;	textureIter = loadedTextures.begin();	while (textureIter->second.fileName != fileName) {		textureIter++;	}	if (textureIter != loadedTextures.end()) {		textureIter->second.refCount++;		textureID = textureIter->first;	}	else {		filePtr = PHYSFS_openRead(fileName.c_str());		fileLength = PHYSFS_fileLength(filePtr);		PHYSFS_read(filePtr, imageData, 1, fileLength);						textureID = SOIL_load_OGL_texture_from_memory(imageData, fileLength, 0, 0, NULL);		if (textureID > 0) {							loadedTextures[textureID].fileName = fileName;			loadedTextures[textureID].width = 320;	//TODO: Read the dimensions from the data file, along with the 			loadedTextures[textureID].height = 320; //texture coordinates for each tile			loadedTextures[textureID].refCount = 1;		}		PHYSFS_close(filePtr);	}			return textureID;}

This topic is closed to new replies.

Advertisement