MCPcopy Create free account
hub / github.com/axmolengine/axmol / initWithTexture

Method initWithTexture

core/2d/SpriteBatchNode.cpp:84–116  ·  view source on GitHub ↗

* init with Texture2D */

Source from the content-addressed store, hash-verified

82 * init with Texture2D
83 */
84bool SpriteBatchNode::initWithTexture(Texture2D* tex, ssize_t capacity /* = DEFAULT_CAPACITY*/)
85{
86 if (tex == nullptr)
87 {
88 return false;
89 }
90
91 AXASSERT(capacity >= 0, "Capacity must be >= 0");
92
93 _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
94 if (!tex->hasPremultipliedAlpha())
95 {
96 _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
97 }
98 _textureAtlas = new TextureAtlas();
99
100 if (capacity <= 0)
101 {
102 capacity = DEFAULT_CAPACITY;
103 }
104
105 _textureAtlas->initWithTexture(tex, capacity);
106
107 setProgramStateWithRegistry(backend::ProgramType::POSITION_TEXTURE_COLOR, tex);
108
109 updateBlendFunc();
110
111 _children.reserve(capacity);
112
113 _descendants.reserve(capacity);
114
115 return true;
116}
117
118void SpriteBatchNode::setUniformLocation()
119{

Callers 2

initMethod · 0.95
createWithTextureMethod · 0.45

Calls 2

hasPremultipliedAlphaMethod · 0.80
reserveMethod · 0.45

Tested by

no test coverage detected