mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-08 01:05:59 +02:00
Graphics.DrawLine, DrawBatch fixes
This commit is contained in:
parent
a269a19ed8
commit
40f3baf127
4 changed files with 66 additions and 14 deletions
|
@ -68,11 +68,12 @@ void* DrawBatch::AllocTris(int vtxCount)
|
|||
{
|
||||
int idxCount = vtxCount;
|
||||
|
||||
if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (idxCount + mIdxIdx >= mAllocatedIndices))
|
||||
bool fits = (idxCount + mIdxIdx <= mAllocatedIndices) && (vtxCount + mVtxIdx <= mAllocatedVertices);
|
||||
if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (!fits))
|
||||
{
|
||||
if (mVtxIdx > 0)
|
||||
if ((mVtxIdx > 0) || (!fits))
|
||||
{
|
||||
DrawBatch* nextBatch = AllocateChainedBatch(0, 0);
|
||||
DrawBatch* nextBatch = AllocateChainedBatch(vtxCount, idxCount);
|
||||
return nextBatch->AllocTris(vtxCount);
|
||||
}
|
||||
|
||||
|
@ -95,11 +96,12 @@ void* DrawBatch::AllocStrip(int vtxCount)
|
|||
{
|
||||
int idxCount = (vtxCount - 2) * 3;
|
||||
|
||||
if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (idxCount + mIdxIdx >= mAllocatedIndices))
|
||||
bool fits = (idxCount + mIdxIdx <= mAllocatedIndices) && (vtxCount + mVtxIdx <= mAllocatedVertices);
|
||||
if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (!fits))
|
||||
{
|
||||
if (mVtxIdx > 0)
|
||||
if ((mVtxIdx > 0) || (!fits))
|
||||
{
|
||||
DrawBatch* nextBatch = AllocateChainedBatch(0, 0);
|
||||
DrawBatch* nextBatch = AllocateChainedBatch(vtxCount, idxCount);
|
||||
return nextBatch->AllocStrip(vtxCount);
|
||||
}
|
||||
|
||||
|
@ -126,9 +128,10 @@ void* DrawBatch::AllocStrip(int vtxCount)
|
|||
|
||||
void DrawBatch::AllocIndexed(int vtxCount, int idxCount, void** verticesOut, uint16** indicesOut, uint16* idxOfsOut)
|
||||
{
|
||||
if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (idxCount + mIdxIdx > mAllocatedIndices))
|
||||
bool fits = (idxCount + mIdxIdx <= mAllocatedIndices) && (vtxCount + mVtxIdx <= mAllocatedVertices);
|
||||
if ((mRenderState != gBFApp->mRenderDevice->mCurRenderState) || (!fits))
|
||||
{
|
||||
if (mVtxIdx > 0)
|
||||
if ((mVtxIdx > 0) || (!fits))
|
||||
{
|
||||
DrawBatch* nextBatch = AllocateChainedBatch(vtxCount, idxCount);
|
||||
return nextBatch->AllocIndexed(vtxCount, idxCount, verticesOut, indicesOut, idxOfsOut);
|
||||
|
@ -190,11 +193,8 @@ DrawBatch* DrawLayer::AllocateBatch(int minVtxCount, int minIdxCount)
|
|||
BF_ASSERT(mRenderDevice->mCurRenderState->mShader != NULL);
|
||||
int vtxSize = mRenderDevice->mCurRenderState->mShader->mVertexSize;
|
||||
|
||||
if (minIdxCount == 0)
|
||||
{
|
||||
minIdxCount = 512;
|
||||
minVtxCount = minIdxCount;
|
||||
}
|
||||
minIdxCount = BF_MAX(minIdxCount, 512);
|
||||
minVtxCount = BF_MAX(minIdxCount, 512);
|
||||
|
||||
BF_ASSERT(minIdxCount * sizeof(uint16) <= DRAWBUFFER_IDXBUFFER_SIZE);
|
||||
BF_ASSERT(minVtxCount * vtxSize <= DRAWBUFFER_VTXBUFFER_SIZE);
|
||||
|
|
|
@ -120,6 +120,20 @@ Texture* RenderDevice::LoadTexture(const StringImpl& fileName, int flags)
|
|||
imageData->mBits[0] = 0xFFFFFFFF;
|
||||
handled = true;
|
||||
}
|
||||
else if (fileName.StartsWith("!square"))
|
||||
{
|
||||
int squareSize = atoi(fileName.c_str() + 7);
|
||||
imageData = new ImageData();
|
||||
imageData->CreateNew(squareSize + 2, squareSize + 2, true);
|
||||
for (int y = 0; y < squareSize; y++)
|
||||
{
|
||||
for (int x = 0; x < squareSize; x++)
|
||||
{
|
||||
imageData->mBits[(y + 1) * (squareSize + 2) + x + 1] = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
else if (ext == ".tga")
|
||||
imageData = new TGAData();
|
||||
else if (ext == ".png")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue