Add server dummy texture
This commit is contained in:
parent
964bb95445
commit
85843433c0
55
src/graphics/server_dummy_texture.hpp
Normal file
55
src/graphics/server_dummy_texture.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef HEADER_SERVER_DUMMY_TEXTURE_HPP
|
||||
#define HEADER_SERVER_DUMMY_TEXTURE_HPP
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <ITexture.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
class ServerDummyTexture : public video::ITexture, NoCopy
|
||||
{
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
ServerDummyTexture(const std::string& p) : video::ITexture(p.c_str()) {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual ~ServerDummyTexture() {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void* lock(video::E_TEXTURE_LOCK_MODE mode =
|
||||
video::ETLM_READ_WRITE, u32 mipmap_level = 0)
|
||||
{ return NULL; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void unlock() {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual const core::dimension2d<u32>& getOriginalSize() const
|
||||
{
|
||||
static core::dimension2d<u32> dummy;
|
||||
return dummy;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual const core::dimension2d<u32>& getSize() const
|
||||
{
|
||||
return getOriginalSize();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual video::E_DRIVER_TYPE getDriverType() const
|
||||
{
|
||||
return video::EDT_NULL;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual video::ECOLOR_FORMAT getColorFormat() const
|
||||
{ return video::ECF_A8R8G8B8; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual u32 getPitch() const { return 0; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool hasMipMaps() const { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void regenerateMipMapLevels(void* mipmap_data = NULL) {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual u64 getTextureHandler() const { return 1; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual unsigned int getTextureSize() const { return 0; }
|
||||
}; // ServerDummyTexture
|
||||
|
||||
#endif
|
@ -20,6 +20,9 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/stk_texture.hpp"
|
||||
#include "graphics/server_dummy_texture.hpp"
|
||||
#include "graphics/stk_texture.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@ -33,7 +36,7 @@ STKTexManager::~STKTexManager()
|
||||
} // ~STKTexManager
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
STKTexture* STKTexManager::findTextureInFileSystem(const std::string& filename,
|
||||
video::ITexture* STKTexManager::findTextureInFileSystem(const std::string& filename,
|
||||
std::string* full_path)
|
||||
{
|
||||
io::path relative_path = file_manager->searchTexture(filename).c_str();
|
||||
@ -70,7 +73,7 @@ video::ITexture* STKTexManager::getTexture(const std::string& path)
|
||||
if (ret != m_all_textures.end())
|
||||
return ret->second;
|
||||
|
||||
STKTexture* new_texture = NULL;
|
||||
video::ITexture* new_texture = NULL;
|
||||
std::string full_path;
|
||||
if (path.find('/') == std::string::npos)
|
||||
{
|
||||
@ -81,7 +84,20 @@ video::ITexture* STKTexManager::getTexture(const std::string& path)
|
||||
return new_texture;
|
||||
}
|
||||
|
||||
new_texture = new STKTexture(full_path.empty() ? path : full_path, NULL);
|
||||
#ifdef SERVER_ONLY
|
||||
new_texture =
|
||||
new ServerDummyTexture(full_path.empty() ? path : full_path);
|
||||
#else
|
||||
if (GUIEngine::isNoGraphics())
|
||||
{
|
||||
new_texture =
|
||||
new ServerDummyTexture(full_path.empty() ? path : full_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_texture =
|
||||
new STKTexture(full_path.empty() ? path : full_path, NULL);
|
||||
}
|
||||
if (new_texture->getTextureHandler() == 0)
|
||||
{
|
||||
const char* name = new_texture->getName().getPtr();
|
||||
@ -96,20 +112,21 @@ video::ITexture* STKTexManager::getTexture(const std::string& path)
|
||||
delete new_texture;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
addTexture(new_texture);
|
||||
return new_texture;
|
||||
} // getTexture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
video::ITexture* STKTexManager::addTexture(STKTexture* texture)
|
||||
video::ITexture* STKTexManager::addTexture(video::ITexture* texture)
|
||||
{
|
||||
m_all_textures[texture->getName().getPtr()] = texture;
|
||||
return texture;
|
||||
} // addTexture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void STKTexManager::removeTexture(STKTexture* texture, bool remove_all)
|
||||
void STKTexManager::removeTexture(video::ITexture* texture, bool remove_all)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::vector<std::string> undeleted_texture;
|
||||
|
@ -59,14 +59,14 @@ struct TexConfig
|
||||
class STKTexManager : public Singleton<STKTexManager>, NoCopy
|
||||
{
|
||||
private:
|
||||
std::unordered_map<std::string, STKTexture*> m_all_textures;
|
||||
std::unordered_map<std::string, irr::video::ITexture*> m_all_textures;
|
||||
|
||||
/** Additional details to be shown in case that a texture is not found.
|
||||
* This is used to specify details like: "while loading kart '...'" */
|
||||
std::string m_texture_error_message;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
STKTexture* findTextureInFileSystem(const std::string& filename,
|
||||
irr::video::ITexture* findTextureInFileSystem(const std::string& filename,
|
||||
std::string* full_path);
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
@ -76,11 +76,11 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
irr::video::ITexture* getTexture(const std::string& path);
|
||||
// ------------------------------------------------------------------------
|
||||
irr::video::ITexture* addTexture(STKTexture* texture);
|
||||
irr::video::ITexture* addTexture(irr::video::ITexture* texture);
|
||||
// ------------------------------------------------------------------------
|
||||
bool hasTexture(const std::string& path);
|
||||
// ------------------------------------------------------------------------
|
||||
void removeTexture(STKTexture* texture, bool remove_all = false);
|
||||
void removeTexture(irr::video::ITexture* texture, bool remove_all = false);
|
||||
// ------------------------------------------------------------------------
|
||||
int dumpTextureUsage();
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user