summaryrefslogtreecommitdiff
path: root/platform/iphone/gl_view.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/iphone/gl_view.mm')
-rwxr-xr-xplatform/iphone/gl_view.mm87
1 files changed, 49 insertions, 38 deletions
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 3309fd0820..f19e16f3f6 100755
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -54,6 +54,14 @@ static bool video_playing = false;
static float video_previous_volume = 0.0f;
static CMTime video_current_time;
+void _show_keyboard(String);
+void _hide_keyboard();
+bool _play_video(String, float, String, String);
+bool _is_video_playing();
+void _focus_out_video();
+void _unpause_video();
+void _stop_video();
+
void _show_keyboard(String p_existing) {
keyboard_text = p_existing;
printf("instance on show is %p\n", _instance);
@@ -334,17 +342,21 @@ static void clear_touches() {
delegateSetup = ![delegate respondsToSelector:@selector(setupView:)];
}
+@synthesize useCADisplayLink;
+
// If our view is resized, we'll be asked to layout subviews.
// This is the perfect opportunity to also update the framebuffer so that it is
// the same size as our display area.
-(void)layoutSubviews
{
- printf("HERE\n");
+ //printf("HERE\n");
[EAGLContext setCurrentContext:context];
[self destroyFramebuffer];
[self createFramebuffer];
[self drawView];
+ [self drawView];
+
}
- (BOOL)createFramebuffer
@@ -416,19 +428,21 @@ static void clear_touches() {
return;
active = TRUE;
printf("start animation!\n");
-#if USE_CADISPLAYLINK
- // Approximate frame rate
- // assumes device refreshes at 60 fps
- int frameInterval = (int) floor(animationInterval * 60.0f);
-
- displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)];
- [displayLink setFrameInterval:frameInterval];
-
- // Setup DisplayLink in main thread
- [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
-#else
- animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
-#endif
+ if (useCADisplayLink) {
+
+ // Approximate frame rate
+ // assumes device refreshes at 60 fps
+ int frameInterval = (int) floor(animationInterval * 60.0f);
+
+ displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)];
+ [displayLink setFrameInterval:frameInterval];
+
+ // Setup DisplayLink in main thread
+ [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
+ }
+ else {
+ animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
+ }
if (video_playing)
{
@@ -442,13 +456,16 @@ static void clear_touches() {
return;
active = FALSE;
printf("******** stop animation!\n");
-#if USE_CADISPLAYLINK
- [displayLink invalidate];
- displayLink = nil;
-#else
- [animationTimer invalidate];
- animationTimer = nil;
-#endif
+
+ if (useCADisplayLink) {
+ [displayLink invalidate];
+ displayLink = nil;
+ }
+ else {
+ [animationTimer invalidate];
+ animationTimer = nil;
+ }
+
clear_touches();
if (video_playing)
@@ -460,13 +477,7 @@ static void clear_touches() {
- (void)setAnimationInterval:(NSTimeInterval)interval
{
animationInterval = interval;
-
-#if USE_CADISPLAYLINK
- if(displayLink)
-#else
- if(animationTimer)
-#endif
- {
+ if ( (useCADisplayLink && displayLink) || ( !useCADisplayLink && animationTimer ) ) {
[self stopAnimation];
[self startAnimation];
}
@@ -475,16 +486,16 @@ static void clear_touches() {
// Updates the OpenGL view when the timer fires
- (void)drawView
{
-#if USE_CADISPLAYLINK
- // Pause the CADisplayLink to avoid recursion
- [displayLink setPaused: YES];
+ if (useCADisplayLink) {
+ // Pause the CADisplayLink to avoid recursion
+ [displayLink setPaused: YES];
- // Process all input events
- while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
+ // Process all input events
+ while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
- // We are good to go, resume the CADisplayLink
- [displayLink setPaused: NO];
-#endif
+ // We are good to go, resume the CADisplayLink
+ [displayLink setPaused: NO];
+ }
if (!active) {
printf("draw view not active!\n");
@@ -615,7 +626,7 @@ static void clear_touches() {
- (void)audioRouteChangeListenerCallback:(NSNotification*)notification
{
- printf("*********** route changed!%i\n");
+ printf("*********** route changed!\n");
NSDictionary *interuptionDict = notification.userInfo;
NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
@@ -630,7 +641,7 @@ static void clear_touches() {
case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable");
NSLog(@"Headphone/Line was pulled. Resuming video play....");
- if (_is_video_playing) {
+ if (_is_video_playing()) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[_instance.avPlayer play]; // NOTE: change this line according your current player implementation