diff --git a/sources/ewol/context/Context.cpp b/sources/ewol/context/Context.cpp index a04b685b..89f516d4 100644 --- a/sources/ewol/context/Context.cpp +++ b/sources/ewol/context/Context.cpp @@ -287,7 +287,7 @@ void ewol::Context::setArchiveDir(int _mode, const char* _str) { ewol::Context::Context(int32_t _argc, const char* _argv[]) : m_previousDisplayTime(0), m_input(*this), -#if defined(__TARGET_OS__Android) +#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs)) m_displayFps(true), #else m_displayFps(false), diff --git a/sources/ewol/context/IOs/AppDelegate.mm b/sources/ewol/context/IOs/AppDelegate.mm index cb553467..4f20b4cb 100644 --- a/sources/ewol/context/IOs/AppDelegate.mm +++ b/sources/ewol/context/IOs/AppDelegate.mm @@ -20,15 +20,23 @@ @synthesize glView; - (void)applicationDidFinishLaunching:(UIApplication *)application { - - CGRect screenBounds = [[UIScreen mainScreen] bounds]; + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + CGFloat screenScale = [[UIScreen mainScreen] scale]; + NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height); + CGSize currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); + //screenBounds.size.width *= screenScale; + //screenBounds.size.height *= screenScale; + NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height); window = [[UIWindow alloc] initWithFrame:screenBounds]; - glView = [[[OpenglView alloc] initWithFrame:window.bounds] autorelease];; + window.contentMode = UIViewContentModeRedraw; + glView = [[OpenglView alloc] initWithFrame:window.bounds]; + glView.contentMode = UIViewContentModeRedraw; [window addSubview:glView]; [window makeKeyAndVisible]; // Create interface of ewol here .... NSLog(@"CREATE EWOL interface creation\n"); IOs::createInterface(); + IOs::resize(currentSize.width, currentSize.height); glView.animationInterval = 1.0 / 60.0; [glView startAnimation]; } diff --git a/sources/ewol/context/IOs/OpenglView.mm b/sources/ewol/context/IOs/OpenglView.mm index 40420801..17a37268 100644 --- a/sources/ewol/context/IOs/OpenglView.mm +++ b/sources/ewol/context/IOs/OpenglView.mm @@ -135,25 +135,35 @@ if ([platform isEqualToString:@"iPad4,2"]) return 264.0f; //@"iPad Air (Cellular)"; if ([platform isEqualToString:@"iPad4,4"]) return 326.0f; //@"iPad mini 2G (WiFi)"; if ([platform isEqualToString:@"iPad4,5"]) return 326.0f; //@"iPad mini 2G (Cellular)"; - if ([platform isEqualToString:@"i386"]) return 326.0f; //@"Simulator"; + if ([platform isEqualToString:@"i386"]) return 200.0f; //@"Simulator"; if ([platform isEqualToString:@"x86_64"]) return 326.0f; //@"Simulator"; return 326.0f; } +- (void)setNeedsDisplay { + EWOL_INFO("**** setNeedsDisplay:" << vec2(self.frame.size.width, self.frame.size.height)); + // TODO : SIZE change ... + +} - (void)configureAspectRatio { CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; m_currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); + //self.frame.size = m_currentSize; - NSLog(@"**** screen size : %fx%f\n", m_currentSize.width, m_currentSize.height); + EWOL_INFO("**** screen size:" << vec2(m_currentSize.width, m_currentSize.height)); float ratio = [self getScreenPPP]; - NSLog(@"**** pixel ratio : %f ppp \n", ratio); + EWOL_INFO("**** pixel ratio: " << ratio); ewol::Dimension::setPixelRatio(vec2(1.0f/ratio, 1.0f/ratio), ewol::Dimension::Inch); IOs::resize(m_currentSize.width, m_currentSize.height); + CGRect localBounds = [self bounds]; + EWOL_INFO("**** localBounds:" << vec2(localBounds.size.width, localBounds.size.height)); } - (void)setupLayer { _eaglLayer = (CAEAGLLayer*) self.layer; + CGFloat screenScale = [[UIScreen mainScreen] scale]; + _eaglLayer.contentsScale = screenScale; _eaglLayer.opaque = YES; } @@ -181,7 +191,8 @@ - (void)setupDepthBuffer { glGenRenderbuffers(1, &_depthRenderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, self.frame.size.width, self.frame.size.height); + CGFloat screenScale = [[UIScreen mainScreen] scale]; + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, self.frame.size.width*screenScale, self.frame.size.height*screenScale); } - (void)setupFrameBuffer { @@ -212,8 +223,10 @@ - (id)initWithFrame:(CGRect)frame { animationInterval = 1.0 / 60.0; + NSLog(@"INIT with size : %fx%f, %fx%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); self = [super initWithFrame:frame]; - if (self) { + self.contentScaleFactor = 1.0f; + if (self) { [self configureAspectRatio]; [self setupLayer]; [self setupContext]; @@ -230,7 +243,7 @@ [EAGLContext setCurrentContext:_context]; // Open GL draw : ... IOs::draw(true); - glFlush(); + //glFlush(); } @@ -238,22 +251,28 @@ UITouch *touch = [touches anyObject]; touchLocation = [touch locationInView:self]; CGRect localBounds = [self bounds]; - EWOL_ERROR("touchesBegan: " << vec2(touchLocation.x, localBounds.size.height - touchLocation.y)); - IOs::setInputState(1, true, touchLocation.x, localBounds.size.height - touchLocation.y); + CGFloat screenScale = [[UIScreen mainScreen] scale]; + vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); + EWOL_ERROR("touchesBegan: " << positionEvent); + IOs::setInputState(1, true, positionEvent.x(), positionEvent.y()); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; touchLocation = [touch locationInView:self]; CGRect localBounds = [self bounds]; - EWOL_ERROR("touchesEnded: " << vec2(touchLocation.x, localBounds.size.height - touchLocation.y)); - IOs::setInputState(1, false, touchLocation.x, localBounds.size.height - touchLocation.y); + CGFloat screenScale = [[UIScreen mainScreen] scale]; + vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); + EWOL_ERROR("touchesEnded: " << positionEvent); + IOs::setInputState(1, false, positionEvent.x(), positionEvent.y()); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; touchLocation = [touch locationInView:self]; CGRect localBounds = [self bounds]; - EWOL_ERROR("touchesMoved: " << vec2(touchLocation.x, localBounds.size.height - touchLocation.y)); - IOs::setInputMotion(1, touchLocation.x, localBounds.size.height - touchLocation.y); + CGFloat screenScale = [[UIScreen mainScreen] scale]; + vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); + EWOL_ERROR("touchesMoved: " << positionEvent); + IOs::setInputMotion(1, positionEvent.x(), positionEvent.y()); } - (void)layoutSubviews { diff --git a/sources/ewol/context/MacOs/AppDelegate.mm b/sources/ewol/context/MacOs/AppDelegate.mm index baef61d5..b4fdfcae 100644 --- a/sources/ewol/context/MacOs/AppDelegate.mm +++ b/sources/ewol/context/MacOs/AppDelegate.mm @@ -16,9 +16,7 @@ @synthesize window=_window; - (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - OpenGLView *view = [[[OpenGLView alloc]initWithFrame:screenBounds] autorelease]; + OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] bounds]]; // Override point for customization after application launch. [self.window addSubview:view]; [self.window makeKeyAndVisible];