Add loadingFailed function for ITexture
This commit is contained in:
parent
d6db020bfe
commit
d60a3a7c0c
@ -30,14 +30,20 @@ GEDX9Texture::GEDX9Texture(video::IImage* img, const std::string& name)
|
||||
{
|
||||
getDevice9();
|
||||
if (!m_device_9 || !img)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
uint8_t* data = NULL;
|
||||
m_size = m_orig_size = img->getDimension();
|
||||
HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height,
|
||||
0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
|
||||
&m_texture_9, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LoadingFailed = true;
|
||||
goto exit;
|
||||
}
|
||||
data = (uint8_t*)img->lock();
|
||||
upload(data);
|
||||
exit:
|
||||
@ -53,7 +59,10 @@ GEDX9Texture::GEDX9Texture(const std::string& name, unsigned int size)
|
||||
{
|
||||
getDevice9();
|
||||
if (!m_device_9)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
m_orig_size.Width = size;
|
||||
m_orig_size.Height = size;
|
||||
m_size = m_orig_size;
|
||||
@ -61,7 +70,10 @@ GEDX9Texture::GEDX9Texture(const std::string& name, unsigned int size)
|
||||
0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
|
||||
&m_texture_9, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
std::vector<uint8_t> data;
|
||||
data.resize(size * size * 4, 0);
|
||||
upload(data.data());
|
||||
@ -87,12 +99,22 @@ void GEDX9Texture::getDevice9()
|
||||
// ----------------------------------------------------------------------------
|
||||
void GEDX9Texture::reload()
|
||||
{
|
||||
if (!m_device_9 || m_disable_reload)
|
||||
if (m_disable_reload)
|
||||
return;
|
||||
|
||||
if (!m_device_9)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
video::IImage* texture_image = getResizedImage(NamedPath.getPtr(),
|
||||
m_max_size, &m_orig_size);
|
||||
if (texture_image == NULL)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
m_size = texture_image->getDimension();
|
||||
if (m_image_mani)
|
||||
m_image_mani(texture_image);
|
||||
@ -106,7 +128,10 @@ void GEDX9Texture::reload()
|
||||
0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
|
||||
&m_texture_9, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LoadingFailed = true;
|
||||
goto exit;
|
||||
}
|
||||
upload(data);
|
||||
exit:
|
||||
texture_image->unlock();
|
||||
|
@ -34,7 +34,10 @@ GEGLTexture::GEGLTexture(video::IImage* img, const std::string& name)
|
||||
m_disable_reload(true), m_single_channel(false)
|
||||
{
|
||||
if (!img)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
glGenTextures(1, &m_texture_name);
|
||||
m_size = m_orig_size = img->getDimension();
|
||||
uint8_t* data = (uint8_t*)img->lock();
|
||||
@ -94,7 +97,10 @@ void GEGLTexture::reload()
|
||||
video::IImage* texture_image = getResizedImage(NamedPath.getPtr(),
|
||||
m_max_size, &m_orig_size);
|
||||
if (texture_image == NULL)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
m_size = texture_image->getDimension();
|
||||
if (m_image_mani)
|
||||
m_image_mani(texture_image);
|
||||
|
@ -35,7 +35,10 @@ GEVulkanTexture::GEVulkanTexture(video::IImage* img, const std::string& name)
|
||||
m_disable_reload(true), m_single_channel(false)
|
||||
{
|
||||
if (!img)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
m_size = m_orig_size = img->getDimension();
|
||||
uint8_t* data = (uint8_t*)img->lock();
|
||||
upload(data);
|
||||
@ -329,7 +332,10 @@ void GEVulkanTexture::reloadInternal()
|
||||
video::IImage* texture_image = getResizedImage(NamedPath.getPtr(),
|
||||
m_max_size, &m_orig_size);
|
||||
if (texture_image == NULL)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
return;
|
||||
}
|
||||
m_size = texture_image->getDimension();
|
||||
if (m_image_mani)
|
||||
m_image_mani(texture_image);
|
||||
|
@ -100,7 +100,7 @@ class ITexture : public virtual IReferenceCounted
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
ITexture(const io::path& name) : NamedPath(name)
|
||||
ITexture(const io::path& name) : NamedPath(name), LoadingFailed(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -202,6 +202,8 @@ public:
|
||||
virtual void updateTexture(void* data, ECOLOR_FORMAT format, u32 w, u32 h, u32 x, u32 y) {}
|
||||
|
||||
virtual void reload() {}
|
||||
|
||||
virtual bool loadingFailed() const { return LoadingFailed; }
|
||||
protected:
|
||||
|
||||
//! Helper function, helps to get the desired texture creation format from the flags.
|
||||
@ -221,6 +223,7 @@ protected:
|
||||
}
|
||||
|
||||
io::SNamedPath NamedPath;
|
||||
bool LoadingFailed;
|
||||
};
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ video::ITexture* STKTexManager::getTexture(const std::string& path,
|
||||
GE::createTexture(full_path.empty() ? path : full_path,
|
||||
image_mani);
|
||||
}
|
||||
if (new_texture->getTextureHandler() == 0)
|
||||
if (new_texture->loadingFailed())
|
||||
{
|
||||
const char* name = new_texture->getName().getPtr();
|
||||
if (!m_texture_error_message.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user