|Jan 16, 2009, 02:10 AM||#1|
Apple's GLSprite and non-256x256 image
Does anyone know why GLSprite only works with .png of size 256x256?
I have used the GLSprite code unaltered except for swapping the default png with either a 32x32 or 16x16 image. This results in messed up texture mapping. However if I put in any 256x256 images, the textures map properly.
Is this a problem with GLSprite's image loader or do I somehow misunderstand the way texture mapping occurs for images that are not 256x256 pixels?
|Jan 16, 2009, 05:49 AM||#2|
OpenGL in general- textures are always a power of two, which means 16x16 and 32x32 are acceptable sizes. I believe you need to study the the GLSprite code more closely to understand your problem...
Just in case you're wondering... I don't see a problem with the loading with my quick read through. My version does retrieve width and height from the spriteImage CGImage. Does yours?
EDIT - one last thought! Are you seeing problems in the Simulator, or on an actual iPhone when you test it???
Last edited by CommanderData; Jan 16, 2009 at 07:03 AM.
|Jan 16, 2009, 10:23 AM||#3|
Thanks for the reply.
It's very odd. I've dug thru the code for a couple hours and don't see where the 256 would be 'locked in'. As you say, the width/height seem to be pulled from the image.
Oddly even more, I've been able to use 64x64 & 128x128 images without a problem. It's only the smaller sizes that cause the image corruption.
It's also not an image format problem as I've created my own 64, 128, and 256 png's without a problem.
|Jan 16, 2009, 11:50 AM||#4|
I fixed it by changing the malloc call to a "calloc" call - that clears the memory before the image is loaded. Now my 16x16 sprites look just fine.
//original call //spriteData = (GLubyte *) malloc(width * height * 4); //clear the memory spriteData = (GLubyte *) calloc(width * height, 4);
Available Now:Dead Panic, a strategic zombie shooter
New Blog Post:How to make your first game for less than $1,000
Last edited by xsmasher; Jan 16, 2009 at 12:08 PM. Reason: added my code
|Jan 16, 2009, 02:47 PM||#5|
xsmasher, that makes sense all right~ great find! If the PNGs did not contain alpha transparent sections he would have never noticed it!
It is odd that this appears more obviously/frequently with smaller images, but maybe that's because the iPhone is able to squeeze that smaller malloc'ed memory into more areas... areas that may be polluted with unused bytes.
|Jan 17, 2009, 01:20 PM||#6|
That solved the problem. People at Apple's dev forum thought the limit was 64x64 so I'll pass your info on & enlighten them.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Apple TV: Center Image, not Fill||-BigMac-||Apple TV and Home Theater||3||Apr 19, 2014 10:12 AM|
|Possible to access Origional image file from texted image? (to view metadata)||inck243||iPhone Tips, Help and Troubleshooting||2||Dec 8, 2013 12:47 AM|
|Apple Preview Image Resize||leerkeller||Digital Photography||5||Jun 9, 2013 08:21 PM|
|Apple tv image quality||Purakane||Apple TV and Home Theater||16||Oct 31, 2012 05:22 AM|
|French Paris Apple Store protest alters Service Quality to harm Apple image||TRONgK||Apple, Industry and Internet Discussion||0||Sep 27, 2012 06:43 PM|
All times are GMT -5. The time now is 01:09 AM.