mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Add a method to create an empty texture
This commit is contained in:
parent
04bc9ed5e0
commit
dcbfd5cc35
@ -212,14 +212,57 @@ CPixmap::ReloadTargetTextures ()
|
|||||||
if (!tex.second.target)
|
if (!tex.second.target)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!Cache (
|
if (tex.second.file.empty ())
|
||||||
tex.first, tex.second.file, tex.second.dimTotal, tex.second.dimIcon))
|
{
|
||||||
|
if (!Cache (tex.first, tex.second.dimTotal))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!Cache (
|
||||||
|
tex.first, tex.second.file, tex.second.dimTotal,
|
||||||
|
tex.second.dimIcon))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPixmap::Cache (size_t channel, Point totalDim)
|
||||||
|
{
|
||||||
|
if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ())
|
||||||
|
{
|
||||||
|
m_SDLTextureInfo[channel].texture = SDL_CreateTexture (
|
||||||
|
g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, totalDim.x,
|
||||||
|
totalDim.y);
|
||||||
|
|
||||||
|
if (!m_SDLTextureInfo[channel].texture)
|
||||||
|
{
|
||||||
|
SDL_LogError (
|
||||||
|
SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s",
|
||||||
|
SDL_GetError ());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetTextureBlendMode (
|
||||||
|
m_SDLTextureInfo[channel].texture, SDL_BLENDMODE_BLEND);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetRenderTarget (g_renderer, m_SDLTextureInfo[channel].texture);
|
||||||
|
SDL_SetRenderDrawColor (g_renderer, 0, 0, 0, 0);
|
||||||
|
SDL_RenderClear (g_renderer);
|
||||||
|
SDL_SetRenderTarget (g_renderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_SDLTextureInfo[channel].texMask = nullptr;
|
||||||
|
m_SDLTextureInfo[channel].target = true;
|
||||||
|
m_SDLTextureInfo[channel].dimIcon = Point{0, 0};
|
||||||
|
m_SDLTextureInfo[channel].dimTotal = totalDim;
|
||||||
|
m_SDLTextureInfo[channel].file = "";
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Cache une image contenant des ic�nes.
|
// Cache une image contenant des ic�nes.
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
bool Create (Point dim);
|
bool Create (Point dim);
|
||||||
|
|
||||||
bool ReloadTargetTextures ();
|
bool ReloadTargetTextures ();
|
||||||
|
bool Cache (size_t channel, Point totalDim);
|
||||||
bool Cache (
|
bool Cache (
|
||||||
size_t channel, const std::string & pFilename, Point totalDim,
|
size_t channel, const std::string & pFilename, Point totalDim,
|
||||||
Point iconDim);
|
Point iconDim);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user