gl_view.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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-2014 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. @protocol GLViewDelegate;
  36. @interface GLView : UIView<UIKeyInput>
  37. {
  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. // An animation timer that, when animation is started, will periodically call -drawView at the given rate.
  48. NSTimer *animationTimer;
  49. NSTimeInterval animationInterval;
  50. // Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer.
  51. id<GLViewDelegate> delegate;
  52. // Flag to denote that the -setupView method of a delegate has been called.
  53. // Resets to NO whenever the delegate changes.
  54. BOOL delegateSetup;
  55. BOOL active;
  56. float screen_scale;
  57. }
  58. @property(nonatomic, assign) id<GLViewDelegate> delegate;
  59. // AVPlayer-related properties
  60. @property(strong, nonatomic) AVAsset *avAsset;
  61. @property(strong, nonatomic) AVPlayerItem *avPlayerItem;
  62. @property(strong, nonatomic) AVPlayer *avPlayer;
  63. @property(strong, nonatomic) AVPlayerLayer *avPlayerLayer;
  64. // Old videoplayer properties
  65. @property(strong, nonatomic) MPMoviePlayerController *moviePlayerController;
  66. @property(strong, nonatomic) UIWindow *backgroundWindow;
  67. -(void)startAnimation;
  68. -(void)stopAnimation;
  69. -(void)drawView;
  70. - (BOOL)canBecomeFirstResponder;
  71. - (void)open_keyboard;
  72. - (void)hide_keyboard;
  73. - (void)deleteBackward;
  74. - (BOOL)hasText;
  75. - (void)insertText:(NSString *)p_text;
  76. - (id)initGLES;
  77. - (BOOL)createFramebuffer;
  78. - (void)destroyFramebuffer;
  79. - (void)audioRouteChangeListenerCallback:(NSNotification*)notification;
  80. @property NSTimeInterval animationInterval;
  81. @end
  82. @protocol GLViewDelegate<NSObject>
  83. @required
  84. // Draw with OpenGL ES
  85. -(void)drawView:(GLView*)view;
  86. @optional
  87. // Called whenever you need to do some initialization before rendering.
  88. -(void)setupView:(GLView*)view;
  89. @end