mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
working on texts and fonts
This commit is contained in:
@@ -24,6 +24,7 @@ namespace mlx
|
||||
|
||||
m_fps.Init();
|
||||
p_render_core = std::make_unique<RenderCore>();
|
||||
LoadFont("default", 6.0f);
|
||||
}
|
||||
|
||||
void Application::Run() noexcept
|
||||
|
||||
@@ -155,13 +155,13 @@ extern "C"
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
if (filename == nullptr)
|
||||
{
|
||||
mlx::Error("PNG loader : filename is NULL");
|
||||
mlx::Error("PNG loader: filename is NULL");
|
||||
return nullptr;
|
||||
}
|
||||
std::filesystem::path file(filename);
|
||||
if(file.extension() != ".png")
|
||||
{
|
||||
mlx::Error("PNG loader : not a png file '%'", filename);
|
||||
mlx::Error("PNG loader: not a png file '%'", filename);
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<mlx::Application*>(mlx)->NewStbTexture(filename, width, height);
|
||||
@@ -172,13 +172,13 @@ extern "C"
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
if (filename == nullptr)
|
||||
{
|
||||
mlx::Error("JPG loader : filename is NULL");
|
||||
mlx::Error("JPG loader: filename is NULL");
|
||||
return nullptr;
|
||||
}
|
||||
std::filesystem::path file(filename);
|
||||
if(file.extension() != ".jpg" && file.extension() != ".jpeg")
|
||||
{
|
||||
mlx::Error("JPG loader : not a jpg file '%'", filename);
|
||||
mlx::Error("JPG loader: not a jpg file '%'", filename);
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<mlx::Application*>(mlx)->NewStbTexture(filename, width, height);
|
||||
@@ -189,13 +189,13 @@ extern "C"
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
if (filename == nullptr)
|
||||
{
|
||||
mlx::Error("BMP loader : filename is NULL");
|
||||
mlx::Error("BMP loader: filename is NULL");
|
||||
return nullptr;
|
||||
}
|
||||
std::filesystem::path file(filename);
|
||||
if(file.extension() != ".bmp" && file.extension() != ".dib")
|
||||
{
|
||||
mlx::Error("BMP loader : not a bmp file '%'", filename);
|
||||
mlx::Error("BMP loader: not a bmp file '%'", filename);
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<mlx::Application*>(mlx)->NewStbTexture(filename, width, height);
|
||||
@@ -230,13 +230,13 @@ extern "C"
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
if (filepath == nullptr)
|
||||
{
|
||||
mlx::Error("Font loader : filepath is NULL");
|
||||
mlx::Error("Font loader: filepath is NULL");
|
||||
return;
|
||||
}
|
||||
std::filesystem::path file(filepath);
|
||||
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
||||
{
|
||||
mlx::Error("TTF loader : not a truetype font file '%'", filepath);
|
||||
mlx::Error("TTF loader: not a truetype font file '%'", filepath);
|
||||
return;
|
||||
}
|
||||
if(std::strcmp(filepath, "default") == 0)
|
||||
@@ -250,13 +250,13 @@ extern "C"
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
if (filepath == nullptr)
|
||||
{
|
||||
mlx::Error("Font loader : filepath is NULL");
|
||||
mlx::Error("Font loader: filepath is NULL");
|
||||
return;
|
||||
}
|
||||
std::filesystem::path file(filepath);
|
||||
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
||||
{
|
||||
mlx::Error("TTF loader : not a truetype font file '%'", filepath);
|
||||
mlx::Error("TTF loader: not a truetype font file '%'", filepath);
|
||||
return;
|
||||
}
|
||||
static_cast<mlx::Application*>(mlx)->LoadFont(file, scale);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace mlx
|
||||
auto it = std::find(s_blocks.begin(), s_blocks.end(), ptr);
|
||||
if(it == s_blocks.end())
|
||||
{
|
||||
Error("Memory Manager : trying to free a pointer not allocated by the memory manager");
|
||||
Error("Memory Manager: trying to free a pointer not allocated by the memory manager");
|
||||
return;
|
||||
}
|
||||
std::free(*it);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace mlx
|
||||
if(m_output_stream.is_open())
|
||||
WriteHeader();
|
||||
else
|
||||
Error("Profiler : cannot open runtime profile file");
|
||||
Error("Profiler: cannot open runtime profile file");
|
||||
m_runtime_session_began = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,21 +43,21 @@ namespace mlx
|
||||
#endif
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
|
||||
FatalError("SDL : unable to init all subsystems; %", SDL_GetError());
|
||||
FatalError("SDL: unable to init all subsystems; %", SDL_GetError());
|
||||
DebugLog("SDL Manager initialized");
|
||||
}
|
||||
|
||||
Handle SDLManager::CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden, std::int32_t& id)
|
||||
{
|
||||
Internal::WindowInfos* infos = new Internal::WindowInfos;
|
||||
Verify(infos != nullptr, "SDL : window allocation failed");
|
||||
Verify(infos != nullptr, "SDL: window allocation failed");
|
||||
|
||||
if(title == "让我们在月光下做爱吧")
|
||||
infos->window = SDL_CreateWindow(title.c_str(), std::rand() % 512, std::rand() % 512, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
|
||||
else
|
||||
infos->window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
|
||||
if(!infos->window)
|
||||
FatalError("SDL : unable to open a new window; %", SDL_GetError());
|
||||
FatalError("SDL: unable to open a new window; %", SDL_GetError());
|
||||
infos->icon = SDL_CreateRGBSurfaceFrom(static_cast<void*>(logo_mlx), logo_mlx_width, logo_mlx_height, 32, 4 * logo_mlx_width, rmask, gmask, bmask, amask);
|
||||
SDL_SetWindowIcon(infos->window, infos->icon);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace mlx
|
||||
|
||||
void SDLManager::DestroyWindow(Handle window) noexcept
|
||||
{
|
||||
Verify(m_windows_registry.find(window) != m_windows_registry.end(), "SDL : cannot destroy window; unknown window pointer");
|
||||
Verify(m_windows_registry.find(window) != m_windows_registry.end(), "SDL: cannot destroy window; unknown window pointer");
|
||||
|
||||
Internal::WindowInfos* infos = static_cast<Internal::WindowInfos*>(window);
|
||||
if(infos->window != nullptr)
|
||||
@@ -86,7 +86,7 @@ namespace mlx
|
||||
{
|
||||
VkSurfaceKHR surface;
|
||||
if(!SDL_Vulkan_CreateSurface(static_cast<Internal::WindowInfos*>(window)->window, instance, &surface))
|
||||
FatalError("SDL : could not create a Vulkan surface; %", SDL_GetError());
|
||||
FatalError("SDL: could not create a Vulkan surface; %", SDL_GetError());
|
||||
return surface;
|
||||
}
|
||||
|
||||
@@ -94,10 +94,10 @@ namespace mlx
|
||||
{
|
||||
std::uint32_t count;
|
||||
if(!SDL_Vulkan_GetInstanceExtensions(static_cast<Internal::WindowInfos*>(window)->window, &count, nullptr))
|
||||
FatalError("SDL Manager : could not retrieve Vulkan instance extensions");
|
||||
FatalError("SDL Manager: could not retrieve Vulkan instance extensions");
|
||||
std::vector<const char*> extensions(count);
|
||||
if(!SDL_Vulkan_GetInstanceExtensions(static_cast<Internal::WindowInfos*>(window)->window, &count, extensions.data()))
|
||||
FatalError("SDL Manager : could not retrieve Vulkan instance extensions");
|
||||
FatalError("SDL Manager: could not retrieve Vulkan instance extensions");
|
||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
return extensions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user