mirror of https://github.com/axmolengine/axmol.git
fix: fix delay when creating QuadCommands
starts with a bigger buffer, and also increases buffer by 25% if needed. triggered by particles. Github issue #15937
This commit is contained in:
parent
bac1870d16
commit
e681a9b5d1
|
@ -72,9 +72,20 @@ void QuadCommand::init(float globalOrder, GLuint textureID, GLProgramState* glPr
|
||||||
|
|
||||||
void QuadCommand::reIndex(int indicesCount)
|
void QuadCommand::reIndex(int indicesCount)
|
||||||
{
|
{
|
||||||
|
// first time init: create a decent buffer size for indices to prevent too much resizing
|
||||||
|
if (__indexCapacity == -1)
|
||||||
|
{
|
||||||
|
indicesCount = std::max(indicesCount, 2048);
|
||||||
|
}
|
||||||
|
|
||||||
if (indicesCount > __indexCapacity)
|
if (indicesCount > __indexCapacity)
|
||||||
{
|
{
|
||||||
|
// if resizing is needed, get needed size plus 25%, but not bigger that max size
|
||||||
|
indicesCount *= 1.25;
|
||||||
|
indicesCount = std::min(indicesCount, 65536);
|
||||||
|
|
||||||
CCLOG("cocos2d: QuadCommand: resizing index size from [%d] to [%d]", __indexCapacity, indicesCount);
|
CCLOG("cocos2d: QuadCommand: resizing index size from [%d] to [%d]", __indexCapacity, indicesCount);
|
||||||
|
|
||||||
_ownedIndices.push_back(__indices);
|
_ownedIndices.push_back(__indices);
|
||||||
__indices = new (std::nothrow) GLushort[indicesCount];
|
__indices = new (std::nothrow) GLushort[indicesCount];
|
||||||
__indexCapacity = indicesCount;
|
__indexCapacity = indicesCount;
|
||||||
|
|
Loading…
Reference in New Issue