[DEV] First good version for IOs

This commit is contained in:
Edouard DUPIN 2014-04-22 21:24:37 +02:00
parent 66b53f30f4
commit 26b3f52d3f
4 changed files with 44 additions and 19 deletions

View File

@ -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),

View File

@ -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];
}

View File

@ -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 {

View File

@ -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];