| 65 | } |
| 66 | |
| 67 | void* DrawBatch::AllocTris(int vtxCount) |
| 68 | { |
| 69 | int idxCount = vtxCount; |
| 70 | |
| 71 | bool fits = (idxCount + mIdxIdx <= mAllocatedIndices) && (vtxCount + mVtxIdx <= mAllocatedVertices); |
| 72 | if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (!fits)) |
| 73 | { |
| 74 | if ((mVtxIdx > 0) || (!fits)) |
| 75 | { |
| 76 | DrawBatch* nextBatch = AllocateChainedBatch(vtxCount, idxCount); |
| 77 | return nextBatch->AllocTris(vtxCount); |
| 78 | } |
| 79 | |
| 80 | mRenderState = gBFApp->mRenderDevice->mCurRenderState; |
| 81 | } |
| 82 | |
| 83 | uint16* idxPtr = mIndices + mIdxIdx; |
| 84 | void* vtxPtr = (uint8*)mVertices + (mVtxIdx * mVtxSize); |
| 85 | |
| 86 | for (int idxNum = 0; idxNum < idxCount; idxNum++) |
| 87 | { |
| 88 | *idxPtr++ = mVtxIdx++; |
| 89 | mIdxIdx++; |
| 90 | } |
| 91 | |
| 92 | return vtxPtr; |
| 93 | } |
| 94 | |
| 95 | void* DrawBatch::AllocStrip(int vtxCount) |
| 96 | { |