Public Member Functions | Static Public Member Functions | Properties

CCTexture2D(CC3Texture) Class Reference

This extension adds behaviour to support the use of a CCTexture2D instance as a component of a CC3Texture. More...

#import <CC3Texture.h>

List of all members.

Public Member Functions

(BOOL) - generateMipmapIfNeeded

Static Public Member Functions

(Class) + instantiationClass
(void) + setInstantiationClass:

Properties

BOOL hasMipmap
BOOL isFlippedVertically

Detailed Description

This extension adds behaviour to support the use of a CCTexture2D instance as a component of a CC3Texture.

Adds the capability to track whether the texture contains a mipmap.

Adds the capability to track whether the texture was flipped vertically by the iOS during loading.

Adds the ability to use CCTexture2D as the top of a class cluster, and in particular, to force a particular subclass of CCTexture2D to be instantiated and returned when the CCTexture2D alloc method is invoked.


Member Function Documentation

- (BOOL) generateMipmapIfNeeded

If this texture does not have a mipmap yet, as indicated by the value of the hasMipmap property, this method generates a GL mipmap for this texture, and sets the value of the hasMipmap property to YES.

It is safe to invoke this method more than once, or on a texture that was loaded from a file that already contains a mipmap, because it will only generate a mipmap if the texture file does not already contain a mipmap and a mipmap has not yet been generated.

Be aware that some formats (notably PVR) may already contain mipmaps in the content loaded from file. For instances of the cluster subclass CC3Texture2D, this is tracked automatically, and invoking this method will not overwrite the loaded mipmap. But for instances of the base cluster parent CCTexture2D, you should be sure to set the hasMipmap property to YES before invoking this method, to avoid overwriting the loaded mipmap.

+ (Class) instantiationClass

Returns the cluster class that will be instantiated and returned when the alloc method is invoked.

The returned class will be a subclass of CCTexture2D, or nil.

If this property is not nil, subsequent invocations of the CCTexture2D alloc method will instantiate and return an instance of that class.

If this property is nil, subsequent invocations of the CCTexture2D alloc method will instantiate and return an instance of CCTexture2D.

This property will temporarily be set to CC3Texture2D by CC3Texture when loading the underlying CCTexture2D instance.

+ (void) setInstantiationClass: (Class)  aClass

Sets the cluster class that will be instantiated and returned when the alloc method is invoked.

The specified class must be a subclass of CCTexture2D, or nil.

If the specified class is not nil, subsequent invocations of the CCTexture2D alloc method will instantiate and return an instance of that class.

If the specified class is nil, subsequent invocations of the CCTexture2D alloc method will instantiate and return an instance of CCTexture2D.

This property will temporarily be set to CC3Texture2D by CC3Texture when loading the underlying CCTexture2D instance.


Property Documentation

- (BOOL) hasMipmap [read, write, assign]

Indicates whether this texture contains a mipmap.

For instances of the cluster subclass CC3Texture2D, the value of this property is set to the correct value automatically when the texture file is loaded.

For instances of the base cluster parent CCTexture2D, you should set this property to the correct value after loading, and before the generateMipmapIfNeeded method is invoked.

This property will also be set to YES when the generateMipmapIfNeeded is invoked.

If you manually set this property to YES for a CCTexture2D, you should set this property back to NO before clearing this texture from the CCTextureCache, in case the GL engine reuses the texture name again.

- (BOOL) isFlippedVertically [read, write, assign]

Returns whether this texture is flipped vertically.

Under iOS, most texture formats are loaded updside-down. This is because the vertical axis of the coordinate system of OpenGL is inverted relative to the iOS view coordinate system. This results in textures being displayed upside-down, relative to the OpenGL coordinate system.

This property will return NO if this texture was loaded from a PVR texture file, and will return YES if loaded from any other texture file type.

For instances of the cluster subclass CC3Texture2D, the value of this property is set to the correct value automatically when the texture file is loaded.

For instances of the base cluster parent CCTexture2D, you should set this property to the correct value after loading.

If you manually set this property to NO for a CCTexture2D, you should set this property back to YES before clearing this texture from the CCTextureCache, in case the GL engine reuses the texture name again.


The documentation for this class was generated from the following file: