CCTexture2D Class Reference

#import <CCTexture2D.h>

List of all members.

Public Member Functions

(id) - initWithData:pixelFormat:pixelsWide:pixelsHigh:contentSize:
(void) - drawAtPoint:
(void) - drawInRect:
(void) - setTexParameters:
(void) - setAntiAliasTexParameters
(void) - setAliasTexParameters
(void) - generateMipmap
(id) - initWithImage:
(id) - initWithPVRTCData:level:bpp:hasAlpha:length:
(id) - initWithPVRTCFile:
(id) - initWithString:dimensions:alignment:fontName:fontSize:
(id) - initWithString:fontName:fontSize:

Static Public Member Functions

(void) + setDefaultAlphaPixelFormat:
(Texture2DPixelFormat) + defaultAlphaPixelFormat

Properties

Texture2DPixelFormat pixelFormat
NSUInteger pixelsWide
NSUInteger pixelsHigh
GLuint name
CGSize contentSize
GLfloat maxS
GLfloat maxT
BOOL hasPremultipliedAlpha

Detailed Description

CCTexture2D class This class allows to easily create OpenGL 2D textures from images, text or raw data. The created Texture2D object will always have power-of-two dimensions. Depending on how you create the Texture2D 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!

Definition at line 94 of file CCTexture2D.h.


Member Function Documentation

+ (Texture2DPixelFormat) defaultAlphaPixelFormat  

returns the alpha pixel format

Since:
v0.8
- (void) drawAtPoint: (CGPoint)  point  

draws a texture at a given point

- (void) drawInRect: (CGRect)  rect  

draws a texture inside a rect

- (void) generateMipmap  

Generates mipmap images for the texture

Since:
v0.99.0
- (id) initWithData: (const void *)  data
pixelFormat: (Texture2DPixelFormat)  pixelFormat
pixelsWide: (NSUInteger)  width
pixelsHigh: (NSUInteger)  height
contentSize: (CGSize)  size 

Intializes with a texture2d with data

- (id) initWithImage: (UIImage *)  uiImage  

Initializes a texture from a UIImage object

- (id) initWithPVRTCData: (const void *)  data
level: (int)  level
bpp: (int)  bpp
hasAlpha: (BOOL)  hasAlpha
length: (int)  length 

Initializes a texture from a PVRTC buffer

- (id) initWithPVRTCFile: (NSString *)  file  

Initializes a texture from a PVRTC file

- (id) initWithString: (NSString *)  string
dimensions: (CGSize)  dimensions
alignment: (UITextAlignment)  alignment
fontName: (NSString *)  name
fontSize: (CGFloat)  size 

Initializes a texture from a string with dimensions, alignment, font name and font size

- (id) initWithString: (NSString *)  string
fontName: (NSString *)  name
fontSize: (CGFloat)  size 

Initializes a texture from a string with font name and font size

- (void) setAliasTexParameters  

sets alias texture parameters: TEXTURE_MIN_FILTER = NEAREST TEXTURE_MAG_FILTER = NEAREST

Since:
v0.8
- (void) setAntiAliasTexParameters  

sets antialias texture parameters: TEXTURE_MIN_FILTER = LINEAR TEXTURE_MAG_FILTER = LINEAR

Since:
v0.8
+ (void) setDefaultAlphaPixelFormat: (Texture2DPixelFormat)  format  

sets the default pixel format for UIImages that contains alpha channel. If the UIImage contains alpha channel, then the options are:

  • generate 32-bit textures: RGBA8 (kTexture2DPixelFormat_RGBA8888)
  • generate 16-bit textures: RGBA4 (default: kTexture2DPixelFormat_RGBA4444)
  • generate 16-bit textures: RGB5A1 (kTexture2DPixelFormat_RGB5A1) You can also use the following option, but you will lose the alpha channel:
  • generate 16-bit textures: RGB565 (kTexture2DPixelFormat_RGB565)

To use this function you MUST disable the "compres .PNG files" in XCode, otherwise all your .PNG images will be pre-multiplied wihtout alpha channel.

Since:
v0.8
- (void) setTexParameters: (ccTexParams *)  texParams  

sets the min filter, mag filter, wrap s and wrap t texture parameters

Since:
v0.8

Property Documentation

- (CGSize) contentSize [read, assign]

content size

Definition at line 119 of file CCTexture2D.h.

- (BOOL) hasPremultipliedAlpha [read, assign]

whether or not the texture has their Alpha premultiplied

Definition at line 125 of file CCTexture2D.h.

- (GLfloat) maxS [read, write, assign]

texture max S

Definition at line 121 of file CCTexture2D.h.

- (GLfloat) maxT [read, write, assign]

texture max T

Definition at line 123 of file CCTexture2D.h.

- (GLuint) name [read, assign]

texture name

Definition at line 116 of file CCTexture2D.h.

- (Texture2DPixelFormat) pixelFormat [read, assign]

pixelFormat

Definition at line 109 of file CCTexture2D.h.

- (NSUInteger) pixelsHigh [read, assign]

hight in pixels

Definition at line 113 of file CCTexture2D.h.

- (NSUInteger) pixelsWide [read, assign]

width in pixels

Definition at line 111 of file CCTexture2D.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Properties Defines

cocos2d for iPhone 0.99.0