![]() |
cocos2d-iphone
1.0.1
Improved Cocos2D API Reference (iOS version) for Kobold2D developers
|
#include <CCTexture2D.h>
Public Member Functions | |
id | initWithData:pixelFormat:pixelsWide:pixelsHigh:contentSize: (const void *data,[pixelFormat] CCTexture2DPixelFormat pixelFormat,[pixelsWide] NSUInteger width,[pixelsHigh] NSUInteger height,[contentSize] CGSize size) |
void | releaseData: (void *data) |
void * | keepData:length: (void *data,[length] NSUInteger length) |
CGSize | contentSize () |
void | drawAtPoint: (CGPoint point) |
void | drawInRect: (CGRect rect) |
void | setTexParameters: (ccTexParams *texParams) |
void | setAntiAliasTexParameters () |
void | setAliasTexParameters () |
void | generateMipmap () |
id | initWithImage: (UIImage *uiImage) |
NSUInteger | bitsPerPixelForFormat () |
id | initWithPVRTCData:level:bpp:hasAlpha:length:pixelFormat: (const void *data,[level] int level,[bpp] int bpp,[hasAlpha] BOOL hasAlpha,[length] int length,[pixelFormat] CCTexture2DPixelFormat pixelFormat) |
id | initWithPVRFile: (NSString *file) |
id | initWithString:dimensions:alignment:lineBreakMode:fontName:fontSize: (NSString *string,[dimensions] CGSize dimensions,[alignment] CCTextAlignment alignment,[lineBreakMode] CCLineBreakMode lineBreakMode,[fontName] NSString *name,[fontSize] CGFloat size) |
id | initWithString:dimensions:alignment:fontName:fontSize: (NSString *string,[dimensions] CGSize dimensions,[alignment] CCTextAlignment alignment,[fontName] NSString *name,[fontSize] CGFloat size) |
id | initWithString:fontName:fontSize: (NSString *string,[fontName] NSString *name,[fontSize] CGFloat size) |
Static Public Member Functions | |
void | setDefaultAlphaPixelFormat: (CCTexture2DPixelFormat format) |
CCTexture2DPixelFormat | defaultAlphaPixelFormat () |
void | PVRImagesHavePremultipliedAlpha: (BOOL haveAlphaPremultiplied) |
Protected Attributes | |
GLuint | name_ |
CGSize | size_ |
NSUInteger | width_ |
NSUInteger | height_ |
CCTexture2DPixelFormat | format_ |
GLfloat | maxS_ |
GLfloat | maxT_ |
BOOL | hasPremultipliedAlpha_ |
Properties | |
CCTexture2DPixelFormat | pixelFormat |
NSUInteger | pixelsWide |
NSUInteger | pixelsHigh |
GLuint | name |
CGSize | contentSizeInPixels |
GLfloat | maxS |
GLfloat | maxT |
BOOL | hasPremultipliedAlpha |
CCTexture2D class. This class allows to easily create OpenGL 2D textures from images, text or raw data. The created CCTexture2D object will always have power-of-two dimensions. Depending on how you create the CCTexture2D object, the actual image area of the texture might be smaller than the texture dimensions i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). Be aware that the content of the generated textures will be upside-down!
NSUInteger CCTexture2D(PixelFormat)::bitsPerPixelForFormat | ( | ) | [virtual] |
returns the bits-per-pixel of the in-memory OpenGL texture
CGSize CCTexture2D::contentSize | ( | ) | [virtual] |
returns the content size of the texture in points
CCTexture2DPixelFormat CCTexture2D(PixelFormat)::defaultAlphaPixelFormat | ( | ) | [static, virtual] |
returns the alpha pixel format
void CCTexture2D(Drawing)::drawAtPoint: | ( | CGPoint | point | ) | [virtual] |
draws a texture at a given point
void CCTexture2D(Drawing)::drawInRect: | ( | CGRect | rect | ) | [virtual] |
draws a texture inside a rect
void CCTexture2D(GLFilter)::generateMipmap | ( | ) | [virtual] |
Generates mipmap images for the texture. It only works if the texture size is POT (power of 2).
id CCTexture2D::initWithData:pixelFormat:pixelsWide:pixelsHigh:contentSize: | ( | const void * | data, |
[pixelFormat] CCTexture2DPixelFormat | pixelFormat, | ||
[pixelsWide] NSUInteger | width, | ||
[pixelsHigh] NSUInteger | height, | ||
[contentSize] CGSize | size | ||
) | [virtual] |
Intializes with a texture2d with data
id CCTexture2D(Image)::initWithImage: | ( | UIImage * | uiImage | ) | [virtual] |
Initializes a texture from a UIImage object
id CCTexture2D(PVRSupport)::initWithPVRFile: | ( | NSString * | file | ) | [virtual] |
Initializes a texture from a PVR file.
Supported PVR formats:
By default PVR images are treated as if they alpha channel is NOT premultiplied. You can override this behavior with this class method:
IMPORTANT: This method is only defined on iOS. It is not supported on the Mac version.
id CCTexture2D(PVRSupport)::initWithPVRTCData:level:bpp:hasAlpha:length:pixelFormat: | ( | const void * | data, |
[level] int | level, | ||
[bpp] int | bpp, | ||
[hasAlpha] BOOL | hasAlpha, | ||
[length] int | length, | ||
[pixelFormat] CCTexture2DPixelFormat | pixelFormat | ||
) | [virtual] |
Initializes a texture from a PVR Texture Compressed (PVRTC) buffer
IMPORTANT: This method is only defined on iOS. It is not supported on the Mac version.
id CCTexture2D(Text)::initWithString:dimensions:alignment:fontName:fontSize: | ( | NSString * | string, |
[dimensions] CGSize | dimensions, | ||
[alignment] CCTextAlignment | alignment, | ||
[fontName] NSString * | name, | ||
[fontSize] CGFloat | size | ||
) | [virtual] |
Initializes a texture from a string with dimensions, alignment, font name and font size
id CCTexture2D(Text)::initWithString:dimensions:alignment:lineBreakMode:fontName:fontSize: | ( | NSString * | string, |
[dimensions] CGSize | dimensions, | ||
[alignment] CCTextAlignment | alignment, | ||
[lineBreakMode] CCLineBreakMode | lineBreakMode, | ||
[fontName] NSString * | name, | ||
[fontSize] CGFloat | size | ||
) | [virtual] |
Initializes a texture from a string with dimensions, alignment, line break mode, font name and font size Supported lineBreakModes:
id CCTexture2D(Text)::initWithString:fontName:fontSize: | ( | NSString * | string, |
[fontName] NSString * | name, | ||
[fontSize] CGFloat | size | ||
) | [virtual] |
Initializes a texture from a string with font name and font size
void CCTexture2D(PVRSupport)::PVRImagesHavePremultipliedAlpha: | ( | BOOL | haveAlphaPremultiplied | ) | [static, virtual] |
treats (or not) PVR files as if they have alpha premultiplied. Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
void CCTexture2D::releaseData: | ( | void * | data | ) | [virtual] |
These functions are needed to create mutable textures
void CCTexture2D(GLFilter)::setAliasTexParameters | ( | ) | [virtual] |
sets alias texture parameters:
void CCTexture2D(GLFilter)::setAntiAliasTexParameters | ( | ) | [virtual] |
sets antialias texture parameters:
void CCTexture2D(PixelFormat)::setDefaultAlphaPixelFormat: | ( | CCTexture2DPixelFormat | format | ) | [static, virtual] |
sets the default pixel format for UIImages that contains alpha channel. If the UIImage contains alpha channel, then the options are:
How does it work ?
This parameter is not valid for PVR images.
void CCTexture2D(GLFilter)::setTexParameters: | ( | ccTexParams * | texParams | ) | [virtual] |
sets the min filter, mag filter, wrap s and wrap t texture parameters. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
CGSize CCTexture2D::contentSizeInPixels [read, assign] |
returns content size of the texture in pixels
BOOL CCTexture2D::hasPremultipliedAlpha [read, assign] |
whether or not the texture has their Alpha premultiplied
GLfloat CCTexture2D::maxS [read, write, assign] |
texture max S
GLfloat CCTexture2D::maxT [read, write, assign] |
texture max T
GLuint CCTexture2D::name [read, assign] |
texture name
CCTexture2DPixelFormat CCTexture2D::pixelFormat [read, assign] |
pixel format of the texture
NSUInteger CCTexture2D::pixelsHigh [read, assign] |
hight in pixels
NSUInteger CCTexture2D::pixelsWide [read, assign] |
width in pixels