cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
/Users/rquesada/progs/cocos2d-iphone/cocos2d/CCTexture2D.h
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 <Availability.h>
00064 
00065 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
00066 #import <UIKit/UIKit.h>                 // for UIImage
00067 #endif
00068 
00069 #import <Foundation/Foundation.h> //    for NSObject
00070 
00071 #import "Platforms/CCGL.h" // OpenGL stuff
00072 #import "Platforms/CCNS.h" // Next-Step stuff
00073 
00074 //CONSTANTS:
00075 
00079 typedef enum {
00080         kCCTexture2DPixelFormat_Automatic = 0,
00082         kCCTexture2DPixelFormat_RGBA8888,
00084         kCCTexture2DPixelFormat_RGB565,
00086         kCCTexture2DPixelFormat_A8,
00088         kCCTexture2DPixelFormat_I8,
00090         kCCTexture2DPixelFormat_AI88,
00092         kCCTexture2DPixelFormat_RGBA4444,
00094         kCCTexture2DPixelFormat_RGB5A1, 
00096         kCCTexture2DPixelFormat_PVRTC4,
00098         kCCTexture2DPixelFormat_PVRTC2,
00099 
00101         kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888,
00102 
00103         // backward compatibility stuff
00104         kTexture2DPixelFormat_Automatic = kCCTexture2DPixelFormat_Automatic,
00105         kTexture2DPixelFormat_RGBA8888 = kCCTexture2DPixelFormat_RGBA8888,
00106         kTexture2DPixelFormat_RGB565 = kCCTexture2DPixelFormat_RGB565,
00107         kTexture2DPixelFormat_A8 = kCCTexture2DPixelFormat_A8,
00108         kTexture2DPixelFormat_RGBA4444 = kCCTexture2DPixelFormat_RGBA4444,
00109         kTexture2DPixelFormat_RGB5A1 = kCCTexture2DPixelFormat_RGB5A1,
00110         kTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_Default
00111         
00112 } CCTexture2DPixelFormat;
00113 
00114 //CLASS INTERFACES:
00115 
00122 @interface CCTexture2D : NSObject
00123 {
00124         GLuint                                          name_;
00125         CGSize                                          size_;
00126         NSUInteger                                      width_,
00127                                                                 height_;
00128         CCTexture2DPixelFormat          format_;
00129         GLfloat                                         maxS_,
00130                                                                 maxT_;
00131         BOOL                                            hasPremultipliedAlpha_;
00132 }
00134 - (id) initWithData:(const void*)data pixelFormat:(CCTexture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size;
00135 
00137 - (void) releaseData:(void*)data;
00138 - (void*) keepData:(void*)data length:(NSUInteger)length;
00139 
00141 @property(nonatomic,readonly) CCTexture2DPixelFormat pixelFormat;
00143 @property(nonatomic,readonly) NSUInteger pixelsWide;
00145 @property(nonatomic,readonly) NSUInteger pixelsHigh;
00146 
00148 @property(nonatomic,readonly) GLuint name;
00149 
00151 @property(nonatomic,readonly, nonatomic) CGSize contentSizeInPixels;
00152 
00154 @property(nonatomic,readwrite) GLfloat maxS;
00156 @property(nonatomic,readwrite) GLfloat maxT;
00158 @property(nonatomic,readonly) BOOL hasPremultipliedAlpha;
00159 
00161 -(CGSize) contentSize;
00162 @end
00163 
00168 @interface CCTexture2D (Drawing)
00170 - (void) drawAtPoint:(CGPoint)point;
00172 - (void) drawInRect:(CGRect)rect;
00173 @end
00174 
00179 @interface CCTexture2D (Image)
00181 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
00182 - (id) initWithImage:(UIImage *)uiImage;
00183 #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
00184 - (id) initWithImage:(CGImageRef)cgImage;
00185 #endif
00186 @end
00187 
00192 @interface CCTexture2D (Text)
00199 - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size;
00201 - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size;
00203 - (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size;
00204 @end
00205 
00206 
00211 @interface CCTexture2D (PVRSupport)
00216 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
00217 -(id) initWithPVRTCData: (const void*)data level:(int)level bpp:(int)bpp hasAlpha:(BOOL)hasAlpha length:(int)length pixelFormat:(CCTexture2DPixelFormat)pixelFormat;
00218 #endif // __IPHONE_OS_VERSION_MAX_ALLOWED
00219 
00239 -(id) initWithPVRFile: (NSString*) file;
00240 
00249 +(void) PVRImagesHavePremultipliedAlpha:(BOOL)haveAlphaPremultiplied;
00250 @end
00251 
00255 typedef struct _ccTexParams {
00256         GLuint  minFilter;
00257         GLuint  magFilter;
00258         GLuint  wrapS;
00259         GLuint  wrapT;
00260 } ccTexParams;
00261 
00262 @interface CCTexture2D (GLFilter)
00267 -(void) setTexParameters: (ccTexParams*) texParams;
00268 
00275 - (void) setAntiAliasTexParameters;
00276 
00283 - (void) setAliasTexParameters;
00284 
00285 
00290 -(void) generateMipmap;
00291 
00292 
00293 @end
00294 
00295 @interface CCTexture2D (PixelFormat)
00312 +(void) setDefaultAlphaPixelFormat:(CCTexture2DPixelFormat)format;
00313 
00317 +(CCTexture2DPixelFormat) defaultAlphaPixelFormat;
00318 
00322 -(NSUInteger) bitsPerPixelForFormat;
00323 @end
00324 
00325 
00326 
00327 
00328 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone API Reference - Generated using Doxygen 1.7.4