1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Irrlicht cleanups (mostly getting rid of core::array)

Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
sfan5 2024-08-17 19:49:11 +02:00 committed by GitHub
parent 5acc2736db
commit 5d226268df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 308 additions and 1227 deletions

View file

@ -257,7 +257,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d<u32> &screenS
DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits);
// DriverAttributes->setAttribute("MaxLights", MaxLights);
DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy);
// DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes);
// DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers);
// DriverAttributes->setAttribute("MaxMultipleRenderTargets", MaxMultipleRenderTargets);
DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices);
@ -268,8 +267,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d<u32> &screenS
GL.PixelStorei(GL_PACK_ALIGNMENT, 1);
UserClipPlane.reallocate(0);
for (s32 i = 0; i < ETS_COUNT; ++i)
setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix);
@ -916,7 +913,8 @@ void COpenGL3DriverBase::draw2DImageBatch(const video::ITexture *texture,
const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size());
assert(6 * drawCount <= QuadIndexCount); // FIXME split the batch? or let it crash?
core::array<S3DVertex> vtx(drawCount * 4);
std::vector<S3DVertex> vtx;
vtx.reserve(drawCount * 4);
for (u32 i = 0; i < drawCount; i++) {
core::position2d<s32> targetPos = positions[i];
@ -939,22 +937,22 @@ void COpenGL3DriverBase::draw2DImageBatch(const video::ITexture *texture,
f32 down = 2.f - (f32)poss.LowerRightCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f;
f32 top = 2.f - (f32)poss.UpperLeftCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f;
vtx.push_back(S3DVertex(left, top, 0.0f,
vtx.emplace_back(left, top, 0.0f,
0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y));
vtx.push_back(S3DVertex(right, top, 0.0f,
tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
vtx.emplace_back(right, top, 0.0f,
0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y));
vtx.push_back(S3DVertex(right, down, 0.0f,
tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
vtx.emplace_back(right, down, 0.0f,
0.0f, 0.0f, 0.0f, color,
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y));
vtx.push_back(S3DVertex(left, down, 0.0f,
tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
vtx.emplace_back(left, down, 0.0f,
0.0f, 0.0f, 0.0f, color,
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y));
tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
}
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, QuadIndexBuffer);
drawElements(GL_TRIANGLES, vt2DImage, vtx.const_pointer(), vtx.size(), 0, 6 * drawCount);
drawElements(GL_TRIANGLES, vt2DImage, vtx.data(), vtx.size(), 0, 6 * drawCount);
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
if (clipRect)
@ -1104,15 +1102,14 @@ void COpenGL3DriverBase::endDraw(const VertexType &vertexType)
ITexture *COpenGL3DriverBase::createDeviceDependentTexture(const io::path &name, IImage *image)
{
core::array<IImage *> imageArray(1);
imageArray.push_back(image);
std::vector<IImage*> tmp { image };
COpenGL3Texture *texture = new COpenGL3Texture(name, imageArray, ETT_2D, this);
COpenGL3Texture *texture = new COpenGL3Texture(name, tmp, ETT_2D, this);
return texture;
}
ITexture *COpenGL3DriverBase::createDeviceDependentTextureCubemap(const io::path &name, const core::array<IImage *> &image)
ITexture *COpenGL3DriverBase::createDeviceDependentTextureCubemap(const io::path &name, const std::vector<IImage*> &image)
{
COpenGL3Texture *texture = new COpenGL3Texture(name, image, ETT_CUBEMAP, this);
@ -1876,40 +1873,6 @@ void COpenGL3DriverBase::removeTexture(ITexture *texture)
CNullDriver::removeTexture(texture);
}
//! Set/unset a clipping plane.
bool COpenGL3DriverBase::setClipPlane(u32 index, const core::plane3df &plane, bool enable)
{
if (index >= UserClipPlane.size())
UserClipPlane.push_back(SUserClipPlane());
UserClipPlane[index].Plane = plane;
UserClipPlane[index].Enabled = enable;
return true;
}
//! Enable/disable a clipping plane.
void COpenGL3DriverBase::enableClipPlane(u32 index, bool enable)
{
UserClipPlane[index].Enabled = enable;
}
//! Get the ClipPlane Count
u32 COpenGL3DriverBase::getClipPlaneCount() const
{
return UserClipPlane.size();
}
const core::plane3df &COpenGL3DriverBase::getClipPlane(irr::u32 index) const
{
if (index < UserClipPlane.size())
return UserClipPlane[index].Plane;
else {
_IRR_DEBUG_BREAK_IF(true) // invalid index
static const core::plane3df dummy;
return dummy;
}
}
core::dimension2du COpenGL3DriverBase::getMaxTextureSize() const
{
return core::dimension2du(MaxTextureSize, MaxTextureSize);