cocos2d-x  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Texture2D Class Reference

Texture2D class. More...

#include <CCTexture2D.h>

Inheritance diagram for Texture2D:
Ref

Classes

struct  PixelFormatInfo
 

Public Types

enum  PixelFormat {
  AUTO, BGRA8888, RGBA8888, RGB888,
  RGB565, A8, I8, AI88,
  RGBA4444, RGB5A1, PVRTC4, PVRTC4A,
  PVRTC2, PVRTC2A, ETC, S3TC_DXT1,
  S3TC_DXT3, S3TC_DXT5, ATC_RGB, ATC_EXPLICIT_ALPHA,
  ATC_INTERPOLATED_ALPHA, DEFAULT = AUTO, NONE = -1
}
 Possible texture pixel formats. More...
 
typedef std::map
< Texture2D::PixelFormat,
const PixelFormatInfo
PixelFormatInfoMap

Public Member Functions

 Texture2D ()
 ctor ()
 Texture2D ()
virtual ~Texture2D ()
virtual std::string getDescription () const
void releaseData (void *data)
 These functions are needed to create mutable textures. More...
 
void * keepData (void *data, unsigned int length)
bool initWithData (const void *data, ssize_t dataLen, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size &contentSize)
 Initializes with a texture2d with data. More...
 
bool initWithMipmaps (MipmapInfo *mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh)
 Initializes with mipmaps. More...
 
bool updateWithData (const void *data, int offsetX, int offsetY, int width, int height)
 Update with texture data. More...
 
void drawAtPoint (const Point &point)
 Drawing extensions to make it easy to draw basic quads using a Texture2D object. More...
 
void drawInRect (const Rect &rect)
 draws a texture inside a rect More...
 
bool initWithImage (Image *image)
 Extensions to make it easy to create a Texture2D object from an image file. More...
 
bool initWithImage (Image *image, PixelFormat format)
 Initializes a texture from a UIImage object. More...
 
bool initWithString (const char *text, const char *fontName, float fontSize, const Size &dimensions=Size(0, 0), TextHAlignment hAlignment=TextHAlignment::CENTER, TextVAlignment vAlignment=TextVAlignment::TOP)
 Initializes a texture from a string with dimensions, alignment, font name and font size. More...
 
var initWithString ( var text, var fontName, var fontSize, var 0, var CENTER, var TOP)
 Initializes a texture from a string with dimensions, alignment, font name and font size. More...
 
local initWithString ( local text, local fontName, local fontSize, local 0, local CENTER, local TOP)
 Initializes a texture from a string with dimensions, alignment, font name and font size. More...
 
bool initWithString (const char *text, const FontDefinition &textDefinition)
 Initializes a texture from a string using a text definition. More...
 
var initWithString ( var text, var textDefinition)
 Initializes a texture from a string using a text definition. More...
 
local initWithString ( local text, local textDefinition)
 Initializes a texture from a string using a text definition. More...
 
void setTexParameters (const TexParams &texParams)
 sets the min filter, mag filter, wrap s and wrap t texture parameters. More...
 
CC_DEPRECATED_ATTRIBUTE void setTexParameters (const TexParams *texParams)
void setAntiAliasTexParameters ()
 sets antialias texture parameters: More...
 
var setAntiAliasTexParameters ()
 sets antialias texture parameters: More...
 
local setAntiAliasTexParameters ()
 sets antialias texture parameters: More...
 
void setAliasTexParameters ()
 sets alias texture parameters: More...
 
void generateMipmap ()
 Generates mipmap images for the texture. More...
 
const char * getStringForFormat () const
 returns the pixel format. More...
 
local getStringForFormat ()
 returns the pixel format. More...
 
CC_DEPRECATED_ATTRIBUTE const
char * 
stringForFormat () const
local stringForFormat ()
unsigned int getBitsPerPixelForFormat () const
 returns the bits-per-pixel of the in-memory OpenGL texture More...
 
CC_DEPRECATED_ATTRIBUTE
unsigned int 
bitsPerPixelForFormat () const
local bitsPerPixelForFormat ()
unsigned int getBitsPerPixelForFormat (Texture2D::PixelFormat format) const
 Helper functions that returns bits per pixels for a given format. More...
 
CC_DEPRECATED_ATTRIBUTE
unsigned int 
bitsPerPixelForFormat (Texture2D::PixelFormat format) const
local bitsPerPixelForFormat ( local format)
const SizegetContentSizeInPixels ()
 content size More...
 
var getContentSizeInPixels ()
 content size More...
 
local getContentSizeInPixels ()
 content size More...
 
bool hasPremultipliedAlpha () const
var hasPremultipliedAlpha ()
local hasPremultipliedAlpha ()
bool hasMipmaps () const
var hasMipmaps ()
local hasMipmaps ()
Texture2D::PixelFormat getPixelFormat () const
 Gets the pixel format of the texture. More...
 
var getPixelFormat ()
 Gets the pixel format of the texture. More...
 
local getPixelFormat ()
 Gets the pixel format of the texture. More...
 
int getPixelsWide () const
 Gets the width of the texture in pixels. More...
 
local getPixelsWide ()
 Gets the width of the texture in pixels. More...
 
int getPixelsHigh () const
 Gets the height of the texture in pixels. More...
 
var getPixelsHigh ()
 Gets the height of the texture in pixels. More...
 
local getPixelsHigh ()
 Gets the height of the texture in pixels. More...
 
GLuint getName () const
 Gets the texture name. More...
 
var getName ()
 Gets the texture name. More...
 
local getName ()
 Gets the texture name. More...
 
GLfloat getMaxS () const
 Gets max S. More...
 
var getMaxS ()
 Gets max S. More...
 
local getMaxS ()
 Gets max S. More...
 
void setMaxS (GLfloat maxS)
 Sets max S. More...
 
local setMaxS ( local maxS)
 Sets max S. More...
 
GLfloat getMaxT () const
 Gets max T. More...
 
local getMaxT ()
 Gets max T. More...
 
void setMaxT (GLfloat maxT)
 Sets max T. More...
 
local setMaxT ( local maxT)
 Sets max T. More...
 
Size getContentSize () const
var getContentSize ()
local getContentSize ()
void setShaderProgram (GLProgram *program)
var setShaderProgram ( var program)
local setShaderProgram ( local program)
GLProgramgetShaderProgram () const
var getShaderProgram ()
local getShaderProgram ()
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Release the ownership immediately. More...
 
Refautorelease ()
 Release the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()

Static Public Member Functions

static void setDefaultAlphaPixelFormat (Texture2D::PixelFormat format)
 sets the default pixel format for UIImagescontains alpha channel. More...
 
local setDefaultAlphaPixelFormat ( local format)
 sets the default pixel format for UIImagescontains alpha channel. More...
 
static Texture2D::PixelFormat getDefaultAlphaPixelFormat ()
 returns the alpha pixel format More...
 
local getDefaultAlphaPixelFormat ()
 returns the alpha pixel format More...
 
static CC_DEPRECATED_ATTRIBUTE
Texture2D::PixelFormat 
defaultAlphaPixelFormat ()
var defaultAlphaPixelFormat ()
local defaultAlphaPixelFormat ()
static void PVRImagesHavePremultipliedAlpha (bool haveAlphaPremultiplied)
 treats (or not) PVR files as if they have alpha premultiplied. More...
 
local PVRImagesHavePremultipliedAlpha ( local haveAlphaPremultiplied)
 treats (or not) PVR files as if they have alpha premultiplied. More...
 
static const PixelFormatInfoMapgetPixelFormatInfoMap ()
var getPixelFormatInfoMap ()
local getPixelFormatInfoMap ()

Protected Attributes

Texture2D::PixelFormat _pixelFormat
 pixel format of the texture More...
 
int _pixelsWide
 width in pixels More...
 
var _pixelsWide
 width in pixels More...
 
local _pixelsWide
 width in pixels More...
 
int _pixelsHigh
 height in pixels More...
 
var _pixelsHigh
 height in pixels More...
 
local _pixelsHigh
 height in pixels More...
 
GLuint _name
 texture name More...
 
var _name
 texture name More...
 
local _name
 texture name More...
 
GLfloat _maxS
 texture max S More...
 
var _maxS
 texture max S More...
 
local _maxS
 texture max S More...
 
GLfloat _maxT
 texture max T More...
 
var _maxT
 texture max T More...
 
local _maxT
 texture max T More...
 
Size _contentSize
 content size More...
 
var _contentSize
 content size More...
 
local _contentSize
 content size More...
 
bool _hasPremultipliedAlpha
 whether or not the texture has their Alpha premultiplied More...
 
