This commit is contained in:
Kbz-8
2024-10-24 19:13:02 +02:00
parent cfb41b7b27
commit da85343e32
3 changed files with 30 additions and 5 deletions

View File

@@ -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);

26
runtime/Includes/Graphics/Text.h git.filemode.normal_file
View File

@@ -0,0 +1,26 @@
#ifndef __MLX_TEXT__
#define __MLX_TEXT__
#include <Graphics/Font.h>
namespace mlx
{
class Text
{
public:
Text(const std::string& text, std::shared_ptr<Font> font);
[[nodiscard]] inline const std::string& GetText() const { return m_text; }
[[nodiscard]] inline std::shared_ptr<Font> GetFont() const { return p_font; }
[[nodiscard]] MLX_FORCEINLINE std::uint32_t GetColor() const noexcept { return m_color; }
~Text();
private:
std::shared_ptr<Font> p_font;
std::string m_text;
std::uint32_t m_color;
};
}
#endif

View File

@@ -10,6 +10,7 @@ namespace mlx
{
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), 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<Texture*>(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