gl_view.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*************************************************************************/
  2. /* gl_view.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #import <AVFoundation/AVFoundation.h>
  31. #import <MediaPlayer/MediaPlayer.h>
  32. #import <OpenGLES/EAGL.h>
  33. #import <OpenGLES/ES1/gl.h>
  34. #import <OpenGLES/ES1/glext.h>
  35. #import <UIKit/UIKit.h>
  36. @protocol GLViewDelegate;
  37. @class GLViewGestureRecognizer;
  38. @interface GLView : UIView <UIKeyInput> {
  39. @private
  40. // The pixel dimensions of the backbuffer
  41. GLint backingWidth;
  42. GLint backingHeight;
  43. EAGLContext *context;
  44. // OpenGL names for the renderbuffer and framebuffers used to render to this view
  45. GLuint viewRenderbuffer, viewFramebuffer;
  46. // OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist)
  47. GLuint depthRenderbuffer;
  48. BOOL useCADisplayLink;
  49. // CADisplayLink available on 3.1+ synchronizes the animation timer & drawing with the refresh rate of the display, only supports animation intervals of 1/60 1/30 & 1/15
  50. CADisplayLink *displayLink;
  51. // An animation timer that, when animation is started, will periodically call -drawView at the given rate.
  52. // Only used if CADisplayLink is not
  53. NSTimer *animationTimer;
  54. NSTimeInterval animationInterval;
  55. // Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer.
  56. id<GLViewDelegate> delegate;
  57. // Flag to denote that the -setupView method of a delegate has been called.
  58. // Resets to NO whenever the delegate changes.
  59. BOOL delegateSetup;
  60. BOOL active;
  61. float screen_scale;
  62. // Delay gesture recognizer
  63. GLViewGestureRecognizer *delayGestureRecognizer;
  64. }
  65. @property(nonatomic, assign) id<GLViewDelegate> delegate;
  66. // AVPlayer-related properties
  67. @property(strong, nonatomic) AVAsset *avAsset;
  68. @property(strong, nonatomic) AVPlayerItem *avPlayerItem;
  69. @property(strong, nonatomic) AVPlayer *avPlayer;
  70. @property(strong, nonatomic) AVPlayerLayer *avPlayerLayer;
  71. @property(strong, nonatomic) UIWindow *backgroundWindow;
  72. @property(nonatomic) UITextAutocorrectionType autocorrectionType;
  73. - (void)startAnimation;
  74. - (void)stopAnimation;
  75. - (void)drawView;
  76. - (BOOL)canBecomeFirstResponder;
  77. - (void)open_keyboard;
  78. - (void)hide_keyboard;
  79. - (void)deleteBackward;
  80. - (BOOL)hasText;
  81. - (void)insertText:(NSString *)p_text;
  82. - (id)initGLES;
  83. - (BOOL)createFramebuffer;
  84. - (void)destroyFramebuffer;
  85. - (void)audioRouteChangeListenerCallback:(NSNotification *)notification;
  86. - (void)keyboardOnScreen:(NSNotification *)notification;
  87. - (void)keyboardHidden:(NSNotification *)notification;
  88. @property(nonatomic, assign) NSTimeInterval animationInterval;
  89. @property(nonatomic, assign) BOOL useCADisplayLink;
  90. @end
  91. @protocol GLViewDelegate <NSObject>
  92. @required
  93. // Draw with OpenGL ES
  94. - (void)drawView:(GLView *)view;
  95. @optional
  96. // Called whenever you need to do some initialization before rendering.
  97. - (void)setupView:(GLView *)view;
  98. @end