var _hasPremultipliedAlpha
 whether or not the texture has their Alpha premultiplied More...
 
local _hasPremultipliedAlpha
 whether or not the texture has their Alpha premultiplied More...
 
bool _hasMipmaps
GLProgram_shaderProgram
 shader program used by drawAtPoint and drawInRect More...
 
var _shaderProgram
 shader program used by drawAtPoint and drawInRect More...
 
local _shaderProgram
 shader program used by drawAtPoint and drawInRect More...
 
bool _antialiasEnabled
var _antialiasEnabled
local _antialiasEnabled
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Static Protected Attributes

static const PixelFormatInfoMap _pixelFormatInfoTables

Additional Inherited Members

- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Detailed Description

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

Member Typedef Documentation

Member Enumeration Documentation

enum PixelFormat
strong

Possible texture pixel formats.

Enumerator
AUTO 

auto detect the type

BGRA8888 

32-bit texture: BGRA8888

RGBA8888 

32-bit texture: RGBA8888

RGB888 

24-bit texture: RGBA888

RGB565 

16-bit texture without Alpha channel

A8 

8-bit textures used as masks

I8 

8-bit intensity texture

AI88 

16-bit textures used as masks

RGBA4444 

16-bit textures: RGBA4444

RGB5A1 

16-bit textures: RGB5A1

PVRTC4 

4-bit PVRTC-compressed texture: PVRTC4

PVRTC4A 

4-bit PVRTC-compressed texture: PVRTC4 (has alpha channel)

PVRTC2 

2-bit PVRTC-compressed texture: PVRTC2

PVRTC2A 

2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel)

ETC 

ETC-compressed texture: ETC.

S3TC_DXT1 

S3TC-compressed texture: S3TC_Dxt1.

S3TC_DXT3 

S3TC-compressed texture: S3TC_Dxt3.

S3TC_DXT5 

S3TC-compressed texture: S3TC_Dxt5.

ATC_RGB 

ATITC-compressed texture: ATC_RGB.

ATC_EXPLICIT_ALPHA 

ATITC-compressed texture: ATC_EXPLICIT_ALPHA.

ATC_INTERPOLATED_ALPHA 

ATITC-compresed texture: ATC_INTERPOLATED_ALPHA.

DEFAULT 

Default texture format: AUTO.

NONE 
var PixelFormat
strong

Possible texture pixel formats.

Enumerator
AUTO 

auto detect the type

BGRA8888 

32-bit texture: BGRA8888

RGBA8888 

32-bit texture: RGBA8888

RGB888 

24-bit texture: RGBA888

RGB565 

16-bit texture without Alpha channel

A8 

8-bit textures used as masks

I8 

8-bit intensity texture

AI88 

16-bit textures used as masks

RGBA4444 

16-bit textures: RGBA4444

RGB5A1 

16-bit textures: RGB5A1

PVRTC4 

4-bit PVRTC-compressed texture: PVRTC4

PVRTC4A 

4-bit PVRTC-compressed texture: PVRTC4 (has alpha channel)

PVRTC2 

2-bit PVRTC-compressed texture: PVRTC2

PVRTC2A 

2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel)

ETC 

ETC-compressed texture: ETC.

S3TC_DXT1 

S3TC-compressed texture: S3TC_Dxt1.

S3TC_DXT3 

S3TC-compressed texture: S3TC_Dxt3.

S3TC_DXT5 

S3TC-compressed texture: S3TC_Dxt5.

ATC_RGB 

ATITC-compressed texture: ATC_RGB.

ATC_EXPLICIT_ALPHA 

ATITC-compressed texture: ATC_EXPLICIT_ALPHA.

ATC_INTERPOLATED_ALPHA 

ATITC-compresed texture: ATC_INTERPOLATED_ALPHA.

DEFAULT 

Default texture format: AUTO.

NONE 
local PixelFormat
strong

Possible texture pixel formats.

Enumerator
AUTO 

auto detect the type

BGRA8888 

32-bit texture: BGRA8888

RGBA8888 

32-bit texture: RGBA8888

RGB888 

24-bit texture: RGBA888

RGB565 

16-bit texture without Alpha channel

A8 

8-bit textures used as masks

I8 

8-bit intensity texture

AI88 

16-bit textures used as masks

RGBA4444 

16-bit textures: RGBA4444

RGB5A1 

