Add GEGLTexture
This commit is contained in:
parent
85843433c0
commit
c4cae7d622
@ -5,4 +5,5 @@ add_library(graphics_engine STATIC
|
|||||||
src/vulkan.c
|
src/vulkan.c
|
||||||
src/ge_main.cpp
|
src/ge_main.cpp
|
||||||
src/ge_texture.cpp
|
src/ge_texture.cpp
|
||||||
|
src/ge_gl_texture.cpp
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef HEADER_GE_TEXTURE_HPP
|
#ifndef HEADER_GE_TEXTURE_HPP
|
||||||
#define HEADER_GE_TEXTURE_HPP
|
#define HEADER_GE_TEXTURE_HPP
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ITexture.h>
|
#include <ITexture.h>
|
||||||
#include <IImage.h>
|
#include <IImage.h>
|
||||||
@ -8,9 +9,12 @@
|
|||||||
namespace GE
|
namespace GE
|
||||||
{
|
{
|
||||||
irr::video::ITexture* createFontTexture(const std::string& name);
|
irr::video::ITexture* createFontTexture(const std::string& name);
|
||||||
irr::video::ITexture* createTexture(irr::video::IImage* img);
|
irr::video::ITexture* createTexture(irr::video::IImage* img,
|
||||||
irr::video::IImage* getResizedImage(const std::string& path);
|
const std::string& name);
|
||||||
irr::video::ITexture* createTexture(const std::string& path);
|
irr::video::IImage* getResizedImage(const std::string& path,
|
||||||
|
irr::core::dimension2d<irr::u32>* orig_size = NULL);
|
||||||
|
irr::video::ITexture* createTexture(const std::string& path,
|
||||||
|
std::function<void(irr::video::IImage*)> image_mani = nullptr);
|
||||||
}; // GE
|
}; // GE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
131
lib/graphics_engine/src/ge_gl_texture.cpp
Normal file
131
lib/graphics_engine/src/ge_gl_texture.cpp
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
#include "ge_gl_texture.hpp"
|
||||||
|
#include "ge_main.hpp"
|
||||||
|
#include "ge_texture.hpp"
|
||||||
|
|
||||||
|
namespace GE
|
||||||
|
{
|
||||||
|
GEGLTexture::GEGLTexture(const std::string& path,
|
||||||
|
std::function<void(video::IImage*)> image_mani)
|
||||||
|
: video::ITexture(path.c_str()), m_image_mani(image_mani),
|
||||||
|
m_single_channel(false), m_texture_name(0), m_texture_size(0),
|
||||||
|
m_driver_type(GE::getDriver()->getDriverType()),
|
||||||
|
m_disable_reload(false)
|
||||||
|
{
|
||||||
|
reload();
|
||||||
|
} // GEGLTexture
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
GEGLTexture::GEGLTexture(video::IImage* img, const std::string& name)
|
||||||
|
: video::ITexture(name.c_str()), m_image_mani(nullptr),
|
||||||
|
m_single_channel(false), m_texture_name(0), m_texture_size(0),
|
||||||
|
m_driver_type(GE::getDriver()->getDriverType()),
|
||||||
|
m_disable_reload(true)
|
||||||
|
{
|
||||||
|
glGenTextures(1, &m_texture_name);
|
||||||
|
m_size = m_orig_size = img->getDimension();
|
||||||
|
uint8_t* data = (uint8_t*)img->lock();
|
||||||
|
upload(data);
|
||||||
|
img->unlock();
|
||||||
|
img->drop();
|
||||||
|
} // GEGLTexture
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
GEGLTexture::~GEGLTexture()
|
||||||
|
{
|
||||||
|
if (m_texture_name != 0)
|
||||||
|
glDeleteTextures(1, &m_texture_name);
|
||||||
|
} // ~GEGLTexture
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void GEGLTexture::reload()
|
||||||
|
{
|
||||||
|
if (m_disable_reload)
|
||||||
|
return;
|
||||||
|
video::IImage* texture_image = getResizedImage(NamedPath.getPtr(),
|
||||||
|
&m_orig_size);
|
||||||
|
if (texture_image == NULL)
|
||||||
|
return;
|
||||||
|
m_size = texture_image->getDimension();
|
||||||
|
if (m_image_mani)
|
||||||
|
m_image_mani(texture_image);
|
||||||
|
if (m_texture_name == 0)
|
||||||
|
glGenTextures(1, &m_texture_name);
|
||||||
|
uint8_t* data = (uint8_t*)texture_image->lock();
|
||||||
|
upload(data);
|
||||||
|
texture_image->unlock();
|
||||||
|
texture_image->drop();
|
||||||
|
} // reload
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void GEGLTexture::upload(uint8_t* data)
|
||||||
|
{
|
||||||
|
const unsigned int w = m_size.Width;
|
||||||
|
const unsigned int h = m_size.Height;
|
||||||
|
unsigned int format = m_single_channel ? GL_RED : GL_BGRA;
|
||||||
|
unsigned int internal_format = m_single_channel ? GL_R8 : GL_RGBA8;
|
||||||
|
|
||||||
|
if (m_driver_type == video::EDT_OGLES2)
|
||||||
|
{
|
||||||
|
formatConversion(data, &format, w, h);
|
||||||
|
int gl_major_version = 0;
|
||||||
|
glGetIntegerv(GL_MAJOR_VERSION, &gl_major_version);
|
||||||
|
// GLES 2.0 specs doesn't allow GL_RGBA8 internal format
|
||||||
|
if (gl_major_version < 3)
|
||||||
|
internal_format = GL_RGBA;
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_texture_name);
|
||||||
|
if (m_single_channel)
|
||||||
|
{
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ONE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ONE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ONE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
|
||||||
|
}
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, format,
|
||||||
|
GL_UNSIGNED_BYTE, data);
|
||||||
|
if (hasMipMaps())
|
||||||
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
m_texture_size = w * h * (m_single_channel ? 1 : 4);
|
||||||
|
} // upload
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void* GEGLTexture::lock(video::E_TEXTURE_LOCK_MODE mode, u32 mipmap_level)
|
||||||
|
{
|
||||||
|
if (m_driver_type == video::EDT_OGLES2 || !glGetTexImage)
|
||||||
|
{
|
||||||
|
video::IImage* img = getResizedImage(NamedPath.getPtr());
|
||||||
|
img->setDeleteMemory(false);
|
||||||
|
void* data = img->lock();
|
||||||
|
img->drop();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
uint8_t* pixels = new uint8_t[m_size.Width * m_size.Height * 4]();
|
||||||
|
GLint tmp_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &tmp_texture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_texture_name);
|
||||||
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tmp_texture);
|
||||||
|
return pixels;
|
||||||
|
} // lock
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void GEGLTexture::formatConversion(uint8_t* data, unsigned int* format,
|
||||||
|
unsigned int w, unsigned int h) const
|
||||||
|
{
|
||||||
|
if (!m_single_channel)
|
||||||
|
{
|
||||||
|
if (format)
|
||||||
|
*format = GL_RGBA;
|
||||||
|
for (unsigned int i = 0; i < w * h; i++)
|
||||||
|
{
|
||||||
|
uint8_t tmp_val = data[i * 4];
|
||||||
|
data[i * 4] = data[i * 4 + 2];
|
||||||
|
data[i * 4 + 2] = tmp_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // formatConversion
|
||||||
|
|
||||||
|
}
|
78
lib/graphics_engine/src/ge_gl_texture.hpp
Normal file
78
lib/graphics_engine/src/ge_gl_texture.hpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#ifndef HEADER_GE_GL_TEXTURE_HPP
|
||||||
|
#define HEADER_GE_GL_TEXTURE_HPP
|
||||||
|
|
||||||
|
#include "glad/gl.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
#include <ITexture.h>
|
||||||
|
|
||||||
|
using namespace irr;
|
||||||
|
|
||||||
|
namespace GE
|
||||||
|
{
|
||||||
|
class GEGLTexture : public video::ITexture
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
core::dimension2d<u32> m_size, m_orig_size;
|
||||||
|
|
||||||
|
std::function<void(video::IImage*)> m_image_mani;
|
||||||
|
|
||||||
|
bool m_single_channel;
|
||||||
|
|
||||||
|
GLuint m_texture_name;
|
||||||
|
|
||||||
|
unsigned int m_texture_size;
|
||||||
|
|
||||||
|
const video::E_DRIVER_TYPE m_driver_type;
|
||||||
|
|
||||||
|
const bool m_disable_reload;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void upload(uint8_t* data);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void formatConversion(uint8_t* data, unsigned int* format, unsigned int w,
|
||||||
|
unsigned int h) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
GEGLTexture(const std::string& path,
|
||||||
|
std::function<void(video::IImage*)> image_mani = nullptr);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
GEGLTexture(video::IImage* img, const std::string& name);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual ~GEGLTexture();
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void* lock(video::E_TEXTURE_LOCK_MODE mode =
|
||||||
|
video::ETLM_READ_WRITE, u32 mipmap_level = 0);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void unlock() {}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual const core::dimension2d<u32>& getOriginalSize() const
|
||||||
|
{ return m_orig_size; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual const core::dimension2d<u32>& getSize() const { return m_size; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual video::E_DRIVER_TYPE getDriverType() const
|
||||||
|
{ return m_driver_type; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual video::ECOLOR_FORMAT getColorFormat() const
|
||||||
|
{ return video::ECF_A8R8G8B8; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual u32 getPitch() const { return 0; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual bool hasMipMaps() const { return glGenerateMipmap != NULL; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void regenerateMipMapLevels(void* mipmap_data = NULL) {}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual u64 getTextureHandler() const { return m_texture_name; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual unsigned int getTextureSize() const { return m_texture_size; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual void reload();
|
||||||
|
|
||||||
|
}; // GEGLTexture
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,4 +1,5 @@
|
|||||||
#include "ge_main.hpp"
|
#include "ge_main.hpp"
|
||||||
|
#include "ge_gl_texture.hpp"
|
||||||
#include "ge_texture.hpp"
|
#include "ge_texture.hpp"
|
||||||
|
|
||||||
#include <IVideoDriver.h>
|
#include <IVideoDriver.h>
|
||||||
@ -7,11 +8,14 @@
|
|||||||
namespace GE
|
namespace GE
|
||||||
{
|
{
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
video::IImage* getResizedImage(const std::string& path)
|
video::IImage* getResizedImage(const std::string& path,
|
||||||
|
core::dimension2d<u32>* orig_size)
|
||||||
{
|
{
|
||||||
video::IImage* image = getDriver()->createImageFromFile(path.c_str());
|
video::IImage* image = getDriver()->createImageFromFile(path.c_str());
|
||||||
if (image == NULL)
|
if (image == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (orig_size)
|
||||||
|
*orig_size = image->getDimension();
|
||||||
|
|
||||||
core::dimension2du img_size = image->getDimension();
|
core::dimension2du img_size = image->getDimension();
|
||||||
bool has_npot = !getGEConfig()->m_disable_npot_texture &&
|
bool has_npot = !getGEConfig()->m_disable_npot_texture &&
|
||||||
@ -40,6 +44,34 @@ video::IImage* getResizedImage(const std::string& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
} // getResizedImage
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
irr::video::ITexture* createTexture(const std::string& path,
|
||||||
|
std::function<void(irr::video::IImage*)> image_mani)
|
||||||
|
{
|
||||||
|
switch (GE::getDriver()->getDriverType())
|
||||||
|
{
|
||||||
|
case video::EDT_OPENGL:
|
||||||
|
case video::EDT_OGLES2:
|
||||||
|
return new GEGLTexture(path, image_mani);
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} // createTexture
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
irr::video::ITexture* createTexture(video::IImage* img,
|
||||||
|
const std::string& name)
|
||||||
|
{
|
||||||
|
switch (GE::getDriver()->getDriverType())
|
||||||
|
{
|
||||||
|
case video::EDT_OPENGL:
|
||||||
|
case video::EDT_OGLES2:
|
||||||
|
return new GEGLTexture(img, name);
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} // createTexture
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,7 @@ public:
|
|||||||
|
|
||||||
virtual void updateTexture(void* data, ECOLOR_FORMAT format, u32 w, u32 h, u32 x, u32 y) {}
|
virtual void updateTexture(void* data, ECOLOR_FORMAT format, u32 w, u32 h, u32 x, u32 y) {}
|
||||||
|
|
||||||
|
virtual void reload() {}
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Helper function, helps to get the desired texture creation format from the flags.
|
//! Helper function, helps to get the desired texture creation format from the flags.
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "graphics/glwrap.hpp"
|
#include "graphics/glwrap.hpp"
|
||||||
#include "graphics/rtts.hpp"
|
#include "graphics/rtts.hpp"
|
||||||
#include "graphics/shared_gpu_objects.hpp"
|
#include "graphics/shared_gpu_objects.hpp"
|
||||||
#include "graphics/stk_texture.hpp"
|
|
||||||
#include "graphics/stk_tex_manager.hpp"
|
#include "graphics/stk_tex_manager.hpp"
|
||||||
#include "graphics/texture_shader.hpp"
|
#include "graphics/texture_shader.hpp"
|
||||||
#include "graphics/weather.hpp"
|
#include "graphics/weather.hpp"
|
||||||
@ -48,6 +47,7 @@
|
|||||||
#include "utils/cpp2011.hpp"
|
#include "utils/cpp2011.hpp"
|
||||||
|
|
||||||
#include <SViewFrustum.h>
|
#include <SViewFrustum.h>
|
||||||
|
#include <ge_texture.hpp>
|
||||||
|
|
||||||
using namespace video;
|
using namespace video;
|
||||||
using namespace scene;
|
using namespace scene;
|
||||||
@ -749,7 +749,7 @@ PostProcessing::PostProcessing()
|
|||||||
createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33),
|
createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33),
|
||||||
"AreaMap33", false);
|
"AreaMap33", false);
|
||||||
video::IImage* img = irr_driver->getVideoDriver()->createImageFromFile(areamap);
|
video::IImage* img = irr_driver->getVideoDriver()->createImageFromFile(areamap);
|
||||||
m_areamap = new STKTexture(img, "AreaMap33");
|
m_areamap = GE::createTexture(img, "AreaMap33");
|
||||||
if (m_areamap->getTextureHandler() == 0)
|
if (m_areamap->getTextureHandler() == 0)
|
||||||
{
|
{
|
||||||
Log::fatal("postprocessing", "Failed to load the areamap");
|
Log::fatal("postprocessing", "Failed to load the areamap");
|
||||||
|
@ -26,11 +26,10 @@
|
|||||||
|
|
||||||
class FrameBuffer;
|
class FrameBuffer;
|
||||||
class RTT;
|
class RTT;
|
||||||
class STKTexture;
|
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace video { class IVideoDriver; }
|
namespace video { class IVideoDriver; class ITexture; }
|
||||||
namespace scene { class ICameraSceneNode; }
|
namespace scene { class ICameraSceneNode; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ private:
|
|||||||
* have a stronger effect. */
|
* have a stronger effect. */
|
||||||
std::vector<float> m_boost_time;
|
std::vector<float> m_boost_time;
|
||||||
|
|
||||||
STKTexture* m_areamap;
|
video::ITexture* m_areamap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostProcessing();
|
PostProcessing();
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#ifndef SERVER_ONLY
|
||||||
|
#include <ge_texture.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
STKTexManager::~STKTexManager()
|
STKTexManager::~STKTexManager()
|
||||||
@ -96,7 +99,7 @@ video::ITexture* STKTexManager::getTexture(const std::string& path)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
new_texture =
|
new_texture =
|
||||||
new STKTexture(full_path.empty() ? path : full_path, NULL);
|
GE::createTexture(full_path.empty() ? path : full_path);
|
||||||
}
|
}
|
||||||
if (new_texture->getTextureHandler() == 0)
|
if (new_texture->getTextureHandler() == 0)
|
||||||
{
|
{
|
||||||
|
@ -84,6 +84,16 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
int dumpTextureUsage();
|
int dumpTextureUsage();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void reloadAllTextures()
|
||||||
|
{
|
||||||
|
for (auto p : m_all_textures)
|
||||||
|
{
|
||||||
|
if (p.second == NULL)
|
||||||
|
continue;
|
||||||
|
p.second->reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the currently defined texture error message, which is used
|
/** Returns the currently defined texture error message, which is used
|
||||||
* by event_handler.cpp to print additional info about irrlicht
|
* by event_handler.cpp to print additional info about irrlicht
|
||||||
* internal errors or warnings. If no error message is currently
|
* internal errors or warnings. If no error message is currently
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "graphics/central_settings.hpp"
|
#include "graphics/central_settings.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/stk_tex_manager.hpp"
|
#include "graphics/stk_tex_manager.hpp"
|
||||||
#include "graphics/stk_texture.hpp"
|
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
@ -32,6 +31,9 @@
|
|||||||
#include <IGUIButton.h>
|
#include <IGUIButton.h>
|
||||||
#include <IGUIStaticText.h>
|
#include <IGUIStaticText.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#ifndef SERVER_ONLY
|
||||||
|
#include <ge_texture.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
using namespace irr::video;
|
using namespace irr::video;
|
||||||
@ -365,13 +367,8 @@ const video::ITexture* IconButtonWidget::getTexture()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture)
|
video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture)
|
||||||
{
|
{
|
||||||
#if !defined(SERVER_ONLY) && !defined(USE_GLES2)
|
#ifndef SERVER_ONLY
|
||||||
STKTexture* stk_tex = static_cast<STKTexture*>(texture);
|
std::string name = texture->getName().getPtr();
|
||||||
// Compressed texture can't be turned into greyscale
|
|
||||||
if (stk_tex->isMeshTexture() && CVS->isTextureCompressionEnabled())
|
|
||||||
return stk_tex;
|
|
||||||
|
|
||||||
std::string name = stk_tex->getName().getPtr();
|
|
||||||
name += "_disabled";
|
name += "_disabled";
|
||||||
STKTexManager* stkm = STKTexManager::getInstance();
|
STKTexManager* stkm = STKTexManager::getInstance();
|
||||||
if (!stkm->hasTexture(name))
|
if (!stkm->hasTexture(name))
|
||||||
@ -381,8 +378,8 @@ video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* textur
|
|||||||
|
|
||||||
video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
||||||
video::IImage* image = driver->createImageFromData
|
video::IImage* image = driver->createImageFromData
|
||||||
(video::ECF_A8R8G8B8, stk_tex->getSize(), stk_tex->lock(),
|
(video::ECF_A8R8G8B8, texture->getSize(), texture->lock(),
|
||||||
stk_tex->getTextureImage() == NULL/*ownForeignMemory*/);
|
true/*ownForeignMemory*/);
|
||||||
texture->unlock();
|
texture->unlock();
|
||||||
|
|
||||||
//Turn the image into grayscale
|
//Turn the image into grayscale
|
||||||
@ -396,12 +393,12 @@ video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* textur
|
|||||||
image->setPixel(x, y, c);
|
image->setPixel(x, y, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stkm->addTexture(new STKTexture(image, name));
|
return stkm->addTexture(GE::createTexture(image, name));
|
||||||
}
|
}
|
||||||
return stkm->getTexture(name);
|
return stkm->getTexture(name);
|
||||||
#else
|
#else
|
||||||
return texture;
|
return texture;
|
||||||
#endif // !SERVER_ONLY
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user