|
|
@@ -20,8 +20,9 @@ using namespace std;
|
|
|
using namespace gameplay;
|
|
|
|
|
|
// UIScreen bounds are provided as if device was in portrait mode Gameplay defaults to landscape
|
|
|
-extern const int WINDOW_WIDTH = [[UIScreen mainScreen] bounds].size.height;
|
|
|
-extern const int WINDOW_HEIGHT = [[UIScreen mainScreen] bounds].size.width;
|
|
|
+extern const int WINDOW_WIDTH = [[UIScreen mainScreen] bounds].size.height * [[UIScreen mainScreen] scale];
|
|
|
+extern const int WINDOW_HEIGHT = [[UIScreen mainScreen] bounds].size.width * [[UIScreen mainScreen] scale];
|
|
|
+extern const int WINDOW_SCALE = [[UIScreen mainScreen] scale];
|
|
|
|
|
|
@class AppDelegate;
|
|
|
@class View;
|
|
|
@@ -102,13 +103,16 @@ int getKey(unichar keyCode);
|
|
|
return nil;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// Configure the CAEAGLLayer and setup out the rendering context
|
|
|
+ CGFloat scale = [[UIScreen mainScreen] scale];
|
|
|
CAEAGLLayer* layer = (CAEAGLLayer *)self.layer;
|
|
|
layer.opaque = TRUE;
|
|
|
layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
|
|
|
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
|
|
+ self.contentScaleFactor = scale;
|
|
|
+ layer.contentsScale = scale;
|
|
|
+
|
|
|
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
|
|
if (!context || ![EAGLContext setCurrentContext:context])
|
|
|
{
|
|
|
@@ -123,7 +127,7 @@ int getKey(unichar keyCode);
|
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
|
|
|
glViewport(0, 0, framebufferWidth, framebufferHeight);
|
|
|
-
|
|
|
+
|
|
|
// Initialize Internal Defaults
|
|
|
displayLink = nil;
|
|
|
defaultFramebuffer = 0;
|
|
|
@@ -324,27 +328,27 @@ int getKey(unichar keyCode);
|
|
|
|
|
|
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
|
|
|
{
|
|
|
- unsigned int uniqueTouch = 0;
|
|
|
- for(UITouch *t in touches)
|
|
|
+ unsigned int touchID = 0;
|
|
|
+ for(UITouch* touch in touches)
|
|
|
{
|
|
|
- CGPoint touchLoc = [t locationInView:self];
|
|
|
+ CGPoint touchPoint = [touch locationInView:self];
|
|
|
if(self.multipleTouchEnabled == YES)
|
|
|
{
|
|
|
- uniqueTouch = [t hash];
|
|
|
+ touchID = [touch hash];
|
|
|
}
|
|
|
- Platform::touchEventInternal(Touch::TOUCH_PRESS, touchLoc.x, touchLoc.y, uniqueTouch);
|
|
|
+ Platform::touchEventInternal(Touch::TOUCH_PRESS, touchPoint.x * WINDOW_SCALE, touchPoint.y * WINDOW_SCALE, touchID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent *)event
|
|
|
+- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
|
|
|
{
|
|
|
- unsigned int uniqueTouch = 0;
|
|
|
- for(UITouch* t in touches)
|
|
|
+ unsigned int touchID = 0;
|
|
|
+ for(UITouch* touch in touches)
|
|
|
{
|
|
|
- CGPoint touchLoc = [t locationInView:self];
|
|
|
+ CGPoint touchPoint = [touch locationInView:self];
|
|
|
if(self.multipleTouchEnabled == YES)
|
|
|
- uniqueTouch = [t hash];
|
|
|
- Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchLoc.x, touchLoc.y, uniqueTouch);
|
|
|
+ touchID = [touch hash];
|
|
|
+ Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchPoint.x * WINDOW_SCALE, touchPoint.y * WINDOW_SCALE, touchID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -356,13 +360,13 @@ int getKey(unichar keyCode);
|
|
|
|
|
|
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
|
|
|
{
|
|
|
- unsigned int uniqueTouch = 0;
|
|
|
- for(UITouch* t in touches)
|
|
|
+ unsigned int touchID = 0;
|
|
|
+ for(UITouch* touch in touches)
|
|
|
{
|
|
|
- CGPoint touchLoc = [t locationInView:self];
|
|
|
+ CGPoint touchPoint = [touch locationInView:self];
|
|
|
if(self.multipleTouchEnabled == YES)
|
|
|
- uniqueTouch = [t hash];
|
|
|
- Platform::touchEventInternal(Touch::TOUCH_MOVE, touchLoc.x, touchLoc.y, uniqueTouch);
|
|
|
+ touchID = [touch hash];
|
|
|
+ Platform::touchEventInternal(Touch::TOUCH_MOVE, touchPoint.x * WINDOW_SCALE, touchPoint.y * WINDOW_SCALE, touchID);
|
|
|
}
|
|
|
}
|
|
|
|