diff --git a/example/main.c b/example/main.c index b8358dd..c839c45 100644 --- a/example/main.c +++ b/example/main.c @@ -129,7 +129,6 @@ int main(void) int dummy; mlx.mlx = mlx_init(); - mlx_new_window(mlx.mlx, 400, 400, mlx.mlx); mlx.win = mlx_new_window(mlx.mlx, 400, 400, "My window"); mlx_set_fps_goal(mlx.mlx, 60); diff --git a/runtime/Includes/Graphics/Text.h b/runtime/Includes/Graphics/Text.h new file mode 100644 index 0000000..6c17c60 --- /dev/null +++ b/runtime/Includes/Graphics/Text.h @@ -0,0 +1,26 @@ +#ifndef __MLX_TEXT__ +#define __MLX_TEXT__ + +#include + +namespace mlx +{ + class Text + { + public: + Text(const std::string& text, std::shared_ptr font); + + [[nodiscard]] inline const std::string& GetText() const { return m_text; } + [[nodiscard]] inline std::shared_ptr GetFont() const { return p_font; } + [[nodiscard]] MLX_FORCEINLINE std::uint32_t GetColor() const noexcept { return m_color; } + + ~Text(); + + private: + std::shared_ptr p_font; + std::string m_text; + std::uint32_t m_color; + }; +} + +#endif diff --git a/runtime/Sources/Core/Application.cpp b/runtime/Sources/Core/Application.cpp index 52bd0d6..9f894c2 100644 --- a/runtime/Sources/Core/Application.cpp +++ b/runtime/Sources/Core/Application.cpp @@ -10,6 +10,7 @@ namespace mlx { Application::Application() : p_mem_manager(std::make_unique()), p_sdl_manager(std::make_unique()), m_fps(), m_in() { + MLX_PROFILE_FUNCTION(); std::srand(std::time(nullptr)); EventBus::RegisterListener({ [](const EventBase& event) { @@ -71,7 +72,7 @@ namespace mlx void Application::DestroyTexture(void* ptr) { MLX_PROFILE_FUNCTION(); - RenderCore::Get().WaitDeviceIdle(); // TODO : synchronize with another method than waiting for GPU to be idle + RenderCore::Get().WaitDeviceIdle(); if(!m_image_registry.IsTextureKnown(static_cast(ptr))) { Error("invalid image ptr"); @@ -84,7 +85,6 @@ namespace mlx else texture->Destroy(); - #pragma omp parallel for for(auto& gs : m_graphics) { if(gs) @@ -96,12 +96,12 @@ namespace mlx Application::~Application() { - #pragma omp parallel for for(auto& window : m_graphics) { - if(window->GetWindow()->GetName() == "让我们在月光下做爱吧") + if(window && window->GetWindow()->GetName() == "让我们在月光下做爱吧") window.reset(); } + p_render_core.reset(); p_sdl_manager.reset(); #ifdef PROFILER