mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
yes
This commit is contained in:
7
runtime/Sources/Graphics/Font.cpp
git.filemode.normal_file
7
runtime/Sources/Graphics/Font.cpp
git.filemode.normal_file
@@ -0,0 +1,7 @@
|
||||
#include <PreCompiled.h>
|
||||
|
||||
#include <Graphics/Font.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
}
|
||||
@@ -5,26 +5,20 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, bool insert_new_texture, std::uint32_t color)
|
||||
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, std::uint64_t draw_layer, std::uint32_t color)
|
||||
{
|
||||
Verify((bool)p_renderer, "invalid renderer pointer");
|
||||
|
||||
VkExtent2D swapchain_extent = kvfGetSwapchainImagesSize(p_renderer->GetSwapchain());
|
||||
if(insert_new_texture)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Texture& texture = m_textures.emplace_back(CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(m_textures.size()));
|
||||
#else
|
||||
Texture& texture = m_textures.emplace_back(CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, std::string_view{});
|
||||
#endif
|
||||
texture.Clear(VK_NULL_HANDLE, Vec4f{ 0.0f });
|
||||
}
|
||||
if(!m_textures.empty())
|
||||
{
|
||||
m_textures.back().SetPixel(x, y, color);
|
||||
return (insert_new_texture ? &m_textures.back() : nullptr);
|
||||
}
|
||||
return nullptr;
|
||||
#ifdef DEBUG
|
||||
auto res = m_textures.try_emplace(draw_layer, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(draw_layer));
|
||||
#else
|
||||
auto res = m_textures.try_emplace(draw_layer, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, std::string_view{});
|
||||
#endif
|
||||
if(res.second)
|
||||
res.first->second.Clear(VK_NULL_HANDLE, Vec4f{ 0.0f });
|
||||
res.first->second.SetPixel(x, y, color);
|
||||
return (res.second ? &res.first->second : nullptr);
|
||||
}
|
||||
|
||||
void PutPixelManager::ResetRenderData()
|
||||
|
||||
@@ -8,6 +8,19 @@ namespace mlx
|
||||
Sprite& Scene::CreateSprite(NonOwningPtr<Texture> texture) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Verify((bool)texture, "Scene: invalid texture (internal mlx issue, please report to devs)");
|
||||
|
||||
#pragma omp parallel for
|
||||
for(auto& sprite : m_sprites)
|
||||
{
|
||||
if(texture->GetWidth() == sprite->GetTexture()->GetWidth() && texture->GetHeight() == sprite->GetTexture()->GetHeight())
|
||||
{
|
||||
std::shared_ptr<Sprite> new_sprite = std::make_shared<Sprite>(sprite->GetMesh(), texture);
|
||||
m_sprites.push_back(new_sprite);
|
||||
return *new_sprite;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Sprite> sprite = std::make_shared<Sprite>(texture);
|
||||
m_sprites.push_back(sprite);
|
||||
return *sprite;
|
||||
@@ -52,6 +65,7 @@ namespace mlx
|
||||
|
||||
bool Scene::IsTextureAtGivenDrawLayer(NonOwningPtr<Texture> texture, std::uint64_t draw_layer) const
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(draw_layer >= m_sprites.size())
|
||||
return false;
|
||||
return m_sprites[draw_layer]->GetTexture() == texture;
|
||||
|
||||
@@ -44,4 +44,13 @@ namespace mlx
|
||||
p_mesh = CreateQuad(0, 0, texture->GetWidth(), texture->GetHeight());
|
||||
p_texture = texture;
|
||||
}
|
||||
|
||||
Sprite::Sprite(std::shared_ptr<Mesh> mesh, NonOwningPtr<Texture> texture)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Verify((bool)texture, "Sprite: invalid texture (internal mlx issue, please report to devs)");
|
||||
Verify((bool)mesh, "Sprite: invalid mesh (internal mlx issue, please report to devs)");
|
||||
p_mesh = mesh;
|
||||
p_texture = texture;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user