2016-03-05 19:45:09 +00:00
|
|
|
//
|
|
|
|
// CSOpenGLView.h
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/07/2015.
|
|
|
|
// Copyright © 2015 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#import <AppKit/AppKit.h>
|
|
|
|
|
|
|
|
@class CSOpenGLView;
|
|
|
|
|
|
|
|
@protocol CSOpenGLViewDelegate
|
2016-03-13 17:38:03 +00:00
|
|
|
/*!
|
|
|
|
Requests that the delegate produce an image of its current output state. May be called on
|
|
|
|
any queue or thread.
|
|
|
|
@param view The view makin the request.
|
|
|
|
@param onlyIfDirty If @c YES then the delegate may decline to redraw if its output would be
|
|
|
|
identical to the previous frame. If @c NO then the delegate must draw.
|
|
|
|
*/
|
2016-03-05 19:45:09 +00:00
|
|
|
- (void)openGLView:(nonnull CSOpenGLView *)view drawViewOnlyIfDirty:(BOOL)onlyIfDirty;
|
2016-03-20 02:46:17 +00:00
|
|
|
|
2016-03-05 19:45:09 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol CSOpenGLViewResponderDelegate <NSObject>
|
2016-03-13 17:38:03 +00:00
|
|
|
/*!
|
|
|
|
Supplies a keyDown event to the delegate. Will always be called on the same queue as the other
|
|
|
|
@c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:].
|
|
|
|
@param event The @c NSEvent describing the keyDown.
|
|
|
|
*/
|
2016-03-05 19:45:09 +00:00
|
|
|
- (void)keyDown:(nonnull NSEvent *)event;
|
2016-03-13 17:38:03 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Supplies a keyUp event to the delegate. Will always be called on the same queue as the other
|
|
|
|
@c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:].
|
|
|
|
@param event The @c NSEvent describing the keyUp.
|
|
|
|
*/
|
2016-03-05 19:45:09 +00:00
|
|
|
- (void)keyUp:(nonnull NSEvent *)event;
|
2016-03-13 17:38:03 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Supplies a flagsChanged event to the delegate. Will always be called on the same queue as the other
|
|
|
|
@c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:].
|
|
|
|
@param event The @c NSEvent describing the flagsChanged.
|
|
|
|
*/
|
2016-03-05 19:45:09 +00:00
|
|
|
- (void)flagsChanged:(nonnull NSEvent *)newModifiers;
|
2016-03-13 17:38:03 +00:00
|
|
|
|
2016-03-05 19:45:09 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides an OpenGL canvas with a refresh-linked update timer and manages a serial dispatch queue
|
|
|
|
such that a delegate may produce video and respond to keyboard events.
|
|
|
|
*/
|
|
|
|
@interface CSOpenGLView : NSOpenGLView
|
|
|
|
|
2017-02-11 17:58:47 +00:00
|
|
|
@property (atomic, weak, nullable) id <CSOpenGLViewDelegate> delegate;
|
2016-06-23 13:37:49 +00:00
|
|
|
@property (nonatomic, weak, nullable) id <CSOpenGLViewResponderDelegate> responderDelegate;
|
2016-03-05 19:45:09 +00:00
|
|
|
|
2016-03-13 17:38:03 +00:00
|
|
|
/*!
|
|
|
|
Ends the timer tracking time; should be called prior to giving up the last owning reference
|
|
|
|
to ensure that any retain cycles implied by the timer are resolved.
|
|
|
|
*/
|
2016-03-05 19:45:09 +00:00
|
|
|
- (void)invalidate;
|
|
|
|
|
2016-03-13 17:38:03 +00:00
|
|
|
/// The size in pixels of the OpenGL canvas, factoring in screen pixel density and view size in points.
|
2016-03-05 19:45:09 +00:00
|
|
|
@property (nonatomic, readonly) CGSize backingSize;
|
|
|
|
|
2016-03-20 02:46:17 +00:00
|
|
|
- (void)performWithGLContext:(nonnull dispatch_block_t)action;
|
|
|
|
|
2016-03-05 19:45:09 +00:00
|
|
|
@end
|