[DEV] Clean IOs wrapper

This commit is contained in:
Edouard DUPIN 2014-04-22 23:41:10 +02:00
parent 26b3f52d3f
commit 8f03df3af2
11 changed files with 32 additions and 115 deletions

3
.gitmodules vendored
View File

@ -62,3 +62,6 @@
[submodule "external/ewolsa"] [submodule "external/ewolsa"]
path = external/ewolsa path = external/ewolsa
url = https://github.com/HeeroYui/ewolsa.git url = https://github.com/HeeroYui/ewolsa.git
[submodule "ios-deploy"]
path = ios-deploy
url = https://github.com/HeeroYui/ios-deploy.git

2
build

@ -1 +1 @@
Subproject commit 49c29fefbd17e2c540b190da006e574576f22b30 Subproject commit 27d665573a0d5acfd68c523b6c3fbc01cf1f874b

2
external/airtaudio vendored

@ -1 +1 @@
Subproject commit c35dbe04f4cca044ce2f5288254158b212bf3b36 Subproject commit 9b55657ef1ce265f95321fc9468cd28b12a7bdfb

@ -1 +1 @@
Subproject commit 99f638245307b977c7926e373d01b73c2cf3b4b3 Subproject commit 2ecad98051db48e1fc8bf9ca8727ba93488201f6

1
ios-deploy Submodule

@ -0,0 +1 @@
Subproject commit 72e83d06e142e3813aff83da73ab2ceda99d74d8

View File

@ -37,8 +37,6 @@
NSLog(@"CREATE EWOL interface creation\n"); NSLog(@"CREATE EWOL interface creation\n");
IOs::createInterface(); IOs::createInterface();
IOs::resize(currentSize.width, currentSize.height); IOs::resize(currentSize.width, currentSize.height);
glView.animationInterval = 1.0 / 60.0;
[glView startAnimation];
} }
/* /*
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@ -49,7 +47,6 @@
*/ */
- (void)applicationWillResignActive:(UIApplication *)application { - (void)applicationWillResignActive:(UIApplication *)application {
glView.animationInterval = 1.0 / 5.0;
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
EWOL_INFO("move windows in applicationWillResignActive"); EWOL_INFO("move windows in applicationWillResignActive");
@ -67,7 +64,6 @@
} }
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication *)application {
glView.animationInterval = 1.0 / 60.0;
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
EWOL_INFO("move windows in applicationDidBecomeActive"); EWOL_INFO("move windows in applicationDidBecomeActive");
} }

View File

@ -62,6 +62,9 @@ public:
return 0; return 0;
} }
virtual void stop(void) {
mm_exit();
}
public: public:
//interface MacOS : //interface MacOS :

View File

@ -14,6 +14,7 @@ extern "C" {
#endif #endif
int mm_main(int argc, const char *argv[]); int mm_main(int argc, const char *argv[]);
void mm_exit(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -18,3 +18,8 @@ int mm_main(int argc, const char *argv[]) {
} // return no error } // return no error
return 0; return 0;
} }
void mm_exit(void) {
[[NSThread mainThread] cancel];
}

View File

@ -20,9 +20,6 @@
@private @private
CAEAGLLayer* _eaglLayer; CAEAGLLayer* _eaglLayer;
/* The pixel dimensions of the backbuffer */
GLint backingWidth;
GLint backingHeight;
EAGLContext *_context; EAGLContext *_context;
GLuint _colorRenderBuffer; GLuint _colorRenderBuffer;
@ -33,19 +30,7 @@
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
GLuint depthRenderbuffer; GLuint depthRenderbuffer;
//NSTimer *animationTimer;
NSTimeInterval animationInterval;
CGPoint touchLocation;
CGSize m_currentSize; CGSize m_currentSize;
} }
@property (nonatomic) NSTimeInterval animationInterval;
- (void)startAnimation;
- (void)stopAnimation;
- (void)drawView;
@end @end

View File

