SOIL image library problem or texture lib problem
Hi folks,
I am looking for an opengl texture loader for iphone that is fast, and can handle 8 bit pngs with alpha and without alpha.
The supplied code in the glsprite example works well but will crash out if I try an 8 bit png without alpha. It sometimes works with alpha. I've tried a lot of different code and had enough. Time to get a library that will do the work for me.
To this end I spent 2 days trying to get http://lonesock.net/soil.html SOIL working on iphone but it just won't work.
I include the .a file as a framework and include the SOIL.h file but I keep getting object errors when compiling.
If anyone knows the answer I would really appreciate a step by step example of how to get SOIL running.
Or perhaps you have a reliable library for iphone which can handle all forms of PNGs - that would work too, please post links or examples.
Thanks guys, my hair is running out!
I am looking for an opengl texture loader for iphone that is fast, and can handle 8 bit pngs with alpha and without alpha.
The supplied code in the glsprite example works well but will crash out if I try an 8 bit png without alpha. It sometimes works with alpha. I've tried a lot of different code and had enough. Time to get a library that will do the work for me.
To this end I spent 2 days trying to get http://lonesock.net/soil.html SOIL working on iphone but it just won't work.
I include the .a file as a framework and include the SOIL.h file but I keep getting object errors when compiling.
If anyone knows the answer I would really appreciate a step by step example of how to get SOIL running.
Or perhaps you have a reliable library for iphone which can handle all forms of PNGs - that would work too, please post links or examples.
Thanks guys, my hair is running out!
I had a problem with SOIL too, but it's all working now. I asked a similar question a while back, it may be the same problem:
http://www.idevgames.com/forum/showthrea...OIL&page=3
http://www.idevgames.com/forum/showthrea...OIL&page=3
~ Bring a Pen ~
Hi mikey thanks for the heads up.
I would like to thank AnotherJake for all his effort in helping you. He helped me so much. The crux of the problem was I was using the existing .a file. With AnotherJake's tutorial I was able to compile a new .a file (I had to mess around making a few folders so it wouldn't crash) - I now have it compiling and working.
Thanks guys!
I would like to thank AnotherJake for all his effort in helping you. He helped me so much. The crux of the problem was I was using the existing .a file. With AnotherJake's tutorial I was able to compile a new .a file (I had to mess around making a few folders so it wouldn't crash) - I now have it compiling and working.
Thanks guys!
No problem. Thanks to AnotherJake!
~ Bring a Pen ~
OH NO
big problem... it isn't working on the actual device! throws up an error. Does this mean I have to somehow build an .a file for arm cpus?
big problem... it isn't working on the actual device! throws up an error. Does this mean I have to somehow build an .a file for arm cpus?
I have managed to get SOIL compiling natively in xcode instead of using .a files. I had to include
#import <OpenGLES/EAGLDrawable.h>
#import <QuartzCore/QuartzCore.h>
#import "EAGLView.h"
At the top of SOIL.c (I renamed c files to m though, not sure if that was worthwhile).
And then I uncommented/commented the CLAMP vars lower in the source (you'll get two errors).
However I'm seeing that SOIL does not load pngs which are less than 8 bit. ie 128 colour or whatever. All PNGs work regardless of bit depth in simulator though.
I am just going to stick with 256 colour pngs I guess. Thats a good file saving at least.
#import <OpenGLES/EAGLDrawable.h>
#import <QuartzCore/QuartzCore.h>
#import "EAGLView.h"
At the top of SOIL.c (I renamed c files to m though, not sure if that was worthwhile).
And then I uncommented/commented the CLAMP vars lower in the source (you'll get two errors).
However I'm seeing that SOIL does not load pngs which are less than 8 bit. ie 128 colour or whatever. All PNGs work regardless of bit depth in simulator though.
I am just going to stick with 256 colour pngs I guess. Thats a good file saving at least.
SOIL is based on stb_image which specifies PNG files must be 8bit. That's 8bit per channel though, and has nothing to do with paletted PNG files as you're describing (but it should load those just fine too).
The problem you're seeing is likely due to Xcode mangling your PNG files when building for the device. You can uncheck "Compress PNG files" in your build settings to avoid that, or use a file extension other than ".png".
The problem you're seeing is likely due to Xcode mangling your PNG files when building for the device. You can uncheck "Compress PNG files" in your build settings to avoid that, or use a file extension other than ".png".
I just wanted to pop in and say thanks for all the "thanks" 
Other than that, I'm with Frank on the png mangle out of xcode. Definitely try disabling that first.

Other than that, I'm with Frank on the png mangle out of xcode. Definitely try disabling that first.
If you just need png loading why not actually use libPNG? You don't need very much code to load a PNG into a texture, and there are examples available. Best of all, by not using a cobbled together image loading library, you won't run into files that don't work.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
I can't vouch for SOIL but I've been using both libpng and SOIL's progenitor stb_image for years, and when I need to load PNG files under my control, I always go for stb_image. It's smaller, faster, and just way way simpler than libpng - plus you get JPEG & PSD and a few other goodies for free.
stb_image & friends are absolutely not suitable for files you don't control though, so if you need to load any PNG file then definitely yes, go for libpng.
stb_image & friends are absolutely not suitable for files you don't control though, so if you need to load any PNG file then definitely yes, go for libpng.
Hey Frank. Just wanted to thank you. About a month ago I was hitting all sorts of strange issues with libpng and you suggested that stb_image and it has worked great since then!
Well I have it kinda working now. Thing is though, won't it slow my game down if my pngs aren't mangled by xcode? I thought it optimised them. Also, it swaps colour channels too doesn't it? I wouldn't like to end up with files with funny colours
Lots of thank you's in this thread
...
@hippocoder By the time OpenGL gets your textures, they are no longer PNG (just raw data) so no, they won't slow down your game. You also won't see funny colours if you use a standard loader with standard (un-Xcode-mangled) PNGs. Xcode mangles PNG for use with CoreGraphics/UIKit, which will load and display mangled PNGs faster. That only really makes sense when using UKit though, since views are typically purged and restored constantly to conserve memory (as far as I understand - I'm no UIKit guru).
If you really need better texture performance in OpenGL there are a few strategies you can use but that's a whole other thread.
...@hippocoder By the time OpenGL gets your textures, they are no longer PNG (just raw data) so no, they won't slow down your game. You also won't see funny colours if you use a standard loader with standard (un-Xcode-mangled) PNGs. Xcode mangles PNG for use with CoreGraphics/UIKit, which will load and display mangled PNGs faster. That only really makes sense when using UKit though, since views are typically purged and restored constantly to conserve memory (as far as I understand - I'm no UIKit guru).
If you really need better texture performance in OpenGL there are a few strategies you can use but that's a whole other thread.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| opengl es strange 16bit texture scale problem | spuckfunkel | 6 | 7,366 |
Aug 14, 2011 10:44 PM Last Post: headkaze |
|
| Scaling Problem in Cocos2d | Jerm #1 | 7 | 8,411 |
May 18, 2011 11:02 AM Last Post: EvolPenguin |
|
| in simulator the app is working, on devices no...how can i find the problem? | sefiroths | 5 | 6,506 |
Jan 27, 2011 11:42 AM Last Post: sefiroths |
|
| Problem with Game Car | nan2castillo | 0 | 1,383 |
Nov 11, 2010 09:15 AM Last Post: nan2castillo |
|
| iPad window size problem | the_wandering_monster | 7 | 7,241 |
Oct 8, 2010 11:06 AM Last Post: Rasterman |
|

