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: Texture2D.h 00019 Abstract: Creates OpenGL 2D textures from images or text. 00020 00021 Version: 1.6 00022 00023 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. 00024 ("Apple") in consideration of your agreement to the following terms, and your 00025 use, installation, modification or redistribution of this Apple software 00026 constitutes acceptance of these terms. If you do not agree with these terms, 00027 please do not use, install, modify or redistribute this Apple software. 00028 00029 In consideration of your agreement to abide by the following terms, and subject 00030 to these terms, Apple grants you a personal, non-exclusive license, under 00031 Apple's copyrights in this original Apple software (the "Apple Software"), to 00032 use, reproduce, modify and redistribute the Apple Software, with or without 00033 modifications, in source and/or binary forms; provided that if you redistribute 00034 the Apple Software in its entirety and without modifications, you must retain 00035 this notice and the following text and disclaimers in all such redistributions 00036 of the Apple Software. 00037 Neither the name, trademarks, service marks or logos of Apple Inc. may be used 00038 to endorse or promote products derived from the Apple Software without specific 00039 prior written permission from Apple. Except as expressly stated in this notice, 00040 no other rights or licenses, express or implied, are granted by Apple herein, 00041 including but not limited to any patent rights that may be infringed by your 00042 derivative works or by other works in which the Apple Software may be 00043 incorporated. 00044 00045 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 00046 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 00047 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00048 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 00049 COMBINATION WITH YOUR PRODUCTS. 00050 00051 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 00052 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00053 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00054 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR 00055 DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF 00056 CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 00057 APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00058 00059 Copyright (C) 2008 Apple Inc. All Rights Reserved. 00060 00061 */ 00062 00063 #import <UIKit/UIKit.h> 00064 #import <OpenGLES/ES1/gl.h> 00065 00066 //CONSTANTS: 00067 00069 typedef enum { 00070 kTexture2DPixelFormat_Automatic = 0, 00072 kTexture2DPixelFormat_RGBA8888, 00074 kTexture2DPixelFormat_RGB565, 00076 kTexture2DPixelFormat_A8, 00078 kTexture2DPixelFormat_RGBA4444, 00080 kTexture2DPixelFormat_RGB5A1, 00081 } Texture2DPixelFormat; 00082 00084 #define kTexture2DPixelFormat_Default kTexture2DPixelFormat_RGBA8888 00085 00086 //CLASS INTERFACES: 00087 00094 @interface CCTexture2D : NSObject 00095 { 00096 GLuint _name; 00097 CGSize _size; 00098 NSUInteger _width, 00099 _height; 00100 Texture2DPixelFormat _format; 00101 GLfloat _maxS, 00102 _maxT; 00103 BOOL _hasPremultipliedAlpha; 00104 } 00106 - (id) initWithData:(const void*)data pixelFormat:(Texture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size; 00107 00109 @property(nonatomic,readonly) Texture2DPixelFormat pixelFormat; 00111 @property(nonatomic,readonly) NSUInteger pixelsWide; 00113 @property(nonatomic,readonly) NSUInteger pixelsHigh; 00114 00116 @property(nonatomic,readonly) GLuint name; 00117 00119 @property(nonatomic,readonly, nonatomic) CGSize contentSize; 00121 @property(nonatomic,readwrite) GLfloat maxS; 00123 @property(nonatomic,readwrite) GLfloat maxT; 00125 @property(nonatomic,readonly) BOOL hasPremultipliedAlpha; 00126 @end 00127 00132 @interface CCTexture2D (Drawing) 00134 - (void) drawAtPoint:(CGPoint)point; 00136 - (void) drawInRect:(CGRect)rect; 00137 @end 00138 00143 @interface CCTexture2D (Image) 00145 - (id) initWithImage:(UIImage *)uiImage; 00146 @end 00147 00152 @interface CCTexture2D (Text) 00154 - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(UITextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size; 00156 - (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size; 00157 @end 00158 00163 @interface CCTexture2D (PVRTC) 00165 -(id) initWithPVRTCData: (const void*)data level:(int)level bpp:(int)bpp hasAlpha:(BOOL)hasAlpha length:(int)length; 00167 -(id) initWithPVRTCFile: (NSString*) file; 00168 @end 00169 00173 typedef struct _ccTexParams { 00174 GLuint minFilter; 00175 GLuint magFilter; 00176 GLuint wrapS; 00177 GLuint wrapT; 00178 } ccTexParams; 00179 00180 @interface CCTexture2D (GLFilter) 00184 -(void) setTexParameters: (ccTexParams*) texParams; 00185 00191 - (void) setAntiAliasTexParameters; 00192 00198 - (void) setAliasTexParameters; 00199 00200 00204 -(void) generateMipmap; 00205 00206 00207 @end 00208 00209 @interface CCTexture2D (PixelFormat) 00222 +(void) setDefaultAlphaPixelFormat:(Texture2DPixelFormat)format; 00223 00227 +(Texture2DPixelFormat) defaultAlphaPixelFormat; 00228 @end 00229 00230 00231