16-bit textures: RGB5A1

PVRTC4 

4-bit PVRTC-compressed texture: PVRTC4

PVRTC4A 

4-bit PVRTC-compressed texture: PVRTC4 (has alpha channel)

PVRTC2 

2-bit PVRTC-compressed texture: PVRTC2

PVRTC2A 

2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel)

ETC 

ETC-compressed texture: ETC.

S3TC_DXT1 

S3TC-compressed texture: S3TC_Dxt1.

S3TC_DXT3 

S3TC-compressed texture: S3TC_Dxt3.

S3TC_DXT5 

S3TC-compressed texture: S3TC_Dxt5.

ATC_RGB 

ATITC-compressed texture: ATC_RGB.

ATC_EXPLICIT_ALPHA 

ATITC-compressed texture: ATC_EXPLICIT_ALPHA.

ATC_INTERPOLATED_ALPHA 

ATITC-compresed texture: ATC_INTERPOLATED_ALPHA.

DEFAULT 

Default texture format: AUTO.

NONE 

Constructor & Destructor Documentation

Texture2D ( )
var ctor ( )
local Texture2D ( )
virtual ~Texture2D ( )
virtual

Member Function Documentation

CC_DEPRECATED_ATTRIBUTE
unsigned int
bitsPerPixelForFormat
( ) const
inline
var bitsPerPixelForFormat ( )
inline
local bitsPerPixelForFormat ( )
inline
CC_DEPRECATED_ATTRIBUTE
unsigned int
bitsPerPixelForFormat
( Texture2D::PixelFormat  format) const
inline
var bitsPerPixelForFormat ( var  format)
inline
local bitsPerPixelForFormat ( local  format)
inline
static CC_DEPRECATED_ATTRIBUTE
Texture2D::PixelFormat
defaultAlphaPixelFormat
( )
inlinestatic
var defaultAlphaPixelFormat ( )
inlinestatic
local defaultAlphaPixelFormat ( )
inlinestatic
void drawAtPoint ( const Point point)

Drawing extensions to make it easy to draw basic quads using a Texture2D object.

These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.draws a texture at a given point

var drawAtPoint ( var  point)

Drawing extensions to make it easy to draw basic quads using a Texture2D object.

These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.draws a texture at a given point

local drawAtPoint ( local  point)

Drawing extensions to make it easy to draw basic quads using a Texture2D object.

These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.draws a texture at a given point

void drawInRect ( const Rect rect)

draws a texture inside a rect

var drawInRect ( var  rect)

draws a texture inside a rect

