* init with Texture2D */
| 82 | * init with Texture2D |
| 83 | */ |
| 84 | bool 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 | |
| 118 | void SpriteBatchNode::setUniformLocation() |
| 119 | { |
no test coverage detected