Public Member Functions | Static Public Member Functions | Properties

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:
(CCTexture2DPixelFormat) + defaultAlphaPixelFormat

Properties

CCTexture2DPixelFormat 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 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!

Definition at line 106 of file CCTexture2D.h.


Member Function Documentation

+ (CCTexture2DPixelFormat) 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. It only works if the texture size is POT (power of 2).

Since:
v0.99.0
- (id) initWithData: (const void *)  data
pixelFormat: (CCTexture2DPixelFormat)  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:

  • GL_TEXTURE_MIN_FILTER = GL_NEAREST
  • GL_TEXTURE_MAG_FILTER = GL_NEAREST
Since:
v0.8
- (void) setAntiAliasTexParameters  

sets antialias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_LINEAR
  • GL_TEXTURE_MAG_FILTER = GL_LINEAR
Since:
v0.8
+ (void) setDefaultAlphaPixelFormat: (CCTexture2DPixelFormat)  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: kCCTexture2DPixelFormat_RGBA8888 (default one)
  • generate 16-bit textures: kCCTexture2DPixelFormat_RGBA4444
  • generate 16-bit textures: kCCTexture2DPixelFormat_RGB5A1
  • generate 16-bit textures: kCCTexture2DPixelFormat_RGB565
  • generate 8-bit textures: kCCTexture2DPixelFormat_A8 (only use it if you use just 1 color)

How does it work ?

  • If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture)
  • If the image is an RGB (without Alpha) then an RGB565 texture will be used (16-bit texture)
Since:
v0.8
- (void) setTexParameters: (ccTexParams *)  texParams  

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}.

Since:
v0.8

Property Documentation

- (CGSize) contentSize [read, assign]

content size

Definition at line 131 of file CCTexture2D.h.

- (BOOL) hasPremultipliedAlpha [read, assign]

whether or not the texture has their Alpha premultiplied

Definition at line 137 of file CCTexture2D.h.

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

texture max S

Definition at line 133 of file CCTexture2D.h.

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

texture max T

Definition at line 135 of file CCTexture2D.h.

- (GLuint) name [read, assign]

texture name

Definition at line 128 of file CCTexture2D.h.

- (CCTexture2DPixelFormat) pixelFormat [read, assign]

pixel format of the texture

Definition at line 121 of file CCTexture2D.h.

- (NSUInteger) pixelsHigh [read, assign]

hight in pixels

Definition at line 125 of file CCTexture2D.h.

- (NSUInteger) pixelsWide [read, assign]

width in pixels

Definition at line 123 of file CCTexture2D.h.


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

cocos2d for iPhone 0.99.4 API Reference - Generated using Doxygen 1.7.1