implemented TileMap, still need Shader for it with billboarding and all that jizz XD

This commit is contained in:
2026-02-02 20:52:28 +01:00
parent 2f3fdf83ae
commit ea2dc4f6b5
7 changed files with 130 additions and 81 deletions

View File

@@ -199,84 +199,6 @@ TSE::Texture TSE::Texture::CutOut(const Vector2 &pos, Vector2 &size) const
return out;
}
TSE::Texture TSE::Texture::Upscale(const Vector2 &size) const
{
Texture result = Texture(0,0);
if(bmp == nullptr)
{
TSE_ERROR("Failed to upscale texture. Source bitmap was nullptr.");
Texture::makeError(result);
return result;
}
const int width = static_cast<int>(size.x);
const int height = static_cast<int>(size.y);
if(width <= 0 || height <= 0)
{
TSE_ERROR("Failed to upscale texture. Size must be greater than 0.");
Texture::makeError(result);
return result;
}
FIBITMAP* scaled = FreeImage_Rescale(bmp, width, height, FILTER_NEAREST);
if(scaled == nullptr)
{
TSE_ERROR("Failed to upscale texture. FreeImage_Rescale returned nullptr.");
Texture::makeError(result);
return result;
}
Texture out = Texture(width, height, Bpp);
if(out.bmp != nullptr)
FreeImage_Unload(out.bmp);
out.bmp = scaled;
out.imagePtr = FreeImage_GetBits(scaled);
out.Bpp = Bpp;
out.chanels = chanels;
out.Size = Vector2(width, height);
out.Apply();
return out;
}
TSE::Texture TSE::Texture::Downscale(const Vector2 &size) const
{
Texture result = Texture(0,0);
if(bmp == nullptr)
{
TSE_ERROR("Failed to downscale texture. Source bitmap was nullptr.");
Texture::makeError(result);
return result;
}
const int width = static_cast<int>(size.x);
const int height = static_cast<int>(size.y);
if(width <= 0 || height <= 0)
{
TSE_ERROR("Failed to downscale texture. Size must be greater than 0.");
Texture::makeError(result);
return result;
}
FIBITMAP* scaled = FreeImage_Rescale(bmp, width, height, FILTER_NEAREST);
if(scaled == nullptr)
{
TSE_ERROR("Failed to downscale texture. FreeImage_Rescale returned nullptr.");
Texture::makeError(result);
return result;
}
Texture out = Texture(width, height, Bpp);
if(out.bmp != nullptr)
FreeImage_Unload(out.bmp);
out.bmp = scaled;
out.imagePtr = FreeImage_GetBits(scaled);
out.Bpp = Bpp;
out.chanels = chanels;
out.Size = Vector2(width, height);
out.Apply();
return out;
}
void TSE::Texture::PasteIn(const Vector2 &pos, Texture &t)
{
if(bmp == nullptr)

View File

@@ -39,8 +39,6 @@ namespace TSE
void SetPixel(const Vector2& pos, const Color& c);
void GetPixel(const Vector2& pos, Color& c) const;
Texture CutOut(const Vector2& pos, Vector2& size) const;
Texture Upscale(const Vector2& size) const;
Texture Downscale(const Vector2& size) const;
void PasteIn(const Vector2& pos, Texture& t);
void SetPixelNoApply(const Vector2& pos, const Color& c);
void ToSprite(Sprite& s);

View File

@@ -23,7 +23,7 @@ namespace TSE
{
SetCount(v.x, v.y);
};
inline void GetSpriteAt(Vector2& v, Sprite& s)
inline void GetSpriteAt(const Vector2& v, Sprite& s)
{
GetSpriteAt(v.x, v.y, s);
};