mirror of
https://github.com/minetest/irrlicht.git
synced 2025-06-28 06:20:21 +02:00
Drop obsolete IVideoDriver features
This commit is contained in:
@ -1231,102 +1231,6 @@ COpenGL3Driver::~COpenGL3Driver()
|
||||
}
|
||||
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha channel
|
||||
void COpenGL3Driver::draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices, s32 kerningWidth,
|
||||
const core::rect<s32>* clipRect, SColor color,
|
||||
bool useAlphaChannelOfTexture)
|
||||
{
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
chooseMaterial2D();
|
||||
if (!setMaterialTexture(0, texture))
|
||||
return;
|
||||
|
||||
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
|
||||
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
|
||||
if (clipRect)
|
||||
{
|
||||
if (!clipRect->isValid())
|
||||
return;
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
|
||||
const core::dimension2du& ss = texture->getOriginalSize();
|
||||
core::position2d<s32> targetPos(pos);
|
||||
// texcoords need to be flipped horizontally for RTTs
|
||||
const bool isRTT = texture->isRenderTarget();
|
||||
const f32 invW = 1.f / static_cast<f32>(ss.Width);
|
||||
const f32 invH = 1.f / static_cast<f32>(ss.Height);
|
||||
|
||||
core::array<S3DVertex> vertices;
|
||||
core::array<u16> quadIndices;
|
||||
vertices.reallocate(indices.size()*4);
|
||||
quadIndices.reallocate(indices.size()*3);
|
||||
|
||||
for (u32 i = 0; i < indices.size(); ++i)
|
||||
{
|
||||
const s32 currentIndex = indices[i];
|
||||
if (!sourceRects[currentIndex].isValid())
|
||||
break;
|
||||
|
||||
const core::rect<f32> tcoords(
|
||||
sourceRects[currentIndex].UpperLeftCorner.X * invW,
|
||||
(isRTT ? sourceRects[currentIndex].LowerRightCorner.Y : sourceRects[currentIndex].UpperLeftCorner.Y) * invH,
|
||||
sourceRects[currentIndex].LowerRightCorner.X * invW,
|
||||
(isRTT ? sourceRects[currentIndex].UpperLeftCorner.Y : sourceRects[currentIndex].LowerRightCorner.Y) * invH);
|
||||
|
||||
const core::rect<s32> poss(targetPos, sourceRects[currentIndex].getSize());
|
||||
|
||||
f32 left = (f32)poss.UpperLeftCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f;
|
||||
f32 right = (f32)poss.LowerRightCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f;
|
||||
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;
|
||||
|
||||
const u32 vstart = vertices.size();
|
||||
vertices.push_back(S3DVertex(left, top, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y));
|
||||
vertices.push_back(S3DVertex(right, top, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y));
|
||||
vertices.push_back(S3DVertex(right, down, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y));
|
||||
vertices.push_back(S3DVertex(left, down, 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();
|
||||
}
|
||||
|
||||
if (vertices.size())
|
||||
{
|
||||
glEnableVertexAttribArray(EVA_POSITION);
|
||||
glEnableVertexAttribArray(EVA_COLOR);
|
||||
glEnableVertexAttribArray(EVA_TCOORD0);
|
||||
glVertexAttribPointer(EVA_POSITION, 3, GL_FLOAT, false, sizeof(S3DVertex), &vertices[0].Pos);
|
||||
glVertexAttribPointer(EVA_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(S3DVertex), &vertices[0].Color);
|
||||
glVertexAttribPointer(EVA_TCOORD0, 2, GL_FLOAT, false, sizeof(S3DVertex), &vertices[0].TCoords);
|
||||
glDrawElements(GL_TRIANGLES, quadIndices.size(), GL_UNSIGNED_SHORT, quadIndices.pointer());
|
||||
glDisableVertexAttribArray(EVA_TCOORD0);
|
||||
glDisableVertexAttribArray(EVA_COLOR);
|
||||
glDisableVertexAttribArray(EVA_POSITION);
|
||||
}
|
||||
|
||||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
testGLError(__LINE__);
|
||||
}
|
||||
|
||||
|
||||
//! draw a 2d rectangle
|
||||
void COpenGL3Driver::draw2DRectangle(SColor color,
|
||||
const core::rect<s32>& position,
|
||||
@ -1980,127 +1884,6 @@ COpenGL3Driver::~COpenGL3Driver()
|
||||
}
|
||||
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer.
|
||||
void COpenGL3Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
|
||||
{
|
||||
const u32 count=triangles.size();
|
||||
if (!StencilBuffer || !count)
|
||||
return;
|
||||
|
||||
bool fog = Material.FogEnable;
|
||||
bool lighting = Material.Lighting;
|
||||
E_MATERIAL_TYPE materialType = Material.MaterialType;
|
||||
|
||||
Material.FogEnable = false;
|
||||
Material.Lighting = false;
|
||||
Material.MaterialType = EMT_SOLID; // Dedicated material in future.
|
||||
|
||||
setRenderStates3DMode();
|
||||
|
||||
CacheHandler->setDepthTest(true);
|
||||
CacheHandler->setDepthFunc(GL_LESS);
|
||||
CacheHandler->setDepthMask(false);
|
||||
|
||||
if (!(debugDataVisible & (scene::EDS_SKELETON|scene::EDS_MESH_WIRE_OVERLAY)))
|
||||
{
|
||||
CacheHandler->setColorMask(ECP_NONE);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
glEnableVertexAttribArray(EVA_POSITION);
|
||||
glVertexAttribPointer(EVA_POSITION, 3, GL_FLOAT, false, sizeof(core::vector3df), triangles.const_pointer());
|
||||
|
||||
glStencilMask(~0);
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
|
||||
GLenum decr = GL_DECR;
|
||||
GLenum incr = GL_INCR;
|
||||
|
||||
#if defined(GL_OES_stencil_wrap)
|
||||
if (FeatureAvailable[IRR_OES_stencil_wrap])
|
||||
{
|
||||
decr = GL_DECR_WRAP_OES;
|
||||
incr = GL_INCR_WRAP_OES;
|
||||
}
|
||||
#endif
|
||||
|
||||
CacheHandler->setCullFace(true);
|
||||
|
||||
if (zfail)
|
||||
{
|
||||
CacheHandler->setCullFaceFunc(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, incr, GL_KEEP);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
CacheHandler->setCullFaceFunc(GL_BACK);
|
||||
glStencilOp(GL_KEEP, decr, GL_KEEP);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
}
|
||||
else // zpass
|
||||
{
|
||||
CacheHandler->setCullFaceFunc(GL_BACK);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, incr);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
CacheHandler->setCullFaceFunc(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, decr);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
}
|
||||
|
||||
glDisableVertexAttribArray(EVA_POSITION);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
Material.FogEnable = fog;
|
||||
Material.Lighting = lighting;
|
||||
Material.MaterialType = materialType;
|
||||
}
|
||||
|
||||
|
||||
void COpenGL3Driver::drawStencilShadow(bool clearStencilBuffer,
|
||||
video::SColor leftUpEdge, video::SColor rightUpEdge,
|
||||
video::SColor leftDownEdge, video::SColor rightDownEdge)
|
||||
{
|
||||
if (!StencilBuffer)
|
||||
return;
|
||||
|
||||
chooseMaterial2D();
|
||||
setMaterialTexture(0, 0);
|
||||
|
||||
setRenderStates2DMode(true, false, false);
|
||||
|
||||
CacheHandler->setDepthMask(false);
|
||||
CacheHandler->setColorMask(ECP_ALL);
|
||||
|
||||
CacheHandler->setBlend(true);
|
||||
CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_NOTEQUAL, 0, ~0);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
|
||||
u16 indices[] = {0, 1, 2, 3};
|
||||
S3DVertex vertices[4];
|
||||
vertices[0] = S3DVertex(-1.f, 1.f, 0.9f, 0, 0, 1, leftDownEdge, 0, 0);
|
||||
vertices[1] = S3DVertex(1.f, 1.f, 0.9f, 0, 0, 1, leftUpEdge, 0, 0);
|
||||
vertices[2] = S3DVertex(1.f, -1.f, 0.9f, 0, 0, 1, rightUpEdge, 0, 0);
|
||||
vertices[3] = S3DVertex(-1.f, -1.f, 0.9f, 0, 0, 1, rightDownEdge, 0, 0);
|
||||
|
||||
glEnableVertexAttribArray(EVA_POSITION);
|
||||
glEnableVertexAttribArray(EVA_COLOR);
|
||||
glVertexAttribPointer(EVA_POSITION, 3, GL_FLOAT, false, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].Pos);
|
||||
glVertexAttribPointer(EVA_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].Color);
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, indices);
|
||||
glDisableVertexAttribArray(EVA_COLOR);
|
||||
glDisableVertexAttribArray(EVA_POSITION);
|
||||
|
||||
if (clearStencilBuffer)
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
|
||||
//! Draws a 3d line.
|
||||
void COpenGL3Driver::draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end, SColor color)
|
||||
|
@ -103,15 +103,6 @@ namespace video
|
||||
// internally used
|
||||
virtual void draw2DImage(const video::ITexture* texture, u32 layer, bool flip);
|
||||
|
||||
//! draws a set of 2d images
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices, s32 kerningWidth = 0,
|
||||
const core::rect<s32>* clipRect = 0,
|
||||
SColor color = SColor(255, 255, 255, 255),
|
||||
bool useAlphaChannelOfTexture = false) override;
|
||||
|
||||
void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::array<core::position2d<s32> >& positions,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
@ -150,16 +141,6 @@ namespace video
|
||||
//! Returns the maximum texture size supported.
|
||||
core::dimension2du getMaxTextureSize() const override;
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer.
|
||||
void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0) override;
|
||||
|
||||
//! Fills the stencil shadow with color.
|
||||
virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0)) override;
|
||||
|
||||
//! sets a viewport
|
||||
void setViewPort(const core::rect<s32>& area) override;
|
||||
|
||||
|
Reference in New Issue
Block a user