5 // Created by Frédéric D'HAEYER on 16/10/09.
6 // Copyright Parrot SA 2009. All rights reserved.
9 #import "ES1Renderer.h"
11 @implementation EAGLView
12 @synthesize animating;
13 @dynamic animationFrameInterval;
15 // You must implement this method
18 return [CAEAGLLayer class];
21 //The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
22 //- (id) initWithCoder:(NSCoder*)coder
24 // if ((self = [super initWithCoder:coder]))
25 - (id)initWithFrame:(CGRect)frame
27 if ((self = [super initWithFrame: frame]))
30 CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
32 eaglLayer.opaque = NO;
33 eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
34 [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
37 renderer = [[ES1Renderer alloc] init];
46 animationFrameInterval = 2; // is 2 * (1 / 60) = 1 / 30 <=> 30 fps
53 - (void) setDrone:(ARDrone*)_drone
60 [renderer render:drone];
63 - (void) layoutSubviews
65 [renderer resizeFromLayer:(CAEAGLLayer*)self.layer];
69 - (NSInteger) animationFrameInterval
71 return animationFrameInterval;
74 - (void)changeState:(BOOL)inGame
81 animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval) target:self selector:@selector(drawView) userInfo:nil repeats:TRUE];
90 [animationTimer invalidate];