At this moment I use this scenario to load OpenGL texture from PNG:
- load PNG via UIImage
- get pixels data via bitmap context
- repack pixels to new format (currently RGBA8 -> RGBA4, RGB8 -> RGB565, using ARM NEON instructions)
- create OpenGL texture with data
(this approach is commonly used in Cocos2d engine)
It takes much time and seems to do extra work that may be done once per build. So I want to save repacked pixels data back into file and load it directly to OpenGL on second time.
I would know the practical advantages. Does anyone tried it? Is it worth to compress data via zip (as I know, current iDevices have bottleneck in file access)? Would be very thankful for real experience sharing.
So, I have made some successful experiment:
I compress texture data by
zlib(max compression ratio) and save it to file (viaNSDatamethods). The size of file is much smaller then PNG in some cases.As for loading time, I can’t say exact timestamps because in my project there are 2 parallel threads – one is loading textures on background while another is still rendering scene. It is approximately twice faster – IMHO the main reason is that we copy image data directly to OpengGL without repacking, and input data amount smaller).
PS: Build optimization level plays very high role in loading time: about 4 seconds in debug configuration vs. 1 second in release.