[DEV] Clean IOs wrapper
This commit is contained in:
parent
26b3f52d3f
commit
8f03df3af2
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -62,3 +62,6 @@
|
||||
[submodule "external/ewolsa"]
|
||||
path = external/ewolsa
|
||||
url = https://github.com/HeeroYui/ewolsa.git
|
||||
[submodule "ios-deploy"]
|
||||
path = ios-deploy
|
||||
url = https://github.com/HeeroYui/ios-deploy.git
|
||||
|
2
build
2
build
@ -1 +1 @@
|
||||
Subproject commit 49c29fefbd17e2c540b190da006e574576f22b30
|
||||
Subproject commit 27d665573a0d5acfd68c523b6c3fbc01cf1f874b
|
2
external/airtaudio
vendored
2
external/airtaudio
vendored
@ -1 +1 @@
|
||||
Subproject commit c35dbe04f4cca044ce2f5288254158b212bf3b36
|
||||
Subproject commit 9b55657ef1ce265f95321fc9468cd28b12a7bdfb
|
2
external/bullet/bullet
vendored
2
external/bullet/bullet
vendored
@ -1 +1 @@
|
||||
Subproject commit 99f638245307b977c7926e373d01b73c2cf3b4b3
|
||||
Subproject commit 2ecad98051db48e1fc8bf9ca8727ba93488201f6
|
1
ios-deploy
Submodule
1
ios-deploy
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 72e83d06e142e3813aff83da73ab2ceda99d74d8
|
@ -37,8 +37,6 @@
|
||||
NSLog(@"CREATE EWOL interface creation\n");
|
||||
IOs::createInterface();
|
||||
IOs::resize(currentSize.width, currentSize.height);
|
||||
glView.animationInterval = 1.0 / 60.0;
|
||||
[glView startAnimation];
|
||||
}
|
||||
/*
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
@ -49,7 +47,6 @@
|
||||
*/
|
||||
|
||||
- (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.
|
||||
// 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");
|
||||
@ -67,7 +64,6 @@
|
||||
}
|
||||
|
||||
- (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.
|
||||
EWOL_INFO("move windows in applicationDidBecomeActive");
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
|
||||
return 0;
|
||||
}
|
||||
virtual void stop(void) {
|
||||
mm_exit();
|
||||
}
|
||||
public:
|
||||
//interface MacOS :
|
||||
|
||||
|
@ -14,6 +14,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int mm_main(int argc, const char *argv[]);
|
||||
void mm_exit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -18,3 +18,8 @@ int mm_main(int argc, const char *argv[]) {
|
||||
} // return no error
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mm_exit(void) {
|
||||
[[NSThread mainThread] cancel];
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,6 @@
|
||||
|
||||
@private
|
||||
CAEAGLLayer* _eaglLayer;
|
||||
/* The pixel dimensions of the backbuffer */
|
||||
GLint backingWidth;
|
||||
GLint backingHeight;
|
||||
|
||||
EAGLContext *_context;
|
||||
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) */
|
||||
GLuint depthRenderbuffer;
|
||||
|
||||
//NSTimer *animationTimer;
|
||||
NSTimeInterval animationInterval;
|
||||
|
||||
CGPoint touchLocation;
|
||||
CGSize m_currentSize;
|
||||
}
|
||||
|
||||
@property (nonatomic) NSTimeInterval animationInterval;
|
||||
|
||||
- (void)startAnimation;
|
||||
- (void)stopAnimation;
|
||||
- (void)drawView;
|
||||
|
||||
|
||||
@end
|
||||
|
@ -17,37 +17,19 @@
|
||||
#import "OpenglView.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 ()
|
||||
|
||||
@property (nonatomic, retain) EAGLContext *context;
|
||||
@property (nonatomic, assign) NSTimer *animationTimer;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation OpenglView
|
||||
|
||||
@synthesize context;
|
||||
@synthesize animationTimer;
|
||||
@synthesize animationInterval;
|
||||
|
||||
|
||||
// You must implement this method
|
||||
// You must implement this method (it does not work without it)
|
||||
+ (Class)layerClass {
|
||||
return [CAEAGLLayer class];
|
||||
}
|
||||
|
||||
- (NSString *) platform{
|
||||
- (NSString *) platform {
|
||||
size_t size;
|
||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||
char *machine = (char*)malloc(size);
|
||||
@ -57,7 +39,7 @@
|
||||
return platform;
|
||||
}
|
||||
|
||||
- (NSString *) platformString{
|
||||
- (NSString *) platformString {
|
||||
NSString *platform = [self platform];
|
||||
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
|
||||
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
|
||||
@ -174,7 +156,6 @@
|
||||
NSLog(@"Failed to initialize OpenGLES 2.0 context");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (![EAGLContext setCurrentContext:_context]) {
|
||||
NSLog(@"Failed to set current OpenGL context");
|
||||
exit(1);
|
||||
@ -204,28 +185,21 @@
|
||||
}
|
||||
|
||||
- (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);
|
||||
//NSLog(@"draw...");
|
||||
[_context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
}
|
||||
|
||||
|
||||
- (void)setupDisplayLink {
|
||||
CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
|
||||
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
animationInterval = 1.0 / 60.0;
|
||||
- (id)initWithFrame:(CGRect)frame {
|
||||
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.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) {
|
||||
[self configureAspectRatio];
|
||||
[self setupLayer];
|
||||
@ -238,95 +212,44 @@
|
||||
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 {
|
||||
UITouch *touch = [touches anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
CGPoint touchLocation = [touch locationInView:self];
|
||||
CGRect localBounds = [self bounds];
|
||||
CGFloat screenScale = [[UIScreen mainScreen] scale];
|
||||
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());
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
UITouch *touch = [touches anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
CGPoint touchLocation = [touch locationInView:self];
|
||||
CGRect localBounds = [self bounds];
|
||||
CGFloat screenScale = [[UIScreen mainScreen] scale];
|
||||
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());
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
UITouch *touch = [touches anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
CGPoint touchLocation = [touch locationInView:self];
|
||||
CGRect localBounds = [self bounds];
|
||||
CGFloat screenScale = [[UIScreen mainScreen] scale];
|
||||
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());
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[EAGLContext setCurrentContext:context];
|
||||
[self drawView];
|
||||
[EAGLContext setCurrentContext:_context];
|
||||
}
|
||||
|
||||
|
||||
- (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 {
|
||||
|
||||
[self stopAnimation];
|
||||
|
||||
if ([EAGLContext currentContext] == context) {
|
||||
if ([EAGLContext currentContext] == _context) {
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
}
|
||||
|
||||
//[context release];
|
||||
//[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user