local drawInRect ( local  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
var generateMipmap ( )

Generates mipmap images for the texture.

It only works if the texture size is POT (power of 2).

Since
v0.99.0
local generateMipmap ( )

Generates mipmap images for the texture.

It only works if the texture size is POT (power of 2).

Since
v0.99.0
unsigned int
getBitsPerPixelForFormat
( ) const

returns the bits-per-pixel of the in-memory OpenGL texture

Since
v1.0
var getBitsPerPixelForFormat ( )

returns the bits-per-pixel of the in-memory OpenGL texture

Since
v1.0
local getBitsPerPixelForFormat ( )

returns the bits-per-pixel of the in-memory OpenGL texture

Since
v1.0
unsigned int
getBitsPerPixelForFormat
( Texture2D::PixelFormat  format) const

Helper functions that returns bits per pixels for a given format.

Since
v2.0
var getBitsPerPixelForFormat ( var  format)

Helper functions that returns bits per pixels for a given format.

Since
v2.0
local getBitsPerPixelForFormat ( local  format)

Helper functions that returns bits per pixels for a given format.

Since
v2.0
Size getContentSize ( ) const
var getContentSize ( )
local getContentSize ( )
const Size& getContentSizeInPixels ( )

content size

var getContentSizeInPixels ( )

content size

local getContentSizeInPixels ( )

content size

static Texture2D::PixelFormat
getDefaultAlphaPixelFormat
( )
static

returns the alpha pixel format

Since
v0.8
var getDefaultAlphaPixelFormat ( )
static

returns the alpha pixel format

Since
v0.8
local getDefaultAlphaPixelFormat ( )
static

returns the alpha pixel format

Since
v0.8
virtual std::string getDescription ( ) const
virtual
GLfloat getMaxS ( ) const

Gets max S.

var getMaxS ( )

Gets max S.

local getMaxS ( )

Gets max S.

GLfloat getMaxT ( ) const

Gets max T.

var getMaxT ( )

Gets max T.

local getMaxT ( )

Gets max T.

GLuint getName ( ) const

Gets the texture name.

var getName ( )

Gets the texture name.

local getName ( )

Gets the texture name.

Texture2D::PixelFormat
getPixelFormat
( ) const

Gets the pixel format of the texture.

var getPixelFormat ( )

Gets the pixel format of the texture.

local getPixelFormat ( )

Gets the pixel format of the texture.

static const
PixelFormatInfoMap&
getPixelFormatInfoMap
( )
static
var getPixelFormatInfoMap ( )
static
local getPixelFormatInfoMap ( )
static
int getPixelsHigh ( ) const

Gets the height of the texture in pixels.

var getPixelsHigh ( )

Gets the height of the texture in pixels.

local getPixelsHigh ( )

Gets the height of the texture in pixels.

int getPixelsWide ( ) const

Gets the width of the texture in pixels.

var getPixelsWide ( )

Gets the width of the texture in pixels.

local getPixelsWide ( )

Gets the width of the texture in pixels.

GLProgram* getShaderProgram ( ) const
var getShaderProgram ( )
local getShaderProgram ( )
const char* getStringForFormat ( ) const

returns the pixel format.

Since
v2.0
var getStringForFormat ( )

returns the pixel format.

Since
v2.0
local getStringForFormat ( )

returns the pixel format.

Since
v2.0
bool hasMipmaps ( ) const
var hasMipmaps ( )
local hasMipmaps ( )
bool hasPremultipliedAlpha ( ) const
var hasPremultipliedAlpha ( )
local hasPremultipliedAlpha ( )
bool initWithData ( const void *  data,
ssize_t  dataLen,
Texture2D::PixelFormat  pixelFormat,
int  pixelsWide,
int  pixelsHigh,
const Size contentSize 
)

Initializes with a texture2d with data.

bool initWithImage ( Image image)

Extensions to make it easy to create a Texture2D object from an image file.

Initializes a texture from a UIImage object. We will use the format you specified with setDefaultAlphaPixelFormat to convert the image for texture. NOTE: It will not convert the pvr image file.

var initWithImage ( var  image)

Extensions to make it easy to create a Texture2D object from an image file.

Initializes a texture from a UIImage object. We will use the format you specified with setDefaultAlphaPixelFormat to convert the image for texture. NOTE: It will not convert the pvr image file.

local initWithImage ( local  image)

Extensions to make it easy to create a Texture2D object from an image file.

Initializes a texture from a UIImage object. We will use the format you specified with setDefaultAlphaPixelFormat to convert the image for texture. NOTE: It will not convert the pvr image file.

bool initWithImage ( Image image,
PixelFormat  format 
)

Initializes a texture from a UIImage object.

we will use the format you passed to the function to convert the image format to the texture format. If you pass PixelFormat::Automatic, we will auto detect the image render type and use that type for texture to render.

var initWithImage ( var  image,
var  format 
)

Initializes a texture from a UIImage object.

we will use the format you passed to the function to convert the image format to the texture format. If you pass PixelFormat::Automatic, we will auto detect the image render type and use that type for texture to render.

local initWithImage ( local  image,
local  format 
)

Initializes a texture from a UIImage object.

we will use the format you passed to the function to convert the image format to the texture format. If you pass PixelFormat::Automatic, we will auto detect the image render type and use that type for texture to render.

bool initWithMipmaps ( MipmapInfo mipmaps,
int  mipmapsNum,
Texture2D::PixelFormat  pixelFormat,
int  pixelsWide,
int  pixelsHigh 
)

Initializes with mipmaps.

var initWithMipmaps ( var  mipmaps,
var  mipmapsNum,
var  pixelFormat,
var  pixelsWide,
var  pixelsHigh 
)

Initializes with mipmaps.

local initWithMipmaps ( local  mipmaps,
local  mipmapsNum,
local  pixelFormat,
local  pixelsWide,
local  pixelsHigh 
)

Initializes with mipmaps.

bool initWithString ( const char *  text,
const char *  fontName,
float  fontSize,
const Size dimensions = Size(0, 0),
TextHAlignment  hAlignment = TextHAlignment::CENTER,
TextVAlignment  vAlignment = TextVAlignment::TOP 
)

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

var initWithString ( var  text,
var  fontName,
var  fontSize,
var  dimensions = Size(0, 0),
var  hAlignment = TextHAlignment::CENTER,
var  vAlignment = TextVAlignment::TOP 
)

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

local initWithString ( local  text,
local  fontName,
local  fontSize,
local  dimensions = Size(0, 0),
local  hAlignment = TextHAlignment::CENTER,
local  vAlignment = TextVAlignment::TOP 
)

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

bool initWithString ( const char *  text,
const FontDefinition textDefinition 
)

Initializes a texture from a string using a text definition.

var initWithString ( var  text,
var  textDefinition 
)

Initializes a texture from a string using a text definition.

local initWithString ( local  text,
local  textDefinition 
)

Initializes a texture from a string using a text definition.

void* keepData ( void *  data,
unsigned int  length 
)
static void
PVRImagesHavePremultipliedAlpha
( bool  haveAlphaPremultiplied)
static

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.

Since
v0.99.5
var PVRImagesHavePremultipliedAlpha ( var  haveAlphaPremultiplied)
static

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.

Since
v0.99.5
local
PVRImagesHavePremultipliedAlpha
( local  haveAlphaPremultiplied)
static

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.

Since
v0.99.5
void releaseData ( void *  data)

These functions are needed to create mutable textures.

void setAliasTexParameters ( )

sets alias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_NEAREST
  • GL_TEXTURE_MAG_FILTER = GL_NEAREST
Warning
Calling this method could allocate additional texture memory.
Since
v0.8
var setAliasTexParameters ( )

sets alias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_NEAREST
  • GL_TEXTURE_MAG_FILTER = GL_NEAREST
Warning
Calling this method could allocate additional texture memory.
Since
v0.8
local setAliasTexParameters ( )

sets alias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_NEAREST
  • GL_TEXTURE_MAG_FILTER = GL_NEAREST
Warning
Calling this method could allocate additional texture memory.
Since
v0.8
void setAntiAliasTexParameters ( )

sets antialias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_LINEAR
  • GL_TEXTURE_MAG_FILTER = GL_LINEAR
Warning
Calling this method could allocate additional texture memory.
Since
v0.8
var setAntiAliasTexParameters ( )

sets antialias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_LINEAR
  • GL_TEXTURE_MAG_FILTER = GL_LINEAR
Warning
Calling this method could allocate additional texture memory.
Since
v0.8
local setAntiAliasTexParameters ( )

sets antialias texture parameters:

  • GL_TEXTURE_MIN_FILTER = GL_LINEAR
  • GL_TEXTURE_MAG_FILTER = GL_LINEAR
Warning
Calling this method could allocate additional texture memory.
Since
v0.8
static void
setDefaultAlphaPixelFormat
( Texture2D::PixelFormat  format)
static

sets the default pixel format for UIImagescontains alpha channel.

If the UIImage contains alpha channel, then the options are:

  • generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one)
  • generate 24-bit textures: Texture2D::PixelFormat::RGB888
  • generate 16-bit textures: Texture2D::PixelFormat::RGBA4444
  • generate 16-bit textures: Texture2D::PixelFormat::RGB5A1
  • generate 16-bit textures: Texture2D::PixelFormat::RGB565
  • generate 8-bit textures: Texture2D::PixelFormat::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: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.

