Flixel Forums

development => iOS => Topic started by: tokyotron on Wed, May 9, 2012

Title: Retina / high res textures
Post by: tokyotron on Wed, May 9, 2012
Did anyone try using high res graphics for retina displays?

How do you do it properly?
I'm in the process trying to find out the above. Use retina textures for retina displays. Standard textures for standard displays.
I think I've gotten FlxSprites working by now, still FlxTileblocks render too big on retina displays... so. If anyone knows of any working examples?

Like someone else noted in a post here, I set useTextureBufferZoom to NO when initing the FlxGame. And for retina displays, set zoom to 2.0 (actually I use device scale from UIScreen if it exists, otherwise 1.0 for backways comp.). This is what seems to fix things for FlxSprites. Still FlxTileblocks seem to draw things on their own and I guess they don't really care about those zoom parameters. And I'll likely need the FlxTileblocks for performance reasons...

Oh and hello this is my first post in this forum. I'll be sticking around for awhile I guess. I'm an iOS developer, but so far made only Cocoa Touch / native apps, and have only temporary experience from OpenGL and that's around 10 years ago.
Title: Re: Retina / high res textures
Post by: initials on Thu, May 10, 2012
Should be easy to do. Canabalt has two sets of textures, one for iPhone and one for iPad. Shouldn't be too hard to make one for retina, and add it to the if statement where it loads the textures.
Title: Re: Retina / high res textures
Post by: tokyotron on Thu, May 10, 2012
I don't yet get it right with the FlxTileblock. Using @2x textures there (they seem properly loaded if existing) just gives bigger graphics, not higher resolution.

I noticed also that the engine gives lots of warnings when compiling, like lots of stuff concerning properties. I've updated the project to give 0 warnings when compiling. I don't think I've seen any problem so far. I might github that stuff later.
Title: Re: Retina / high res textures
Post by: tokyotron on Tue, Jun 12, 2012
I just couldn't read the source of FlxTileblock so I rewrote it from scratch to learn. It works, I can now use tiles of arbitrary resolution (1x, 2x (retina) or whatever). I just couldn't get it to work with graphics loaded from atlases so for now I just add the tile graphics one by one. Not sure if there's any performance boost of using atlases anyway, at least in this case. What I did learn from the original FlxTileblock was to use "stitching" before drawing the first column of any new line which is not the first line.
Uh, and, despite doing all this I haven't really measured any performances differences but at least instead of using hundreds/thousands of FlxSprites in my case I'm just using a few tile blocks that really just draw vertices from an array.
Kind of makes you wonder what makes FlxSprites so slow in the first place...

If anyone's interested I could share this class.
Title: Re: Retina / high res textures
Post by: tokyotron on Sun, Feb 3, 2013
HEre is the finished game with retina gfx http://forums.flixel.org/index.php/topic,7050.msg39277.html#msg39277