Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions Source/HYPSignatureView.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,47 +116,56 @@ @implementation HYPSignatureView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) return nil;

[self initialize];
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (!self) return nil;

[self initialize];
return self;
}

- (void)initialize {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!context) {
[NSException raise:@"NSOpenGLES2ContextException" format:@"Failed to create OpenGL ES2 context"];
return nil;
}

time(NULL);

self.backgroundColor = [UIColor whiteColor];
self.opaque = NO;

self.context = context;
self.drawableDepthFormat = GLKViewDrawableDepthFormat24;
self.enableSetNeedsDisplay = YES;

// Turn on antialiasing
self.drawableMultisample = GLKViewDrawableMultisample4X;

[self setupGL];

// Capture touches
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
pan.maximumNumberOfTouches = pan.minimumNumberOfTouches = 1;
pan.cancelsTouchesInView = YES;
[self addGestureRecognizer:pan];

// For dotting your i's
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
tap.cancelsTouchesInView = YES;
[self addGestureRecognizer:tap];

// Erase with long press
UILongPressGestureRecognizer *longer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
longer.cancelsTouchesInView = YES;
[self addGestureRecognizer:longer];

return self;
}


- (void)dealloc {
[self tearDownGL];

Expand Down