Fix primitive render calls, which could happen to contain less vertices and indices than stated by the parameters. Now the calculation is based on the actually transferred number of elements.
Not sure why, but the draw2DImageBatch in ogl-es2 driver seemed to lack index calculation completely. I've added this now, should be required. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4249 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
9262b0848f
commit
cfb32c5ec4
|
@ -1406,14 +1406,25 @@ namespace video
|
|||
|
||||
const core::rect<s32> poss(targetPos, sourceRects[currentIndex].getSize());
|
||||
|
||||
const u32 vstart = vertices.size();
|
||||
vertices.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y));
|
||||
vertices.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y));
|
||||
vertices.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y));
|
||||
vertices.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y));
|
||||
quadIndices.push_back(vstart);
|
||||
quadIndices.push_back(vstart+1);
|
||||
quadIndices.push_back(vstart+2);
|
||||
quadIndices.push_back(vstart);
|
||||
quadIndices.push_back(vstart+2);
|
||||
quadIndices.push_back(vstart+3);
|
||||
|
||||
targetPos.X += sourceRects[currentIndex].getWidth();
|
||||
}
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), indices.size()*4, quadIndices.pointer(), 2*indices.size(), video::EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT, false);
|
||||
if (vertices.size()
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), vertices.size(),
|
||||
quadIndices.pointer(), vertices.size()/2,
|
||||
video::EVT_STANDARD, scene::EPT_TRIANGLES,
|
||||
EIT_16BIT, false);
|
||||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
testGLError();
|
||||
|
|
|
@ -1174,14 +1174,21 @@ void COGLES1Driver::draw2DImage(const video::ITexture* texture,
|
|||
if (!setActiveTexture(0, texture))
|
||||
return;
|
||||
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
|
||||
const int crop[] = {sourceRect.UpperLeftCorner.X, sourceRect.LowerRightCorner.Y, sourceRect.getWidth(), sourceRect.getHeight()};
|
||||
const GLint crop[] = {sourceRect.UpperLeftCorner.X, getCurrentRenderTargetSize().Height-sourceRect.LowerRightCorner.Y, sourceRect.getWidth(), sourceRect.getHeight()};
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
|
||||
core::rect<s32> destRect(sourceRect);
|
||||
destRect-=destRect.UpperLeftCorner;
|
||||
destRect+=pos;
|
||||
|
||||
const bool isRTT = true;//texture->isRenderTarget();
|
||||
if (!isRTT)
|
||||
{
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
GLfloat glmat[16];
|
||||
createGLTextureMatrix(glmat, TextureFlipMatrix);
|
||||
glLoadMatrixf(glmat);
|
||||
}
|
||||
core::rect<s32> destRect(pos,sourceRect.getSize());
|
||||
if (clipRect)
|
||||
destRect.clipAgainst(*clipRect);
|
||||
extGlDrawTex(destRect.UpperLeftCorner.X, destRect.UpperLeftCorner.Y, 0, destRect.getWidth(), destRect.getHeight());
|
||||
extGlDrawTex(destRect.UpperLeftCorner.X, getCurrentRenderTargetSize().Height-destRect.UpperLeftCorner.Y, 0, destRect.getWidth(), destRect.getHeight());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1421,7 +1428,11 @@ void COGLES1Driver::draw2DImage(const video::ITexture* texture,
|
|||
|
||||
targetPos.X += sourceRects[currentIndex].getWidth();
|
||||
}
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), indices.size()*4, quadIndices.pointer(), 2*indices.size(), video::EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT, false);
|
||||
if (vertices.size())
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), vertices.size(),
|
||||
quadIndices.pointer(), vertices.size()/2,
|
||||
video::EVT_STANDARD, scene::EPT_TRIANGLES,
|
||||
EIT_16BIT, false);
|
||||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
@ -1439,8 +1450,12 @@ void COGLES1Driver::draw2DImageBatch(const video::ITexture* texture,
|
|||
return;
|
||||
|
||||
const u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size());
|
||||
if (!drawCount)
|
||||
return;
|
||||
|
||||
const core::dimension2d<u32>& ss = texture->getOriginalSize();
|
||||
if (!ss.Width || !ss.Height)
|
||||
return;
|
||||
const f32 invW = 1.f / static_cast<f32>(ss.Width);
|
||||
const f32 invH = 1.f / static_cast<f32>(ss.Height);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
|
@ -1561,7 +1576,11 @@ void COGLES1Driver::draw2DImageBatch(const video::ITexture* texture,
|
|||
quadIndices.push_back(vstart+2);
|
||||
quadIndices.push_back(vstart+3);
|
||||
}
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), 4*drawCount, quadIndices.pointer(), 2*drawCount, video::EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT, false);
|
||||
if (vertices.size())
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), vertices.size(),
|
||||
quadIndices.pointer(), vertices.size()/2,
|
||||
video::EVT_STANDARD, scene::EPT_TRIANGLES,
|
||||
EIT_16BIT, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue