2 * Copyright (C) 2010-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #import <UIKit/UIKit.h>
22 #import <OpenGLES/EAGL.h>
23 #import <OpenGLES/ES2/gl.h>
25 // This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
26 // The view content is basically an EAGL surface you render your OpenGL scene into.
27 // Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
28 @interface IOSEAGLView : UIView
32 // The pixel dimensions of the CAEAGLLayer.
33 GLint framebufferWidth;
34 GLint framebufferHeight;
35 // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view.
36 GLuint defaultFramebuffer, colorRenderbuffer, depthRenderbuffer;
37 // the shader program object
45 NSConditionLock* animationThreadLock;
46 NSThread* animationThread;
47 UIScreen *currentScreen;
49 // Use of the CADisplayLink class is the preferred method for controlling the animation timing.
50 // CADisplayLink will link to the main display and fire every vsync when added to a given run-loop.
51 CADisplayLink *displayLink;
52 CFTimeInterval displayFPS;
53 BOOL displayLinkSupported;
54 BOOL framebufferResizeRequested;
56 @property (readonly, nonatomic, getter=isAnimating) BOOL animating;
57 @property (readonly, nonatomic, getter=isXBMCAlive) BOOL xbmcAlive;
58 @property (readonly, nonatomic, getter=isPause) BOOL pause;
59 @property (readonly, getter=getCurrentScreen) UIScreen *currentScreen;
60 @property BOOL framebufferResizeRequested;
62 - (id)initWithFrame:(CGRect)frame withScreen:(UIScreen *)screen;
63 - (void) initDisplayLink;
64 - (void) deinitDisplayLink;
65 - (double) getDisplayLinkFPS;
66 - (void) pauseAnimation;
67 - (void) resumeAnimation;
68 - (void) startAnimation;
69 - (void) stopAnimation;
70 - (void) setFramebuffer;
71 - (bool) presentFramebuffer;
72 - (void) setScreen:(UIScreen *)screen withFrameBufferResize:(BOOL)resize;
73 - (CGFloat) getScreenScale:(UIScreen *)screen;