mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
i dont know chat i did i was high as f*ck
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
|
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/16 06:41:48 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 08:03:37 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ int main(void)
|
|||||||
mlx_loop(mlx.mlx);
|
mlx_loop(mlx.mlx);
|
||||||
|
|
||||||
mlx_get_screens_size(mlx.mlx, &w, &h);
|
mlx_get_screens_size(mlx.mlx, &w, &h);
|
||||||
printf("screen size : %dx%d", w, h);
|
printf("screen size : %dx%d\n", w, h);
|
||||||
|
|
||||||
mlx_destroy_image(mlx.mlx, mlx.logo_png);
|
mlx_destroy_image(mlx.mlx, mlx.logo_png);
|
||||||
mlx_destroy_image(mlx.mlx, mlx.logo_jpg);
|
mlx_destroy_image(mlx.mlx, mlx.logo_jpg);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/10 19:54:51 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 08:20:17 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ extern "C"
|
|||||||
if (filepath == nullptr)
|
if (filepath == nullptr)
|
||||||
{
|
{
|
||||||
mlx::core::error::report(e_kind::error, "Font loader : filepath is NULL");
|
mlx::core::error::report(e_kind::error, "Font loader : filepath is NULL");
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
std::filesystem::path file(filepath);
|
std::filesystem::path file(filepath);
|
||||||
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
||||||
@@ -237,7 +237,7 @@ extern "C"
|
|||||||
if (filepath == nullptr)
|
if (filepath == nullptr)
|
||||||
{
|
{
|
||||||
mlx::core::error::report(e_kind::error, "Font loader : filepath is NULL");
|
mlx::core::error::report(e_kind::error, "Font loader : filepath is NULL");
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
std::filesystem::path file(filepath);
|
std::filesystem::path file(filepath);
|
||||||
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/05 16:30:19 by maldavid #+# #+# */
|
/* Created: 2022/10/05 16:30:19 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/11 19:08:23 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 07:59:15 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "inputs.h"
|
#include "inputs.h"
|
||||||
#include <mlx.h>
|
#include <mlx.h>
|
||||||
#include <cstring>
|
|
||||||
#include <core/profiler.h>
|
#include <core/profiler.h>
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
|
|||||||
@@ -6,15 +6,14 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */
|
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/12/11 19:47:20 by vavaas ### ########.fr */
|
/* Updated: 2024/01/16 07:59:08 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <function.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@@ -26,7 +25,7 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
struct Hook
|
struct Hook
|
||||||
{
|
{
|
||||||
std::function<int(int, void*)> hook;
|
func::function<int(int, void*)> hook;
|
||||||
void* param = nullptr;
|
void* param = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
|
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/12/27 16:57:28 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 07:59:21 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include <platform/window.h>
|
#include <platform/window.h>
|
||||||
#include <core/errors.h>
|
#include <core/errors.h>
|
||||||
#include <utils/icon_mlx.h>
|
#include <utils/icon_mlx.h>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/12/18 21:27:38 by maldavid #+# #+# */
|
/* Created: 2022/12/18 21:27:38 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/10 21:53:38 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 07:45:15 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace mlx
|
|||||||
gl_Position = uProj.mat * vec4(pos.x, pos.y, 0.0, 1.0);
|
gl_Position = uProj.mat * vec4(pos.x, pos.y, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const std::vector<uint32_t> vertex_shader = {
|
const std::vector<uint32_t> vertex_shader = { // precompiled vertex shader
|
||||||
0x07230203,0x00010000,0x0008000b,0x0000003b,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x0008000b,0x0000003b,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015,
|
0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015,
|
||||||
@@ -124,7 +124,7 @@ namespace mlx
|
|||||||
fColor = process_color;
|
fColor = process_color;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const std::vector<uint32_t> fragment_shader = {
|
const std::vector<uint32_t> fragment_shader = { // pre compiled fragment shader
|
||||||
0x07230203,0x00010000,0x0008000b,0x0000002c,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x0008000b,0x0000002c,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x0000002a,0x00030010,
|
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x0000002a,0x00030010,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/12/18 17:25:16 by maldavid #+# #+# */
|
/* Created: 2022/12/18 17:25:16 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/16 07:14:19 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 08:02:57 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -82,12 +82,7 @@ namespace mlx
|
|||||||
|
|
||||||
if(result == VK_ERROR_OUT_OF_DATE_KHR)
|
if(result == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
{
|
{
|
||||||
_swapchain.recreate();
|
recreateRenderData();
|
||||||
_pass.destroy();
|
|
||||||
_pass.init(_swapchain.getImagesFormat(), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
|
|
||||||
_framebuffers.clear();
|
|
||||||
for(std::size_t i = 0; i < _swapchain.getImagesNumber(); i++)
|
|
||||||
_framebuffers.emplace_back().init(_pass, _swapchain.getImage(i));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if(result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR)
|
else if(result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR)
|
||||||
@@ -150,12 +145,7 @@ namespace mlx
|
|||||||
if(result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || _framebufferResized)
|
if(result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || _framebufferResized)
|
||||||
{
|
{
|
||||||
_framebufferResized = false;
|
_framebufferResized = false;
|
||||||
_swapchain.recreate();
|
recreateRenderData();
|
||||||
_pass.destroy();
|
|
||||||
_pass.init(_swapchain.getImagesFormat(), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
|
|
||||||
_framebuffers.clear();
|
|
||||||
for(std::size_t i = 0; i < _swapchain.getImagesNumber(); i++)
|
|
||||||
_framebuffers.emplace_back().init(_pass, _swapchain.getImage(i));
|
|
||||||
}
|
}
|
||||||
else if(result != VK_SUCCESS)
|
else if(result != VK_SUCCESS)
|
||||||
core::error::report(e_kind::fatal_error, "Vulkan error : failed to present swap chain image");
|
core::error::report(e_kind::fatal_error, "Vulkan error : failed to present swap chain image");
|
||||||
@@ -168,6 +158,18 @@ namespace mlx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::recreateRenderData()
|
||||||
|
{
|
||||||
|
_swapchain.recreate();
|
||||||
|
_pass.destroy();
|
||||||
|
_pass.init(_swapchain.getImagesFormat(), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
|
||||||
|
for(auto& fb : _framebuffers)
|
||||||
|
fb.destroy();
|
||||||
|
_framebuffers.clear();
|
||||||
|
for(std::size_t i = 0; i < _swapchain.getImagesNumber(); i++)
|
||||||
|
_framebuffers.emplace_back().init(_pass, _swapchain.getImage(i));
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::destroy()
|
void Renderer::destroy()
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */
|
/* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/12/22 21:59:15 by kbz_8 ### ########.fr */
|
/* Updated: 2024/01/16 08:01:25 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -113,6 +113,9 @@ namespace mlx
|
|||||||
|
|
||||||
~Renderer() = default;
|
~Renderer() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void recreateRenderData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GraphicPipeline _pipeline;
|
GraphicPipeline _pipeline;
|
||||||
CmdManager _cmd;
|
CmdManager _cmd;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/06 18:21:36 by maldavid #+# #+# */
|
/* Created: 2022/10/06 18:21:36 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/10 21:53:03 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 08:22:39 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
static const VkClearValue clearColor = {{{ 0.0f, 0.0f, 0.0f, 1.0f }}}; // wtf, this mess to satisfy a warning
|
static const VkClearValue clearColor = {{{ 0.f, 0.f, 0.f, 1.0f }}}; // wtf, this mess to satisfy a warning
|
||||||
|
|
||||||
void RenderPass::init(VkFormat attachement_format, VkImageLayout layout)
|
void RenderPass::init(VkFormat attachement_format, VkImageLayout layout)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/12/11 22:06:09 by kbz_8 #+# #+# */
|
/* Created: 2023/12/11 22:06:09 by kbz_8 #+# #+# */
|
||||||
/* Updated: 2024/01/11 01:23:20 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 09:11:26 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ constexpr const int RANGE = 1024;
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
Font::Font(Renderer& renderer, const std::filesystem::path& path, float scale) : non_copyable(), _name(path.string()), _scale(scale)
|
Font::Font(Renderer& renderer, const std::filesystem::path& path, float scale) : _name(path.string()), _scale(scale)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
|
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
|
||||||
@@ -56,7 +56,7 @@ namespace mlx
|
|||||||
_atlas.setDescriptor(renderer.getFragDescriptorSet().duplicate());
|
_atlas.setDescriptor(renderer.getFragDescriptorSet().duplicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
Font::Font(class Renderer& renderer, const std::string& name, const std::vector<uint8_t>& ttf_data, float scale) : non_copyable(), _name(name), _scale(scale)
|
Font::Font(class Renderer& renderer, const std::string& name, const std::vector<uint8_t>& ttf_data, float scale) : _name(name), _scale(scale)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
|
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/12/11 21:17:04 by kbz_8 #+# #+# */
|
/* Created: 2023/12/11 21:17:04 by kbz_8 #+# #+# */
|
||||||
/* Updated: 2024/01/11 20:08:55 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 09:14:53 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -15,13 +15,12 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <stb_truetype.h>
|
#include <stb_truetype.h>
|
||||||
#include <utils/non_copyable.h>
|
|
||||||
#include <renderer/images/texture_atlas.h>
|
#include <renderer/images/texture_atlas.h>
|
||||||
#include <utils/combine_hash.h>
|
#include <utils/combine_hash.h>
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
class Font : public non_copyable
|
class Font
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Font() = delete;
|
Font() = delete;
|
||||||
@@ -32,7 +31,7 @@ namespace mlx
|
|||||||
inline const std::array<stbtt_packedchar, 96>& getCharData() const { return _cdata; }
|
inline const std::array<stbtt_packedchar, 96>& getCharData() const { return _cdata; }
|
||||||
inline const TextureAtlas& getAtlas() const noexcept { return _atlas; }
|
inline const TextureAtlas& getAtlas() const noexcept { return _atlas; }
|
||||||
inline bool operator==(const Font& rhs) const { return rhs._name == _name && rhs._scale == _scale; }
|
inline bool operator==(const Font& rhs) const { return rhs._name == _name && rhs._scale == _scale; }
|
||||||
inline bool operator!=(const Font& rhs) const { return rhs._name != _name && rhs._scale != _scale; }
|
inline bool operator!=(const Font& rhs) const { return rhs._name != _name || rhs._scale != _scale; }
|
||||||
~Font();
|
~Font();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -43,18 +42,4 @@ namespace mlx
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
template <>
|
|
||||||
struct hash<mlx::Font>
|
|
||||||
{
|
|
||||||
std::size_t operator()(const mlx::Font& f) const noexcept
|
|
||||||
{
|
|
||||||
std::size_t hash = 0;
|
|
||||||
mlx::hashCombine(hash, f.getName(), f.getScale());
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */
|
/* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/11 05:19:24 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 08:54:22 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <renderer/texts/text_library.h>
|
#include <renderer/texts/text_library.h>
|
||||||
#include <renderer/texts/text.h>
|
#include <renderer/texts/text.h>
|
||||||
#include <core/errors.h>
|
#include <core/errors.h>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
|
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/11 05:08:04 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 08:54:15 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include <renderer/buffers/vk_vbo.h>
|
#include <renderer/buffers/vk_vbo.h>
|
||||||
#include <renderer/buffers/vk_ibo.h>
|
#include <renderer/buffers/vk_ibo.h>
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */
|
/* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/11 04:54:16 by maldavid ### ########.fr */
|
/* Updated: 2024/01/17 03:47:46 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -14,28 +14,34 @@
|
|||||||
#include <renderer/texts/text_library.h>
|
#include <renderer/texts/text_library.h>
|
||||||
#include <renderer/texts/text.h>
|
#include <renderer/texts/text.h>
|
||||||
#include <renderer/texts/text_manager.h>
|
#include <renderer/texts/text_manager.h>
|
||||||
#include <array>
|
|
||||||
#include <core/profiler.h>
|
#include <core/profiler.h>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <utils/dogica_ttf.h>
|
#include <utils/dogica_ttf.h>
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
void TextManager::init(Renderer& renderer) noexcept
|
void TextManager::init(Renderer& renderer) noexcept
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
_font_in_use = &const_cast<Font&>(*_font_set.emplace(renderer, "default", dogica_ttf, 6.0f).first);
|
loadFont(renderer, "default", 6.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextManager::loadFont(Renderer& renderer, const std::filesystem::path& filepath, float scale)
|
void TextManager::loadFont(Renderer& renderer, const std::filesystem::path& filepath, float scale)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
if(filepath.string() == "default") // we're sure it is already loaded
|
for(Font& font : _font_set)
|
||||||
_font_in_use = &const_cast<Font&>(*_font_set.emplace(renderer, "default", dogica_ttf, scale).first);
|
{
|
||||||
|
if(filepath == font.getName() && scale == font.getScale())
|
||||||
|
{
|
||||||
|
_font_in_use = &font;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filepath.string() == "default")
|
||||||
|
_font_in_use = &_font_set.emplace_back(renderer, "default", dogica_ttf, scale);
|
||||||
else
|
else
|
||||||
_font_in_use = &const_cast<Font&>(*_font_set.emplace(renderer, filepath, scale).first);
|
_font_in_use = &_font_set.emplace_back(renderer, filepath, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<DrawableResource*, bool> TextManager::registerText(int x, int y, uint32_t color, std::string str)
|
std::pair<DrawableResource*, bool> TextManager::registerText(int x, int y, uint32_t color, std::string str)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */
|
/* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/11 18:48:01 by maldavid ### ########.fr */
|
/* Updated: 2024/01/16 09:04:05 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <stb_truetype.h>
|
#include <stb_truetype.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
#include <mlx_profile.h>
|
#include <mlx_profile.h>
|
||||||
#include <renderer/texts/text_descriptor.h>
|
#include <renderer/texts/text_descriptor.h>
|
||||||
#include <renderer/texts/text_library.h>
|
#include <renderer/texts/text_library.h>
|
||||||
@@ -40,7 +41,7 @@ namespace mlx
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<TextDrawDescriptor> _text_descriptors;
|
std::unordered_set<TextDrawDescriptor> _text_descriptors;
|
||||||
std::unordered_set<Font> _font_set;
|
std::vector<Font> _font_set;
|
||||||
Font* _font_in_use = nullptr;
|
Font* _font_in_use = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user