gl_view.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*************************************************************************/
  2. /* gl_view.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #import <UIKit/UIKit.h>
  30. #import <OpenGLES/EAGL.h>
  31. #import <OpenGLES/ES1/gl.h>
  32. #import <OpenGLES/ES1/glext.h>
  33. #import <MediaPlayer/MediaPlayer.h>
  34. #import <AVFoundation/AVFoundation.h>
  35. #define USE_CADISPLAYLINK 1 //iOS version 3.1+ is required
  36. @protocol GLViewDelegate;
  37. @interface GLView : UIView<UIKeyInput>
  38. {
  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. #if USE_CADISPLAYLINK
  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. #else
  52. // An animation timer that, when animation is started, will periodically call -drawView at the given rate.
  53. NSTimer *animationTimer;
  54. #endif
  55. NSTimeInterval animationInterval;
  56. // Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer.
  57. id<GLViewDelegate> delegate;
  58. // Flag to denote that the -setupView method of a delegate has been called.
  59. // Resets to NO whenever the delegate changes.
  60. BOOL delegateSetup;
  61. BOOL active;
  62. float screen_scale;
  63. }
  64. @property(nonatomic, assign) id<GLViewDelegate> delegate;
  65. // AVPlayer-related properties
  66. @property(strong, nonatomic) AVAsset *avAsset;
  67. @property(strong, nonatomic) AVPlayerItem *avPlayerItem;
  68. @property(strong, nonatomic) AVPlayer *avPlayer;
  69. @property(strong, nonatomic) AVPlayerLayer *avPlayerLayer;
  70. // Old videoplayer properties
  71. @property(strong, nonatomic) MPMoviePlayerController *moviePlayerController;
  72. @property(strong, nonatomic) UIWindow *backgroundWindow;
  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. @property NSTimeInterval animationInterval;
  87. @end
  88. @protocol GLViewDelegate<NSObject>
  89. @required
  90. // Draw with OpenGL ES
  91. -(void)drawView:(GLView*)view;
  92. @optional
  93. // Called whenever you need to do some initialization before rendering.
  94. -(void)setupView:(GLView*)view;
  95. @end