Using GLKit to speed up image loading in iT2D
by Paul Jan · 06/18/2012 (2:54 am) · 7 comments
In a previous post, I added the GLKit framework to add ViewControllers and Storyboards to iT2D. There's a lot more to GLKit however. This resource uses GLKit to load images into imagedatablocks, resulting in roughly a 30% improvement. It also adds support for Zwoptex plist files for spritesheets.
s87051801.onlinehome.us/Torque/GLKIT2.zip
Known Issues - GLKit is picky about the png files it takes, so I've left the old systems in as a backup. If you see a warning message "Error loading texture: ... GLKTextureLoaderErrorDomain error 12." the png has been loaded the old way.
update 8/23/2012
I've added scripts to allow you to create t2dImageDatablocks using Zwoptex files inside of TGB. Its still a little clunky, but functional.
More importantly, by adding imagesize fields to t2dImageDatablocks, we can skip a lot of unnecessary loading of images. Stock torque currently loads up images when you create image datablocks, even if you disable preloading just to get the size of the image.
s87051801.onlinehome.us/Torque/GLKIT3.zip
The catch is the image size information in the datablock has to be correct - I haven't set up error trapping there, so bad data can result in crashes or infinite looping.
I've been speed testing against the FeatureDemo app, which requires changes to some images (see error 12 above), and changes to the level datablocks to include image size information.
Example Files - Feature Demo:
s87051801.onlinehome.us/Torque/FeatureDemoImages.zip
s87051801.onlinehome.us/Torque/FeatureDemodatablocks.zip
s87051801.onlinehome.us/Torque/GLKIT2.zip
Known Issues - GLKit is picky about the png files it takes, so I've left the old systems in as a backup. If you see a warning message "Error loading texture: ... GLKTextureLoaderErrorDomain error 12." the png has been loaded the old way.
update 8/23/2012
I've added scripts to allow you to create t2dImageDatablocks using Zwoptex files inside of TGB. Its still a little clunky, but functional.
More importantly, by adding imagesize fields to t2dImageDatablocks, we can skip a lot of unnecessary loading of images. Stock torque currently loads up images when you create image datablocks, even if you disable preloading just to get the size of the image.
s87051801.onlinehome.us/Torque/GLKIT3.zip
The catch is the image size information in the datablock has to be correct - I haven't set up error trapping there, so bad data can result in crashes or infinite looping.
I've been speed testing against the FeatureDemo app, which requires changes to some images (see error 12 above), and changes to the level datablocks to include image size information.
Example Files - Feature Demo:
s87051801.onlinehome.us/Torque/FeatureDemoImages.zip
s87051801.onlinehome.us/Torque/FeatureDemodatablocks.zip
About the author
#2
06/19/2012 (4:42 pm)
GLKit is only available on ios 5.0+. It won't run on ios4.
#3
06/23/2012 (1:26 pm)
Thanks Paul. Going to give your resource a try. Very useful!
#4
06/27/2012 (1:57 am)
very nice work :) especially when considering that iOS6 is gonna add texture streaming :D
#5
Theres other goodies in GLKit I want to take a crack at when I get the time and the need - Asynchronous loading for instance.
I have some builder changes to put in that will let you use FILE type images for animations in the builder. Still gotta work out a button for loading the zwoptex files.
07/05/2012 (9:46 pm)
Let me know if you guys have any problems. I tend to do things on a "works for me" basis so things get overlooked :(Theres other goodies in GLKit I want to take a crack at when I get the time and the need - Asynchronous loading for instance.
I have some builder changes to put in that will let you use FILE type images for animations in the builder. Still gotta work out a button for loading the zwoptex files.
#6
Feature Demo's levelSelect_datablocks.cs and levelSelect.t2d are down to 384 ms on my test platform from the original's 1408 ms and 1152 ms.
Basically add fields to the imageDatablocks for image width and height and use those values for frame calcuations instead. Still fiddling with making it work right with the builder.
And GLKit is going to be added to OSX Mountain Lion. Joy!
07/18/2012 (8:36 pm)
Okay, I've come up with a way to get rid of that first loading and cut the time in half.Feature Demo's levelSelect_datablocks.cs and levelSelect.t2d are down to 384 ms on my test platform from the original's 1408 ms and 1152 ms.
Basically add fields to the imageDatablocks for image width and height and use those values for frame calcuations instead. Still fiddling with making it work right with the builder.
And GLKit is going to be added to OSX Mountain Lion. Joy!
#7
08/15/2012 (12:41 am)
Bug fix: some textures were not being unloaded. A new zip file has ben uploaded. ( 8/15/2012 )
Torque Owner Johnny Vo