1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-10 03:55:20 +01:00

Irrlicht: remove some dead code

This commit is contained in:
sfan5
2025-11-03 14:43:52 +01:00
parent 2368126d0a
commit 8042b5512f
22 changed files with 9 additions and 452 deletions

View File

@@ -1,32 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CFPSCounter.h"
#include "irrMath.h"
namespace video
{
CFPSCounter::CFPSCounter() :
FPS(0), StartTime(0), FramesCounted(0)
{
}
//! to be called every frame
void CFPSCounter::registerFrame(u32 now)
{
++FramesCounted;
const u32 milliseconds = now - StartTime;
if (milliseconds >= 1500) {
const f32 invMilli = core::reciprocal((f32)milliseconds);
FPS = core::ceil32((1000 * FramesCounted) * invMilli);
FramesCounted = 0;
StartTime = now;
}
}
} // end namespace video

View File

@@ -1,29 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#pragma once
#include "irrTypes.h"
namespace video
{
class CFPSCounter
{
public:
CFPSCounter();
//! returns current fps
s32 getFPS() const { return FPS; }
//! to be called every frame
void registerFrame(u32 now);
private:
s32 FPS;
u32 StartTime;
u32 FramesCounted;
};
} // end namespace video

View File

@@ -384,7 +384,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters &param) :
sdlver += SDL_GetPlatform();
}
Operator = new COSOperator(sdlver);
Operator = new COSOperator();
if (SDLDeviceInstances == 1) {
os::Printer::log(sdlver.c_str(), ELL_INFORMATION);
}
@@ -1351,26 +1351,6 @@ bool CIrrDeviceSDL::isWindowMinimized() const
return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MINIMIZED) != 0;
}
//! returns color format of the window.
video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const
{
if (Window) {
SDL_Surface *surface = SDL_GetWindowSurface(Window);
if (surface->format->BitsPerPixel == 16) {
if (surface->format->Amask != 0)
return video::ECF_A1R5G5B5;
else
return video::ECF_R5G6B5;
} else {
if (surface->format->Amask != 0)
return video::ECF_A8R8G8B8;
else
return video::ECF_R8G8B8;
}
} else
return CIrrDeviceStub::getColorFormat();
}
void CIrrDeviceSDL::createKeyMap()
{
// I don't know if this is the best method to create

View File

@@ -54,9 +54,6 @@ public:
//! returns if window is minimized.
bool isWindowMinimized() const override;
//! returns color format of the window.
video::ECOLOR_FORMAT getColorFormat() const override;
//! notifies the device that it should close itself
void closeDevice() override;

View File

@@ -261,12 +261,6 @@ bool CIrrDeviceStub::isFullscreen() const
return CreationParams.Fullscreen;
}
//! returns color format
video::ECOLOR_FORMAT CIrrDeviceStub::getColorFormat() const
{
return video::ECF_R5G6B5;
}
//! No-op in this implementation
bool CIrrDeviceStub::activateJoysticks(core::array<SJoystickInfo> &joystickInfo)
{

View File

@@ -101,9 +101,6 @@ public:
//! Checks if the window is running in fullscreen mode.
bool isFullscreen() const override;
//! get color format of the current window
video::ECOLOR_FORMAT getColorFormat() const override;
//! Activate any joysticks, and generate events for them.
bool activateJoysticks(core::array<SJoystickInfo> &joystickInfo) override;

View File

@@ -341,8 +341,6 @@ set(IRRIMAGEOBJ
)
add_library(IRRVIDEOOBJ OBJECT
CFPSCounter.h
CFPSCounter.cpp
${IRRDRVROBJ}
${IRRIMAGEOBJ}
)

View File

@@ -208,7 +208,6 @@ bool CNullDriver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u
bool CNullDriver::endScene()
{
FPSCounter.registerFrame(os::Timer::getRealTime());
expireHardwareBuffers();
updateAllOcclusionQueries();
return true;
@@ -680,12 +679,6 @@ void CNullDriver::draw2DLine(const core::position2d<s32> &start,
{
}
//! returns color format
ECOLOR_FORMAT CNullDriver::getColorFormat() const
{
return ECF_R5G6B5;
}
//! returns screen size
const core::dimension2d<u32> &CNullDriver::getScreenSize() const
{
@@ -706,12 +699,6 @@ const core::dimension2d<u32> &CNullDriver::getCurrentRenderTargetSize() const
return CurrentRenderTargetSize;
}
// returns current frames per second value
s32 CNullDriver::getFPS() const
{
return FPSCounter.getFPS();
}
SFrameStats CNullDriver::getFrameStats() const
{
return FrameStats;
@@ -725,118 +712,6 @@ const char *CNullDriver::getName() const
return "Irrlicht NullDevice";
}
//! Creates a boolean alpha channel of the texture based of an color key.
void CNullDriver::makeColorKeyTexture(video::ITexture *texture,
video::SColor color) const
{
if (!texture)
return;
if (texture->getColorFormat() != ECF_A1R5G5B5 &&
texture->getColorFormat() != ECF_A8R8G8B8) {
os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR);
return;
}
if (texture->getColorFormat() == ECF_A1R5G5B5) {
u16 *p = (u16 *)texture->lock();
if (!p) {
os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR);
return;
}
const core::dimension2d<u32> dim = texture->getSize();
const u32 pitch = texture->getPitch() / 2;
// color with alpha disabled (i.e. fully transparent)
const u16 refZeroAlpha = (0x7fff & color.toA1R5G5B5());
const u32 pixels = pitch * dim.Height;
for (u32 pixel = 0; pixel < pixels; ++pixel) {
// If the color matches the reference color, ignoring alphas,
// set the alpha to zero.
if (((*p) & 0x7fff) == refZeroAlpha)
(*p) = refZeroAlpha;
++p;
}
texture->unlock();
} else {
u32 *p = (u32 *)texture->lock();
if (!p) {
os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR);
return;
}
core::dimension2d<u32> dim = texture->getSize();
u32 pitch = texture->getPitch() / 4;
// color with alpha disabled (fully transparent)
const u32 refZeroAlpha = 0x00ffffff & color.color;
const u32 pixels = pitch * dim.Height;
for (u32 pixel = 0; pixel < pixels; ++pixel) {
// If the color matches the reference color, ignoring alphas,
// set the alpha to zero.
if (((*p) & 0x00ffffff) == refZeroAlpha)
(*p) = refZeroAlpha;
++p;
}
texture->unlock();
}
texture->regenerateMipMapLevels();
}
//! Creates an boolean alpha channel of the texture based of an color key position.
void CNullDriver::makeColorKeyTexture(video::ITexture *texture,
core::position2d<s32> colorKeyPixelPos) const
{
if (!texture)
return;
if (texture->getColorFormat() != ECF_A1R5G5B5 &&
texture->getColorFormat() != ECF_A8R8G8B8) {
os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR);
return;
}
SColor colorKey;
if (texture->getColorFormat() == ECF_A1R5G5B5) {
u16 *p = (u16 *)texture->lock(ETLM_READ_ONLY);
if (!p) {
os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR);
return;
}
u32 pitch = texture->getPitch() / 2;
const u16 key16Bit = 0x7fff & p[colorKeyPixelPos.Y * pitch + colorKeyPixelPos.X];
colorKey = video::A1R5G5B5toA8R8G8B8(key16Bit);
} else {
u32 *p = (u32 *)texture->lock(ETLM_READ_ONLY);
if (!p) {
os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR);
return;
}
u32 pitch = texture->getPitch() / 4;
colorKey = 0x00ffffff & p[colorKeyPixelPos.Y * pitch + colorKeyPixelPos.X];
}
texture->unlock();
makeColorKeyTexture(texture, colorKey);
}
SDriverLimits CNullDriver::getLimits() const
{
SDriverLimits ret;
@@ -1427,15 +1302,6 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer *renderer, const char *na
return MaterialRenderers.size() - 1;
}
//! Sets the name of a material renderer.
void CNullDriver::setMaterialRendererName(u32 idx, const char *name)
{
if (idx < numBuiltInMaterials || idx >= MaterialRenderers.size())
return;
MaterialRenderers[idx].Name = name;
}
void CNullDriver::swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames)
{
if (idx1 < MaterialRenderers.size() && idx2 < MaterialRenderers.size()) {
@@ -1483,15 +1349,6 @@ u32 CNullDriver::getMaterialRendererCount() const
return MaterialRenderers.size();
}
//! Returns name of the material renderer
const char *CNullDriver::getMaterialRendererName(u32 idx) const
{
if (idx < MaterialRenderers.size())
return MaterialRenderers[idx].Name.c_str();
return 0;
}
//! Returns pointer to the IGPUProgrammingServices interface.
IGPUProgrammingServices *CNullDriver::getGPUProgrammingServices()
{

View File

@@ -12,7 +12,6 @@
#include "IMesh.h"
#include "IMeshBuffer.h"
#include "IMeshSceneNode.h"
#include "CFPSCounter.h"
#include "S3DVertex.h"
#include "SVertexIndex.h"
#include "SExposedVideoData.h"
@@ -175,9 +174,6 @@ public:
f32 &start, f32 &end, f32 &density,
bool &pixelFog, bool &rangeFog) override;
//! get color format of the current color buffer
ECOLOR_FORMAT getColorFormat() const override;
//! get screen size
const core::dimension2d<u32> &getScreenSize() const override;
@@ -187,9 +183,6 @@ public:
//! get render target size
const core::dimension2d<u32> &getCurrentRenderTargetSize() const override;
// get current frames per second value
s32 getFPS() const override;
SFrameStats getFrameStats() const override;
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
@@ -222,13 +215,6 @@ public:
ITexture *addRenderTargetTextureCubemap(const u32 sideLen,
const io::path &name, const ECOLOR_FORMAT format) override;
//! Creates an 1bit alpha channel of the texture based of an color key.
void makeColorKeyTexture(video::ITexture *texture, video::SColor color) const override;
//! Creates an 1bit alpha channel of the texture based of an color key position.
virtual void makeColorKeyTexture(video::ITexture *texture,
core::position2d<s32> colorKeyPixelPos) const override;
SDriverLimits getLimits() const override;
//! Enables or disables a texture creation flag.
@@ -436,8 +422,6 @@ public:
//! Returns amount of currently available material renderers.
u32 getMaterialRendererCount() const override;
//! Returns name of the material renderer
const char *getMaterialRendererName(u32 idx) const override;
//! Adds a new material renderer to the VideoDriver, based on a high level shading language.
virtual s32 addHighLevelShaderMaterial(
@@ -492,9 +476,6 @@ public:
//! Writes the provided image to a file.
bool writeImageToFile(IImage *image, io::IWriteFile *file, u32 param = 0) override;
//! Sets the name of a material renderer.
void setMaterialRendererName(u32 idx, const char *name) override;
//! Swap the material renderers used for certain id's
void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) override;
@@ -692,7 +673,6 @@ protected:
core::dimension2d<u32> ScreenSize;
core::matrix4 TransformationMatrix;
CFPSCounter FPSCounter;
SFrameStats FrameStats;
u32 MinVertexCountForVBO;

View File

@@ -25,8 +25,7 @@
#include "fast_atof.h"
// constructor
COSOperator::COSOperator(const core::stringc &osVersion) :
OperatingSystem(osVersion)
COSOperator::COSOperator()
{}
COSOperator::~COSOperator()
@@ -37,12 +36,6 @@ COSOperator::~COSOperator()
#endif
}
//! returns the current operating system version as string.
const core::stringc &COSOperator::getOperatingSystemVersion() const
{
return OperatingSystem;
}
//! copies text to the clipboard
void COSOperator::copyToClipboard(const c8 *text) const
{
@@ -97,52 +90,3 @@ const c8 *COSOperator::getTextFromPrimarySelection() const
#endif
}
bool COSOperator::getSystemMemory(u32 *Total, u32 *Avail) const
{
#if defined(_IRR_WINDOWS_API_)
MEMORYSTATUSEX MemoryStatusEx;
MemoryStatusEx.dwLength = sizeof(MEMORYSTATUSEX);
// cannot fail
GlobalMemoryStatusEx(&MemoryStatusEx);
if (Total)
*Total = (u32)(MemoryStatusEx.ullTotalPhys >> 10);
if (Avail)
*Avail = (u32)(MemoryStatusEx.ullAvailPhys >> 10);
return true;
#elif defined(_IRR_POSIX_API_) && defined(_SC_PHYS_PAGES) && defined(_SC_AVPHYS_PAGES)
long ps = sysconf(_SC_PAGESIZE);
long pp = sysconf(_SC_PHYS_PAGES);
long ap = sysconf(_SC_AVPHYS_PAGES);
if (ps == -1 || (Total && pp == -1) || (Avail && ap == -1))
return false;
if (Total)
*Total = (u32)((pp >> 10) * ps);
if (Avail)
*Avail = (u32)((ap >> 10) * ps);
return true;
#elif defined(_IRR_OSX_PLATFORM_)
int mib[2];
int64_t physical_memory;
size_t length;
// Get the Physical memory size
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE;
length = sizeof(int64_t);
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
if (Total)
*Total = (u32)(physical_memory >> 10);
if (Avail)
*Avail = (u32)(physical_memory >> 10); // we don't know better
return true;
#else
return false;
#endif
}

