mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
new text management, texts and textures are on the same level, new texture rendering management, fixing issues
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <core/graphics.h>
|
||||
#include <type_traits>
|
||||
#include <iostream>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -21,9 +21,10 @@ namespace mlx
|
||||
void GraphicsSupport::clearRenderData() noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
_textures_to_render.clear();
|
||||
_drawlist.clear();
|
||||
_pixel_put_pipeline.clear();
|
||||
_text_put_pipeline->clear();
|
||||
_text_manager.clear();
|
||||
_texture_manager.clear();
|
||||
}
|
||||
|
||||
void GraphicsSupport::pixelPut(int x, int y, uint32_t color) noexcept
|
||||
@@ -35,21 +36,32 @@ namespace mlx
|
||||
void GraphicsSupport::stringPut(int x, int y, uint32_t color, std::string str)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
_text_put_pipeline->put(x, y, color, str);
|
||||
std::pair<DrawableResource*, bool> res = _text_manager.registerText(x, y, color, str);
|
||||
if(!res.second) // if this is not a completly new text draw
|
||||
{
|
||||
auto it = std::find(_drawlist.begin(), _drawlist.end(), res.first);
|
||||
if(it != _drawlist.end())
|
||||
_drawlist.erase(it);
|
||||
}
|
||||
_drawlist.push_back(res.first);
|
||||
}
|
||||
|
||||
void GraphicsSupport::texturePut(Texture* texture, int x, int y)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
_textures_to_render.emplace_back(texture, x, y);
|
||||
auto it = std::find(_textures_to_render.begin(), _textures_to_render.end() - 1, _textures_to_render.back());
|
||||
if(it != _textures_to_render.end() - 1)
|
||||
_textures_to_render.erase(it);
|
||||
auto res = _texture_manager.registerTexture(texture, x, y);
|
||||
if(!res.second) // if this is not a completly new texture draw
|
||||
{
|
||||
auto it = std::find(_drawlist.begin(), _drawlist.end(), res.first);
|
||||
if(it != _drawlist.end())
|
||||
_drawlist.erase(it);
|
||||
}
|
||||
_drawlist.push_back(res.first);
|
||||
}
|
||||
|
||||
void GraphicsSupport::loadFont(const std::filesystem::path& filepath, float scale)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
_text_put_pipeline->loadFont(filepath, scale);
|
||||
_text_manager.loadFont(*_renderer, filepath, scale);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user