@ -17,37 +17,19 @@
#import "OpenglView.h" #import "OpenglView.h"
#include <ewol/debug.h> #include <ewol/debug.h>
// tuto de deploiment d'appo$ilcation :
// http://mobiforge.com/design-development/deploying-iphone-apps-real-devices
// http://www.techotopia.com/index.php/Testing_Apps_on_the_iPhone__Developer_Certificates_and_Provisioning_Profiles
#define USE_DEPTH_BUFFER 1
#define DEGREES_TO_RADIANS(__ANGLE) ((__ANGLE) / 180.0 * M_PI)
// A class extension to declare private methods
@interface OpenglView () @interface OpenglView ()
@property (nonatomic, retain) EAGLContext *context;
@property (nonatomic, assign) NSTimer *animationTimer;
@end @end
@implementation OpenglView @implementation OpenglView
@synthesize context; // You must implement this method (it does not work without it)
@synthesize animationTimer;
@synthesize animationInterval;
// You must implement this method
+ (Class)layerClass { + (Class)layerClass {
return [CAEAGLLayer class]; return [CAEAGLLayer class];
} }
- (NSString *) platform{ - (NSString *) platform {
size_t size; size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0); sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char*)malloc(size); char *machine = (char*)malloc(size);
@ -57,7 +39,7 @@
return platform; return platform;
} }
- (NSString *) platformString{ - (NSString *) platformString {
NSString *platform = [self platform]; NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
@ -174,7 +156,6 @@
NSLog(@"Failed to initialize OpenGLES 2.0 context"); NSLog(@"Failed to initialize OpenGLES 2.0 context");
exit(1); exit(1);
} }
if (![EAGLContext setCurrentContext:_context]) { if (![EAGLContext setCurrentContext:_context]) {
NSLog(@"Failed to set current OpenGL context"); NSLog(@"Failed to set current OpenGL context");
exit(1); exit(1);
@ -204,28 +185,21 @@
} }
- (void)render:(CADisplayLink*)displayLink { - (void)render:(CADisplayLink*)displayLink {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
IOs::draw(true); IOs::draw(true);
//NSLog(@"draw...");
[_context presentRenderbuffer:GL_RENDERBUFFER]; [_context presentRenderbuffer:GL_RENDERBUFFER];
} }
- (void)setupDisplayLink { - (void)setupDisplayLink {
CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)]; CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
} }
- (id)initWithFrame:(CGRect)frame - (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); NSLog(@"INIT with size : %fx%f, %fx%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
self.contentScaleFactor = 1.0f; self.contentScaleFactor = 1.0f;
// TODO : Enable multi touch ==> but this generate many sub errors ... 3 touch can be appear in 1 event ...
//self.multipleTouchEnabled = YES;
if (self) { if (self) {
[self configureAspectRatio]; [self configureAspectRatio];
[self setupLayer]; [self setupLayer];
@ -238,95 +212,44 @@
return self; return self;
} }
- (void)drawView {
//setting up the draw content
[EAGLContext setCurrentContext:_context];
// Open GL draw : ...
IOs::draw(true);
//glFlush();
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject]; UITouch *touch = [touches anyObject];
touchLocation = [touch locationInView:self]; CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds]; CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale]; CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
EWOL_ERROR("touchesBegan: " << positionEvent); EWOL_DEBUG(touches.count << " touchesBegan: " << positionEvent);
IOs::setInputState(1, true, positionEvent.x(), positionEvent.y()); IOs::setInputState(1, true, positionEvent.x(), positionEvent.y());
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject]; UITouch *touch = [touches anyObject];
touchLocation = [touch locationInView:self]; CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds]; CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale]; CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
EWOL_ERROR("touchesEnded: " << positionEvent); EWOL_DEBUG(touches.count << " touchesEnded: " << positionEvent);
IOs::setInputState(1, false, positionEvent.x(), positionEvent.y()); IOs::setInputState(1, false, positionEvent.x(), positionEvent.y());
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject]; UITouch *touch = [touches anyObject];
touchLocation = [touch locationInView:self]; CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds]; CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale]; CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
EWOL_ERROR("touchesMoved: " << positionEvent); EWOL_DEBUG(touches.count << " touchesMoved: " << positionEvent);
IOs::setInputMotion(1, positionEvent.x(), positionEvent.y()); IOs::setInputMotion(1, positionEvent.x(), positionEvent.y());
} }
- (void)layoutSubviews { - (void)layoutSubviews {
[EAGLContext setCurrentContext:context]; [EAGLContext setCurrentContext:_context];
[self drawView];
} }
- (void)startAnimation {
NSLog(@"start annimation\n");
/*
self.animationTimer = [NSTimer
scheduledTimerWithTimeInterval:animationInterval
target:self
selector:@selector(drawView)
userInfo:nil
repeats:YES];
*/
}
- (void)stopAnimation {
NSLog(@"Stop annimation\n");
self.animationTimer = nil;
}
- (void)setAnimationTimer:(NSTimer *)newTimer {
NSLog(@"new timer\n");
[animationTimer invalidate];
animationTimer = newTimer;
}
- (void)setAnimationInterval:(NSTimeInterval)interval {
animationInterval = interval;
if (animationTimer) {
[self stopAnimation];
[self startAnimation];
}
}
- (void)dealloc { - (void)dealloc {
if ([EAGLContext currentContext] == _context) {
[self stopAnimation];
if ([EAGLContext currentContext] == context) {
[EAGLContext setCurrentContext:nil]; [EAGLContext setCurrentContext:nil];
} }
//[context release];
//[super dealloc];
} }