View File

@@ -11,16 +11,13 @@ class COSOperator : public IOSOperator
{
public:
// constructor
COSOperator(const core::stringc &osversion);
COSOperator();
~COSOperator();
COSOperator(const COSOperator &) = delete;
COSOperator &operator=(const COSOperator &) = delete;
//! Get the current OS version as string.
const core::stringc &getOperatingSystemVersion() const override;
//! Copies text to the clipboard
//! \param text: text in utf-8
void copyToClipboard(const c8 *text) const override;
@@ -39,15 +36,7 @@ public:
//! \return Returns 0 if no string is in there, otherwise an utf-8 string.
const c8 *getTextFromPrimarySelection() const override;
//! Get the total and available system RAM
/** \param totalBytes: will contain the total system memory in Kilobytes (1024 B)
\param availableBytes: will contain the available memory in Kilobytes (1024 B)
\return True if successful, false if not */
bool getSystemMemory(u32 *Total, u32 *Avail) const override;
private:
core::stringc OperatingSystem;
#ifdef _IRR_WINDOWS_API_
mutable core::stringc ClipboardBuf;
#endif

View File

@@ -151,7 +151,7 @@ public:
OriginalColorFormat = format;
if (ECF_UNKNOWN == OriginalColorFormat)
ColorFormat = getBestColorFormat(Driver->getColorFormat());
ColorFormat = getBestColorFormat(video::ECF_A8R8G8B8);
else
ColorFormat = OriginalColorFormat;

View File

@@ -28,7 +28,7 @@ const u16 COpenGLDriver::Quad2DIndices[4] = {0, 1, 2, 3};
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters &params, io::IFileSystem *io, IContextManager *contextManager) :
CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE), Params(params),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), FixedPipelineState(EOFPS_ENABLE), Params(params),
ContextManager(contextManager)
{}
@@ -2505,12 +2505,6 @@ E_DRIVER_TYPE COpenGLDriver::getDriverType() const
return EDT_OPENGL;
}
//! returns color format
ECOLOR_FORMAT COpenGLDriver::getColorFormat() const
{
return ColorFormat;
}
//! Get a vertex shader constant index.
s32 COpenGLDriver::getVertexShaderConstantID(const c8 *name)
{
@@ -2776,7 +2770,7 @@ IImage *COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
return 0;
if (format == video::ECF_UNKNOWN)
format = getColorFormat();
format = video::ECF_R8G8B8;
// TODO: Maybe we could support more formats (floating point and some of those beyond ECF_R8), didn't really try yet
if (IImage::isCompressedFormat(format) || IImage::isDepthFormat(format) || IImage::isFloatingPointFormat(format) || format >= ECF_R8)

View File

@@ -183,9 +183,6 @@ public:
//! Returns type of video driver
E_DRIVER_TYPE getDriverType() const override;
//! get color format of the current color buffer
ECOLOR_FORMAT getColorFormat() const override;
//! Returns the transformation set by setTransform
const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const override;
@@ -368,9 +365,6 @@ private:
core::matrix4 TextureFlipMatrix;
//! Color buffer format
ECOLOR_FORMAT ColorFormat;
E_OPENGL_FIXED_PIPELINE_STATE FixedPipelineState;
SIrrlichtCreationParameters Params;

View File

@@ -152,7 +152,7 @@ COpenGL3DriverBase::COpenGL3DriverBase(const SIrrlichtCreationParameters &params
MaterialRenderer2DActive(0), MaterialRenderer2DTexture(0), MaterialRenderer2DNoTexture(0),
CurrentRenderMode(ERM_NONE), Transformation3DChanged(true),
OGLES2ShaderPath(params.OGLES2ShaderPath),
ColorFormat(ECF_R8G8B8), ContextManager(contextManager), EnableErrorTest(params.DriverDebug)
ContextManager(contextManager), EnableErrorTest(params.DriverDebug)
{
if (!ContextManager)
return;
@@ -1560,12 +1560,6 @@ E_DRIVER_TYPE COpenGL3DriverBase::getDriverType() const
return EDT_OPENGL3;
}
//! returns color format
ECOLOR_FORMAT COpenGL3DriverBase::getColorFormat() const
{
return ColorFormat;
}
//! Get a vertex shader constant index.
s32 COpenGL3DriverBase::getVertexShaderConstantID(const c8 *name)
{

View File

@@ -144,9 +144,6 @@ public:
//! Returns type of video driver
E_DRIVER_TYPE getDriverType() const override;
//! get color format of the current color buffer
ECOLOR_FORMAT getColorFormat() const override;
//! Returns the transformation set by setTransform
const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const override;
@@ -351,9 +348,6 @@ private:
SMaterial Material, LastMaterial;
//! Color buffer format
ECOLOR_FORMAT ColorFormat;
IContextManager *ContextManager;
void printTextureFormats();