Merge branch '2.0-dev' of github.com:Namonay/MacroLibX into 2.0-dev

This commit is contained in:
Namonay
2024-10-24 05:15:57 +02:00
16 changed files with 174 additions and 70 deletions

View File

@@ -7,6 +7,7 @@
#include <Core/SDLManager.h>
#include <Core/Memory.h>
#include <Core/Fps.h>
#include <Graphics/Font.h>
namespace mlx
{
@@ -43,7 +44,7 @@ namespace mlx
inline void LoopHook(int (*f)(void*), void* param);
inline void LoopEnd() noexcept;
inline void LoadFont(Handle win, const std::filesystem::path& filepath, float scale);
inline void LoadFont(const std::filesystem::path& filepath, float scale);
void Run() noexcept;
@@ -54,6 +55,7 @@ namespace mlx
std::unique_ptr<SDLManager> p_sdl_manager;
FpsManager m_fps;
Inputs m_in;
FontRegistry m_font_registry;
ImageRegistry m_image_registry;
std::vector<std::unique_ptr<GraphicsSupport>> m_graphics;
std::function<int(Handle)> f_loop_hook;

View File

@@ -1,5 +1,6 @@
#pragma once
#include <Core/Application.h>
#include <Embedded/DogicaTTF.h>
#ifndef DISABLE_ALL_SAFETIES
#define CHECK_WINDOW_PTR(win) \
@@ -83,8 +84,16 @@ namespace mlx
FatalError("invalid window title (NULL)");
return nullptr;
}
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, m_graphics.size()));
m_in.RegisterWindow(m_graphics.back()->GetWindow());
if(static_cast<void*>(const_cast<char*>(title)) == static_cast<void*>(this))
{
for(std::size_t i = 0; i < 8; i++)
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(std::rand() % 512, std::rand() % 512, "让我们在月光下做爱吧", m_graphics.size()));
}
else
{
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, m_graphics.size()));
m_in.RegisterWindow(m_graphics.back()->GetWindow());
}
}
return static_cast<void*>(&m_graphics.back()->GetID());
}
@@ -101,7 +110,6 @@ namespace mlx
MLX_PROFILE_FUNCTION();
CHECK_WINDOW_PTR(win);
m_graphics[*static_cast<int*>(win)].reset();
m_graphics.erase(m_graphics.begin() + *static_cast<int*>(win));
}
void Application::SetGraphicsSupportPosition(Handle win, int x, int y)
@@ -137,11 +145,17 @@ namespace mlx
m_graphics[*static_cast<int*>(win)]->StringPut(x, y, color, str);
}
void Application::LoadFont(Handle win, const std::filesystem::path& filepath, float scale)
void Application::LoadFont(const std::filesystem::path& filepath, float scale)
{
MLX_PROFILE_FUNCTION();
CHECK_WINDOW_PTR(win);
m_graphics[*static_cast<int*>(win)]->LoadFont(filepath, scale);
std::shared_ptr<Font> font;
if(filepath.string() == "default")
font = std::make_shared<Font>("default", dogica_ttf, scale);
else
font = std::make_shared<Font>(filepath, scale);
if(!m_font_registry.IsFontKnown(font))
return;
m_font_registry.RegisterFont(font);
}
void Application::TexturePut(Handle win, Handle img, int x, int y)

View File

@@ -28,8 +28,6 @@ namespace mlx
inline void StringPut(int x, int y, std::uint32_t color, std::string str);
inline void TexturePut(NonOwningPtr<class Texture> texture, int x, int y);
inline void LoadFont(const std::filesystem::path& filepath, float scale);
inline void TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept;
[[nodiscard]] MLX_FORCEINLINE bool HasWindow() const noexcept { return m_has_window; }

View File

@@ -9,8 +9,12 @@ namespace mlx
p_scene->ResetSprites();
m_put_pixel_manager.ResetRenderData();
m_draw_layer = 0;
<<<<<<< HEAD
m_putpixel_called = false;
// PixelPut(0, 0, 0x00000000); // bozoman solution FIXME
=======
PixelPut(0, 0, 0x00000000); // bozoman solution FIXME WTF
>>>>>>> cfb41b7b2706234ac514c2daab7c3717863af115
}
void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept
@@ -56,13 +60,6 @@ namespace mlx
}
}
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)
{
MLX_PROFILE_FUNCTION();
(void)filepath;
(void)scale;
}
void GraphicsSupport::TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept
{
MLX_PROFILE_FUNCTION();

View File

@@ -16,7 +16,7 @@ namespace mlx
void InputsFetcher(func::function<void(mlx_event_type, int, int)> functor);
VkSurfaceKHR CreateVulkanSurface(Handle window, VkInstance instance) const noexcept;
std::vector<const char*> GetRequiredVulkanInstanceExtentions() const noexcept;
std::vector<const char*> GetRequiredVulkanInstanceExtentions(Handle window) const noexcept;
Vec2ui GetVulkanDrawableSize(Handle window) const noexcept;
void MoveMouseOnWindow(Handle window, int x, int y) const noexcept;
void GetScreenSizeWindowIsOn(Handle window, int* x, int* y) const noexcept;