This parameter is not valid for PVR / PVR.CCZ images.

Since
v0.8
var setDefaultAlphaPixelFormat ( var  format)
static

sets the default pixel format for UIImagescontains alpha channel.

If the UIImage contains alpha channel, then the options are:

  • generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one)
  • generate 24-bit textures: Texture2D::PixelFormat::RGB888
  • generate 16-bit textures: Texture2D::PixelFormat::RGBA4444
  • generate 16-bit textures: Texture2D::PixelFormat::RGB5A1
  • generate 16-bit textures: Texture2D::PixelFormat::RGB565
  • generate 8-bit textures: Texture2D::PixelFormat::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: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.

This parameter is not valid for PVR / PVR.CCZ images.

Since
v0.8
local setDefaultAlphaPixelFormat ( local  format)
static

sets the default pixel format for UIImagescontains alpha channel.

If the UIImage contains alpha channel, then the options are:

  • generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one)
  • generate 24-bit textures: Texture2D::PixelFormat::RGB888
  • generate 16-bit textures: Texture2D::PixelFormat::RGBA4444
  • generate 16-bit textures: Texture2D::PixelFormat::RGB5A1
  • generate 16-bit textures: Texture2D::PixelFormat::RGB565
  • generate 8-bit textures: Texture2D::PixelFormat::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: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.

