00001 /* 00002 00003 ===== IMPORTANT ===== 00004 00005 This is sample code demonstrating API, technology or techniques in development. 00006 Although this sample code has been reviewed for technical accuracy, it is not 00007 final. Apple is supplying this information to help you plan for the adoption of 00008 the technologies and programming interfaces described herein. This information 00009 is subject to change, and software implemented based on this sample code should 00010 be tested with final operating system software and final documentation. Newer 00011 versions of this sample code may be provided with future seeds of the API or 00012 technology. For information about updates to this and other developer 00013 documentation, view the New & Updated sidebars in subsequent documentation 00014 seeds. 00015 00016 ===================== 00017 00018 File: EAGLView.h 00019 Abstract: Convenience class that wraps the CAEAGLLayer from CoreAnimation into a 00020 UIView subclass. 00021 00022 Version: 1.3 00023 00024 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. 00025 ("Apple") in consideration of your agreement to the following terms, and your 00026 use, installation, modification or redistribution of this Apple software 00027 constitutes acceptance of these terms. If you do not agree with these terms, 00028 please do not use, install, modify or redistribute this Apple software. 00029 00030 In consideration of your agreement to abide by the following terms, and subject 00031 to these terms, Apple grants you a personal, non-exclusive license, under 00032 Apple's copyrights in this original Apple software (the "Apple Software"), to 00033 use, reproduce, modify and redistribute the Apple Software, with or without 00034 modifications, in source and/or binary forms; provided that if you redistribute 00035 the Apple Software in its entirety and without modifications, you must retain 00036 this notice and the following text and disclaimers in all such redistributions 00037 of the Apple Software. 00038 Neither the name, trademarks, service marks or logos of Apple Inc. may be used 00039 to endorse or promote products derived from the Apple Software without specific 00040 prior written permission from Apple. Except as expressly stated in this notice, 00041 no other rights or licenses, express or implied, are granted by Apple herein, 00042 including but not limited to any patent rights that may be infringed by your 00043 derivative works or by other works in which the Apple Software may be 00044 incorporated. 00045 00046 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 00047 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 00048 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00049 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 00050 COMBINATION WITH YOUR PRODUCTS. 00051 00052 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 00053 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00054 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00055 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR 00056 DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF 00057 CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 00058 APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00059 00060 Copyright (C) 2008 Apple Inc. All Rights Reserved. 00061 00062 */ 00063 00064 #import <UIKit/UIKit.h> 00065 #import <OpenGLES/EAGL.h> 00066 #import <OpenGLES/EAGLDrawable.h> 00067 #import <OpenGLES/ES1/gl.h> 00068 #import <OpenGLES/ES1/glext.h> 00069 00070 #import "ESRenderer.h" 00071 00072 //CLASSES: 00073 00074 @class EAGLView; 00075 00076 //PROTOCOLS: 00077 00078 @protocol EAGLTouchDelegate <NSObject> 00079 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; 00080 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; 00081 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; 00082 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; 00083 @end 00084 00085 //CLASS INTERFACE: 00086 00092 @interface EAGLView : UIView 00093 { 00094 id <ESRenderer> renderer_; 00095 EAGLContext *context_; // weak ref 00096 00097 NSString *pixelformat_; 00098 GLuint depthFormat_; 00099 00100 CGSize size_; 00101 BOOL discardFramebufferSupported_; 00102 id<EAGLTouchDelegate> touchDelegate_; 00103 } 00104 00106 + (id) viewWithFrame:(CGRect)frame; 00108 + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format; 00110 + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained; 00111 00112 00114 - (id) initWithFrame:(CGRect)frame; //These also set the current context 00116 - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format; 00118 - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained; 00119 00121 @property(nonatomic,readonly) NSString* pixelFormat; 00123 @property(nonatomic,readonly) GLuint depthFormat; 00124 00126 @property(nonatomic,readonly) CGSize surfaceSize; 00127 00129 @property(nonatomic,readonly) EAGLContext *context; 00130 00132 @property(nonatomic,readwrite,assign) id<EAGLTouchDelegate> touchDelegate; 00133 00135 -(void) swapBuffers; 00136 00137 - (CGPoint) convertPointFromViewToSurface:(CGPoint)point; 00138 - (CGRect) convertRectFromViewToSurface:(CGRect)rect; 00139 @end