gl_view.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*************************************************************************/
  2. /* gl_view.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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. @interface GLView : UIView <UIKeyInput> {
  38. @private
  39. // The pixel dimensions of the backbuffer
  40. GLint backingWidth;
  41. GLint backingHeight;
  42. EAGLContext *context;
  43. // OpenGL names for the renderbuffer and framebuffers used to render to this view
  44. GLuint viewRenderbuffer, viewFramebuffer;
  45. // OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist)
  46. GLuint depthRenderbuffer;
  47. BOOL useCADisplayLink;
  48. // 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
  49. CADisplayLink *displayLink;
  50. // An animation timer that, when animation is started, will periodically call -drawView at the given rate.
  51. // Only used if CADisplayLink is not
  52. NSTimer *animationTimer;
  53. NSTimeInterval animationInterval;
  54. // Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer.
  55. id<GLViewDelegate> delegate;
  56. // Flag to denote that the -setupView method of a delegate has been called.
  57. // Resets to NO whenever the delegate changes.
  58. BOOL delegateSetup;
  59. BOOL active;
  60. float screen_scale;
  61. }
  62. @property(nonatomic, assign) id<GLViewDelegate> delegate;
  63. // AVPlayer-related properties
  64. @property(strong, nonatomic) AVAsset *avAsset;
  65. @property(strong, nonatomic) AVPlayerItem *avPlayerItem;
  66. @property(strong, nonatomic) AVPlayer *avPlayer;
  67. @property(strong, nonatomic) AVPlayerLayer *avPlayerLayer;
  68. // Old videoplayer properties
  69. @property(strong, nonatomic) MPMoviePlayerController *moviePlayerController;
  70. @property(strong, nonatomic) UIWindow *backgroundWindow;
  71. @property(nonatomic) UITextAutocorrectionType autocorrectionType;
  72. - (void)startAnimation;
  73. - (void)stopAnimation;
  74. - (void)drawView;
  75. - (BOOL)canBecomeFirstResponder;
  76. - (void)open_keyboard;
  77. - (void)hide_keyboard;
  78. - (void)deleteBackward;
  79. - (BOOL)hasText;
  80. - (void)insertText:(NSString *)p_text;
  81. - (id)initGLES;
  82. - (BOOL)createFramebuffer;
  83. - (void)destroyFramebuffer;
  84. - (void)audioRouteChangeListenerCallback:(NSNotification *)notification;
  85. - (void)keyboardOnScreen:(NSNotification *)notification;
  86. - (void)keyboardHidden:(NSNotification *)notification;
  87. @property NSTimeInterval animationInterval;
  88. @property(nonatomic, assign) BOOL useCADisplayLink;
  89. @end
  90. @protocol GLViewDelegate <NSObject>
  91. @required
  92. // Draw with OpenGL ES
  93. - (void)drawView:(GLView *)view;
  94. @optional
  95. // Called whenever you need to do some initialization before rendering.
  96. - (void)setupView:(GLView *)view;
  97. @end