This parameter is not valid for PVR / PVR.CCZ images.

Since
v0.8
void setMaxS ( GLfloat  maxS)

Sets max S.

var setMaxS ( var  maxS)

Sets max S.

local setMaxS ( local  maxS)

Sets max S.

void setMaxT ( GLfloat  maxT)

Sets max T.

var setMaxT ( var  maxT)

Sets max T.

local setMaxT ( local  maxT)

Sets max T.

void setShaderProgram ( GLProgram program)
var setShaderProgram ( var  program)
local setShaderProgram ( local  program)
void setTexParameters ( const TexParams 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}.

Warning
Calling this method could allocate additional texture memory.
Since
v0.8
When this function bound into js or lua,the input parameter will be changed
In js: var setBlendFunc(var arg1, var arg2, var arg3, var arg4)
In lua: local setBlendFunc(local arg1, local arg2, local arg3, local arg4)
var setTexParameters ( var  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}.

Warning
Calling this method could allocate additional texture memory.
Since
v0.8
When this function bound into js or lua,the input parameter will be changed
In js: var setBlendFunc(var arg1, var arg2, var arg3, var arg4)
In lua: local setBlendFunc(local arg1, local arg2, local arg3, local arg4)
local setTexParameters ( local  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}.

Warning
Calling this method could allocate additional texture memory.
Since
v0.8
When this function bound into js or lua,the input parameter will be changed
In js: var setBlendFunc(var arg1, var arg2, var arg3, var arg4)
In lua: local setBlendFunc(local arg1, local arg2, local arg3, local arg4)
CC_DEPRECATED_ATTRIBUTE void
setTexParameters
( const TexParams texParams)
inline
CC_DEPRECATED_ATTRIBUTE const
char* stringForFormat
( ) const
inline
var stringForFormat ( )
inline
local stringForFormat ( )
inline
bool updateWithData ( const void *  data,
int  offsetX,
int  offsetY,
int  width,
int  height 
)

Update with texture data.

var updateWithData ( var  data,
var  offsetX,
var  offsetY,
var  width,
var  height 
)

Update with texture data.

local updateWithData ( local  data,
local  offsetX,
local  offsetY,
local  width,
local  height 
)

Update with texture data.

Member Data Documentation

bool _antialiasEnabled
protected
var _antialiasEnabled
protected
local _antialiasEnabled
protected
Size _contentSize
protected

content size

var _contentSize
protected

content size

local _contentSize
protected

content size

bool _hasMipmaps
protected
var _hasMipmaps
protected
local _hasMipmaps
protected
bool _hasPremultipliedAlpha
protected

whether or not the texture has their Alpha premultiplied

var _hasPremultipliedAlpha
protected

whether or not the texture has their Alpha premultiplied

local _hasPremultipliedAlpha
protected

whether or not the texture has their Alpha premultiplied

GLfloat _maxS
protected

texture max S

var _maxS
protected

texture max S

local _maxS
protected

texture max S

GLfloat _maxT
protected

texture max T

var _maxT
protected

texture max T

local _maxT
protected

texture max T

GLuint _name
protected

texture name

var _name
protected

texture name

local _name
protected

texture name

Texture2D::PixelFormat _pixelFormat
protected

pixel format of the texture

var _pixelFormat
protected

pixel format of the texture

local _pixelFormat
protected

pixel format of the texture

const PixelFormatInfoMap
_pixelFormatInfoTables
staticprotected
var _pixelFormatInfoTables
staticprotected
local _pixelFormatInfoTables
staticprotected
int _pixelsHigh
protected

height in pixels

var _pixelsHigh
protected

height in pixels

local _pixelsHigh
protected

height in pixels

int _pixelsWide
protected

width in pixels

var _pixelsWide
protected

width in pixels

local _pixelsWide
protected

width in pixels

GLProgram* _shaderProgram
protected

shader program used by drawAtPoint and drawInRect

var _shaderProgram
protected

shader program used by drawAtPoint and drawInRect

local _shaderProgram
protected

shader program used by drawAtPoint and drawInRect


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