Created
May 27, 2011 08:35
-
-
Save frostney/994862 to your computer and use it in GitHub Desktop.
Add a simple function in SDL iOS 1.3 to detect if the current target has a retina display or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add the function header to the your source file or header. | |
The resolution on Retina phones is still 480x320 pixels (460 px if the status bar is visible), only the scale changed. | |
*/ | |
extern DECLSPEC float SDLCALL SDL_iPhoneGetScale(void); | |
/* | |
How to call this function | |
*/ | |
if (SDL_iPhoneGetScale() > 1.0f) | |
{ | |
// Load assets for Retina phones | |
// On Retina phones the function returns 2.0f | |
} | |
else | |
{ | |
// Load assets for "older" phones | |
// On 3rd generation devices or lower it returns 1.0f | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add this little function to a .m file of your choice. I chose SDL_uikitview.m as it already has the iPhone specific keyboard functions in it. | |
I'm pretty sure you can choose any *.m file in /Library Source/video/uikit from the Xcode project file. | |
Make sure this function is added after @implementation ... @end. | |
Admittedly this is not best solution as it forces you capsulate your asset loading into one or more if calls. | |
SDL unfortunately has no tie-ins to NSImage, so you can't use the usual @2x stuff by default. (I'm not sure about SDL_image for iOS though. This option here is also preferred if you want to include a third-party non-SDL image library such as Vampyre Imaging.) | |
*/ | |
float | |
SDL_iPhoneGetScale(void) | |
{ | |
return [UIScreen mainScreen].scale; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment