Browse Source

Update iOSWindow.mm

Creating two global variables that represent the resolution of the iOS device
3dDeters 9 years ago
parent
commit
51f13bc74f
1 changed files with 8 additions and 1 deletions
  1. 8 1
      engine/source/platformiOS/iOSWindow.mm

+ 8 - 1
engine/source/platformiOS/iOSWindow.mm

@@ -121,6 +121,13 @@ void Platform::setWindowTitle(const char *title)
 //------------------------------------------------------------------------------
 void Platform::init()
 {
+    // Create two variables that I use later to make the canvas the right size
+    CGRect screenBounds = [[UIScreen mainScreen] bounds];
+    CGFloat screenScale = [[UIScreen mainScreen] scale];
+    
+    Con::setFloatVariable("$iOSwidth", screenBounds.size.width * screenScale);
+    Con::setFloatVariable("$iOSheight", screenBounds.size.height * screenScale);
+
     Con::setVariable("$platform", "iOS");
     
     if ([[UIScreen mainScreen] scale] == 2)
@@ -444,4 +451,4 @@ ConsoleFunction(setStatusBarHidden, bool, 2, 2, " Hides/unhides the iOS status b
 
 ConsoleFunction(setStatusBarType, void, 2, 2, " Set the status bar type. 0 hidden, 1 Black Opaque, 2 Black Translucent \n"){
     return setStatusBarType(dAtoi(argv[1]));
-}
+}