mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing compilation issues
This commit is contained in:
@@ -20,9 +20,9 @@ int update(void* param)
|
|||||||
mlx_clear_window(mlx->mlx, mlx->win);
|
mlx_clear_window(mlx->mlx, mlx->win);
|
||||||
|
|
||||||
if(i >= 250)
|
if(i >= 250)
|
||||||
mlx_set_font_scale(mlx->mlx, mlx->win, "default", 16.f);
|
mlx_set_font_scale(mlx->mlx, "default", 16.f);
|
||||||
else
|
else
|
||||||
mlx_set_font_scale(mlx->mlx, mlx->win, "default", 6.f);
|
mlx_set_font_scale(mlx->mlx, "default", 6.f);
|
||||||
|
|
||||||
mlx_string_put(mlx->mlx, mlx->win, 160, 120, 0xFFFF2066, "this text should be hidden");
|
mlx_string_put(mlx->mlx, mlx->win, 160, 120, 0xFFFF2066, "this text should be hidden");
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ int update(void* param)
|
|||||||
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo_bmp, 220, 40);
|
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo_bmp, 220, 40);
|
||||||
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->img, 150, 60);
|
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->img, 150, 60);
|
||||||
|
|
||||||
mlx_set_font(mlx->mlx, mlx->win, "default");
|
mlx_set_font(mlx->mlx, "default");
|
||||||
mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text");
|
mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text");
|
||||||
|
|
||||||
for(int j = 0, color = 0; j < 400; j++)
|
for(int j = 0, color = 0; j < 400; j++)
|
||||||
@@ -145,7 +145,7 @@ int main(void)
|
|||||||
|
|
||||||
mlx.img = create_image(&mlx);
|
mlx.img = create_image(&mlx);
|
||||||
|
|
||||||
mlx_set_font_scale(mlx.mlx, mlx.win, "font.ttf", 16.f);
|
mlx_set_font_scale(mlx.mlx, "font.ttf", 16.f);
|
||||||
mlx_string_put(mlx.mlx, mlx.win, 20, 20, 0xFF0020FF, "that text will disappear");
|
mlx_string_put(mlx.mlx, mlx.win, 20, 20, 0xFF0020FF, "that text will disappear");
|
||||||
|
|
||||||
mlx_loop_hook(mlx.mlx, update, &mlx);
|
mlx_loop_hook(mlx.mlx, update, &mlx);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <contact@kbz8.me> +#+ +:+ +#+ */
|
/* By: maldavid <contact@kbz8.me> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
|
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/10/17 17:51:28 by maldavid ### ########.fr */
|
/* Updated: 2024/10/22 11:56:44 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ MLX_API int mlx_string_put(void* mlx, void* win, int x, int y, int color, char*
|
|||||||
*
|
*
|
||||||
* @return (void)
|
* @return (void)
|
||||||
*/
|
*/
|
||||||
MLX_API void mlx_set_font(void* mlx, void* win, char* filepath);
|
MLX_API void mlx_set_font(void* mlx, char* filepath);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +325,7 @@ MLX_API void mlx_set_font(void* mlx, void* win, char* filepath);
|
|||||||
*
|
*
|
||||||
* @return (void)
|
* @return (void)
|
||||||
*/
|
*/
|
||||||
MLX_API void mlx_set_font_scale(void* mlx, void* win, char* filepath, float scale);
|
MLX_API void mlx_set_font_scale(void* mlx, char* filepath, float scale);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace mlx
|
|||||||
inline void LoopHook(int (*f)(void*), void* param);
|
inline void LoopHook(int (*f)(void*), void* param);
|
||||||
inline void LoopEnd() noexcept;
|
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;
|
void Run() noexcept;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Core/Application.h>
|
#include <Core/Application.h>
|
||||||
|
#include <Embedded/DogicaTTF.h>
|
||||||
|
|
||||||
#ifndef DISABLE_ALL_SAFETIES
|
#ifndef DISABLE_ALL_SAFETIES
|
||||||
#define CHECK_WINDOW_PTR(win) \
|
#define CHECK_WINDOW_PTR(win) \
|
||||||
@@ -137,11 +138,17 @@ namespace mlx
|
|||||||
m_graphics[*static_cast<int*>(win)]->StringPut(x, y, color, str);
|
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();
|
MLX_PROFILE_FUNCTION();
|
||||||
CHECK_WINDOW_PTR(win);
|
std::shared_ptr<Font> font;
|
||||||
m_graphics[*static_cast<int*>(win)]->LoadFont(filepath, scale);
|
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)
|
void Application::TexturePut(Handle win, Handle img, int x, int y)
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ namespace mlx
|
|||||||
inline void StringPut(int x, int y, std::uint32_t color, std::string str);
|
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 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;
|
inline void TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept;
|
||||||
|
|
||||||
[[nodiscard]] MLX_FORCEINLINE bool HasWindow() const noexcept { return m_has_window; }
|
[[nodiscard]] MLX_FORCEINLINE bool HasWindow() const noexcept { return m_has_window; }
|
||||||
|
|||||||
@@ -46,13 +46,6 @@ namespace mlx
|
|||||||
p_scene->BringToFront(std::move(sprite));
|
p_scene->BringToFront(std::move(sprite));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)
|
|
||||||
{
|
|
||||||
MLX_PROFILE_FUNCTION();
|
|
||||||
(void)filepath;
|
|
||||||
(void)scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsSupport::TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept
|
void GraphicsSupport::TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace mlx
|
|||||||
void InputsFetcher(func::function<void(mlx_event_type, int, int)> functor);
|
void InputsFetcher(func::function<void(mlx_event_type, int, int)> functor);
|
||||||
|
|
||||||
VkSurfaceKHR CreateVulkanSurface(Handle window, VkInstance instance) const noexcept;
|
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;
|
Vec2ui GetVulkanDrawableSize(Handle window) const noexcept;
|
||||||
void MoveMouseOnWindow(Handle window, int x, int y) const noexcept;
|
void MoveMouseOnWindow(Handle window, int x, int y) const noexcept;
|
||||||
void GetScreenSizeWindowIsOn(Handle window, int* x, int* y) const noexcept;
|
void GetScreenSizeWindowIsOn(Handle window, int* x, int* y) const noexcept;
|
||||||
|
|||||||
@@ -1,43 +1,31 @@
|
|||||||
3,2,35,7,0,0,1,0,39,0,0,0,52,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,
|
3,2,35,7,0,0,1,0,39,0,0,0,34,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,14,0,
|
||||||
6,0,29,0,0,0,71,76,83,76,46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,
|
3,0,0,0,0,0,1,0,0,0,15,0,7,0,4,0,0,0,21,0,0,0,109,97,105,110,0,0,0,0,
|
||||||
1,0,0,0,15,0,7,0,4,0,0,0,31,0,0,0,109,97,105,110,0,0,0,0,15,0,0,0,23,0,
|
10,0,0,0,18,0,0,0,16,0,3,0,21,0,0,0,7,0,0,0,3,0,3,0,0,0,0,0,100,0,
|
||||||
0,0,16,0,3,0,31,0,0,0,7,0,0,0,3,0,3,0,0,0,0,0,100,0,0,0,5,0,4,0,
|
0,0,5,0,4,0,14,0,0,0,86,101,114,116,79,117,116,0,6,0,4,0,14,0,0,0,0,0,0,0,
|
||||||
19,0,0,0,86,101,114,116,79,117,116,0,6,0,4,0,19,0,0,0,0,0,0,0,117,118,0,0,5,0,
|
117,118,0,0,5,0,4,0,19,0,0,0,70,114,97,103,79,117,116,0,6,0,5,0,19,0,0,0,0,0,
|
||||||
4,0,24,0,0,0,70,114,97,103,79,117,116,0,6,0,5,0,24,0,0,0,0,0,0,0,99,111,108,111,
|
0,0,99,111,108,111,114,0,0,0,5,0,5,0,5,0,0,0,117,95,116,101,120,116,117,114,101,0,0,0,
|
||||||
114,0,0,0,5,0,5,0,5,0,0,0,117,95,116,101,120,116,117,114,101,0,0,0,5,0,3,0,15,0,
|
5,0,3,0,10,0,0,0,117,118,0,0,5,0,4,0,18,0,0,0,99,111,108,111,114,0,0,0,5,0,
|
||||||
0,0,117,118,0,0,5,0,4,0,23,0,0,0,99,111,108,111,114,0,0,0,5,0,6,0,30,0,0,0,
|
4,0,21,0,0,0,109,97,105,110,0,0,0,0,71,0,4,0,5,0,0,0,33,0,0,0,0,0,0,0,
|
||||||
76,105,110,101,97,114,84,111,115,82,71,66,0,0,0,0,5,0,4,0,31,0,0,0,109,97,105,110,0,0,
|
71,0,4,0,5,0,0,0,34,0,0,0,0,0,0,0,71,0,4,0,10,0,0,0,30,0,0,0,0,0,
|
||||||
0,0,71,0,4,0,5,0,0,0,33,0,0,0,0,0,0,0,71,0,4,0,5,0,0,0,34,0,0,0,
|
0,0,71,0,4,0,18,0,0,0,30,0,0,0,0,0,0,0,72,0,5,0,14,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,71,0,4,0,15,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,23,0,0,0,30,0,
|
35,0,0,0,0,0,0,0,72,0,5,0,19,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,22,0,
|
||||||
0,0,0,0,0,0,72,0,5,0,19,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,72,0,5,0,
|
3,0,1,0,0,0,32,0,0,0,25,0,9,0,2,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,
|
||||||
24,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,22,0,3,0,1,0,0,0,32,0,0,0,25,0,
|
0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,27,0,3,0,3,0,0,0,2,0,0,0,32,0,
|
||||||
9,0,2,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
|
4,0,4,0,0,0,0,0,0,0,3,0,0,0,19,0,2,0,6,0,0,0,33,0,3,0,7,0,0,0,
|
||||||
0,0,0,0,27,0,3,0,3,0,0,0,2,0,0,0,32,0,4,0,4,0,0,0,0,0,0,0,3,0,
|
6,0,0,0,23,0,4,0,8,0,0,0,1,0,0,0,2,0,0,0,32,0,4,0,9,0,0,0,1,0,
|
||||||
0,0,23,0,4,0,6,0,0,0,1,0,0,0,3,0,0,0,32,0,4,0,7,0,0,0,7,0,0,0,
|
0,0,8,0,0,0,21,0,4,0,11,0,0,0,32,0,0,0,1,0,0,0,43,0,4,0,11,0,0,0,
|
||||||
6,0,0,0,33,0,4,0,8,0,0,0,6,0,0,0,7,0,0,0,43,0,4,0,1,0,0,0,9,0,
|
12,0,0,0,0,0,0,0,32,0,4,0,13,0,0,0,7,0,0,0,8,0,0,0,30,0,3,0,14,0,
|
||||||
0,0,46,186,232,62,44,0,6,0,6,0,0,0,10,0,0,0,9,0,0,0,9,0,0,0,9,0,0,0,
|
0,0,8,0,0,0,32,0,4,0,15,0,0,0,7,0,0,0,14,0,0,0,23,0,4,0,16,0,0,0,
|
||||||
19,0,2,0,11,0,0,0,33,0,3,0,12,0,0,0,11,0,0,0,23,0,4,0,13,0,0,0,1,0,
|
1,0,0,0,4,0,0,0,32,0,4,0,17,0,0,0,3,0,0,0,16,0,0,0,30,0,3,0,19,0,
|
||||||
0,0,2,0,0,0,32,0,4,0,14,0,0,0,1,0,0,0,13,0,0,0,21,0,4,0,16,0,0,0,
|
0,0,16,0,0,0,32,0,4,0,20,0,0,0,7,0,0,0,19,0,0,0,32,0,4,0,31,0,0,0,
|
||||||
32,0,0,0,1,0,0,0,43,0,4,0,16,0,0,0,17,0,0,0,0,0,0,0,32,0,4,0,18,0,
|
7,0,0,0,16,0,0,0,59,0,4,0,4,0,0,0,5,0,0,0,0,0,0,0,59,0,4,0,9,0,
|
||||||
0,0,7,0,0,0,13,0,0,0,30,0,3,0,19,0,0,0,13,0,0,0,32,0,4,0,20,0,0,0,
|
0,0,10,0,0,0,1,0,0,0,59,0,4,0,17,0,0,0,18,0,0,0,3,0,0,0,54,0,5,0,
|
||||||
7,0,0,0,19,0,0,0,23,0,4,0,21,0,0,0,1,0,0,0,4,0,0,0,32,0,4,0,22,0,
|
6,0,0,0,21,0,0,0,0,0,0,0,7,0,0,0,248,0,2,0,22,0,0,0,59,0,4,0,20,0,
|
||||||
0,0,3,0,0,0,21,0,0,0,30,0,3,0,24,0,0,0,21,0,0,0,32,0,4,0,25,0,0,0,
|
0,0,23,0,0,0,7,0,0,0,59,0,4,0,15,0,0,0,24,0,0,0,7,0,0,0,65,0,5,0,
|
||||||
7,0,0,0,24,0,0,0,43,0,4,0,16,0,0,0,26,0,0,0,1,0,0,0,43,0,4,0,16,0,
|
13,0,0,0,25,0,0,0,24,0,0,0,12,0,0,0,63,0,3,0,25,0,0,0,10,0,0,0,61,0,
|
||||||
0,0,27,0,0,0,2,0,0,0,43,0,4,0,1,0,0,0,28,0,0,0,0,0,128,63,32,0,4,0,
|
4,0,3,0,0,0,26,0,0,0,5,0,0,0,65,0,5,0,13,0,0,0,27,0,0,0,24,0,0,0,
|
||||||
49,0,0,0,7,0,0,0,21,0,0,0,59,0,4,0,4,0,0,0,5,0,0,0,0,0,0,0,59,0,
|
12,0,0,0,61,0,4,0,8,0,0,0,28,0,0,0,27,0,0,0,87,0,5,0,16,0,0,0,29,0,
|
||||||
4,0,14,0,0,0,15,0,0,0,1,0,0,0,59,0,4,0,22,0,0,0,23,0,0,0,3,0,0,0,
|
0,0,26,0,0,0,28,0,0,0,65,0,5,0,31,0,0,0,30,0,0,0,23,0,0,0,12,0,0,0,
|
||||||
54,0,5,0,6,0,0,0,30,0,0,0,0,0,0,0,8,0,0,0,55,0,3,0,7,0,0,0,32,0,
|
62,0,3,0,30,0,0,0,29,0,0,0,61,0,4,0,19,0,0,0,32,0,0,0,23,0,0,0,81,0,
|
||||||
0,0,248,0,2,0,33,0,0,0,61,0,4,0,6,0,0,0,34,0,0,0,32,0,0,0,12,0,7,0,
|
5,0,16,0,0,0,33,0,0,0,32,0,0,0,0,0,0,0,62,0,3,0,18,0,0,0,33,0,0,0,
|
||||||
6,0,0,0,35,0,0,0,29,0,0,0,26,0,0,0,34,0,0,0,10,0,0,0,254,0,2,0,35,0,
|
253,0,1,0,56,0,1,0
|
||||||
0,0,56,0,1,0,54,0,5,0,11,0,0,0,31,0,0,0,0,0,0,0,12,0,0,0,248,0,2,0,
|
|
||||||
36,0,0,0,59,0,4,0,25,0,0,0,37,0,0,0,7,0,0,0,59,0,4,0,7,0,0,0,38,0,
|
|
||||||
0,0,7,0,0,0,59,0,4,0,20,0,0,0,39,0,0,0,7,0,0,0,65,0,5,0,18,0,0,0,
|
|
||||||
40,0,0,0,39,0,0,0,17,0,0,0,63,0,3,0,40,0,0,0,15,0,0,0,61,0,4,0,3,0,
|
|
||||||
0,0,41,0,0,0,5,0,0,0,65,0,5,0,18,0,0,0,42,0,0,0,39,0,0,0,17,0,0,0,
|
|
||||||
61,0,4,0,13,0,0,0,43,0,0,0,42,0,0,0,87,0,5,0,21,0,0,0,44,0,0,0,41,0,
|
|
||||||
0,0,43,0,0,0,79,0,8,0,6,0,0,0,45,0,0,0,44,0,0,0,44,0,0,0,0,0,0,0,
|
|
||||||
1,0,0,0,2,0,0,0,62,0,3,0,38,0,0,0,45,0,0,0,57,0,5,0,6,0,0,0,46,0,
|
|
||||||
0,0,30,0,0,0,38,0,0,0,80,0,5,0,21,0,0,0,47,0,0,0,46,0,0,0,28,0,0,0,
|
|
||||||
65,0,5,0,49,0,0,0,48,0,0,0,37,0,0,0,17,0,0,0,62,0,3,0,48,0,0,0,47,0,
|
|
||||||
0,0,61,0,4,0,24,0,0,0,50,0,0,0,37,0,0,0,81,0,5,0,21,0,0,0,51,0,0,0,
|
|
||||||
50,0,0,0,0,0,0,0,62,0,3,0,23,0,0,0,51,0,0,0,253,0,1,0,56,0,1,0
|
|
||||||
|
|||||||
@@ -11,23 +11,21 @@ namespace mlx
|
|||||||
Font(const std::filesystem::path& path, float scale) : m_build_data(path), m_name(path.string()), m_scale(scale) {}
|
Font(const std::filesystem::path& path, float scale) : m_build_data(path), m_name(path.string()), m_scale(scale) {}
|
||||||
Font(const std::string& name, const std::vector<std::uint8_t>& ttf_data, float scale) : m_build_data(ttf_data), m_name(name), m_scale(scale) {}
|
Font(const std::string& name, const std::vector<std::uint8_t>& ttf_data, float scale) : m_build_data(ttf_data), m_name(name), m_scale(scale) {}
|
||||||
|
|
||||||
|
void BuildFont();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
inline const std::string& GetName() const { return m_name; }
|
inline const std::string& GetName() const { return m_name; }
|
||||||
inline float GetScale() const noexcept { return m_scale; }
|
inline float GetScale() const noexcept { return m_scale; }
|
||||||
inline const std::array<stbtt_packedchar, 96>& GetCharData() const { return m_cdata; }
|
inline const std::array<stbtt_packedchar, 96>& GetCharData() const { return m_cdata; }
|
||||||
inline const Font& GetFont() const noexcept { return m_atlas; }
|
inline const Texture& GetTexture() const noexcept { return m_atlas; }
|
||||||
inline bool operator==(const Font& rhs) const { return rhs.m_name == m_name && rhs.m_scale == m_scale; }
|
inline bool operator==(const Font& rhs) const { return rhs.m_name == m_name && rhs.m_scale == m_scale; }
|
||||||
inline bool operator!=(const Font& rhs) const { return rhs.m_name != m_name || rhs.m_scale != m_scale; }
|
inline bool operator!=(const Font& rhs) const { return rhs.m_name != m_name || rhs.m_scale != m_scale; }
|
||||||
|
|
||||||
inline ~Font() { Destroy(); }
|
inline ~Font() { Destroy(); }
|
||||||
|
|
||||||
private:
|
|
||||||
void BuildFont();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<stbtt_packedchar, 96> m_cdata;
|
std::array<stbtt_packedchar, 96> m_cdata;
|
||||||
Font m_atlas;
|
Texture m_atlas;
|
||||||
std::variant<std::filesystem::path, std::vector<std::uint8_t>> m_build_data;
|
std::variant<std::filesystem::path, std::vector<std::uint8_t>> m_build_data;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace mlx
|
|||||||
inline void SetPosition(int x, int y) { SDLManager::Get().SetWindowPosition(p_window, x, y); }
|
inline void SetPosition(int x, int y) { SDLManager::Get().SetWindowPosition(p_window, x, y); }
|
||||||
|
|
||||||
inline VkSurfaceKHR CreateVulkanSurface(VkInstance instance) const noexcept { return SDLManager::Get().CreateVulkanSurface(p_window, instance); }
|
inline VkSurfaceKHR CreateVulkanSurface(VkInstance instance) const noexcept { return SDLManager::Get().CreateVulkanSurface(p_window, instance); }
|
||||||
inline std::vector<const char*> GetRequiredVulkanInstanceExtentions() const noexcept { return SDLManager::Get().GetRequiredVulkanInstanceExtentions(); }
|
inline std::vector<const char*> GetRequiredVulkanInstanceExtentions() const noexcept { return SDLManager::Get().GetRequiredVulkanInstanceExtentions(p_window); }
|
||||||
inline Vec2ui GetVulkanDrawableSize() const noexcept { return SDLManager::Get().GetVulkanDrawableSize(p_window); }
|
inline Vec2ui GetVulkanDrawableSize() const noexcept { return SDLManager::Get().GetVulkanDrawableSize(p_window); }
|
||||||
|
|
||||||
void Destroy() noexcept;
|
void Destroy() noexcept;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ extern "C"
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mlx_set_font(void* mlx, void* win, char* filepath)
|
void mlx_set_font(void* mlx, char* filepath)
|
||||||
{
|
{
|
||||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||||
if (filepath == nullptr)
|
if (filepath == nullptr)
|
||||||
@@ -240,12 +240,12 @@ extern "C"
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(std::strcmp(filepath, "default") == 0)
|
if(std::strcmp(filepath, "default") == 0)
|
||||||
static_cast<mlx::Application*>(mlx)->LoadFont(win, file, 6.f);
|
static_cast<mlx::Application*>(mlx)->LoadFont(file, 6.f);
|
||||||
else
|
else
|
||||||
static_cast<mlx::Application*>(mlx)->LoadFont(win, file, 16.f);
|
static_cast<mlx::Application*>(mlx)->LoadFont(file, 16.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mlx_set_font_scale(void* mlx, void* win, char* filepath, float scale)
|
void mlx_set_font_scale(void* mlx, char* filepath, float scale)
|
||||||
{
|
{
|
||||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||||
if (filepath == nullptr)
|
if (filepath == nullptr)
|
||||||
@@ -259,7 +259,7 @@ extern "C"
|
|||||||
mlx::Error("TTF loader : not a truetype font file '%'", filepath);
|
mlx::Error("TTF loader : not a truetype font file '%'", filepath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static_cast<mlx::Application*>(mlx)->LoadFont(win, file, scale);
|
static_cast<mlx::Application*>(mlx)->LoadFont(file, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mlx_clear_window(void* mlx, void* win)
|
int mlx_clear_window(void* mlx, void* win)
|
||||||
|
|||||||
@@ -87,30 +87,15 @@ namespace mlx
|
|||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char*> SDLManager::GetRequiredVulkanInstanceExtentions() const noexcept
|
std::vector<const char*> SDLManager::GetRequiredVulkanInstanceExtentions(Handle window) const noexcept
|
||||||
{
|
{
|
||||||
std::vector<const char*> extensions;
|
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");
|
||||||
|
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");
|
||||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
|
||||||
extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
|
||||||
extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
|
||||||
// extensions.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
|
||||||
extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
|
||||||
extensions.push_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME);
|
|
||||||
#endif
|
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
#include <PreCompiled.h>
|
#include <PreCompiled.h>
|
||||||
|
|
||||||
#include <Graphics/Font.h>
|
#include <Graphics/Font.h>
|
||||||
|
#include <Core/Memory.h>
|
||||||
|
|
||||||
|
#define STB_TRUETYPE_IMPLEMENTATION
|
||||||
|
#define STB_malloc(x, u) ((void)(u), MemManager::Get().Malloc(x))
|
||||||
|
#define STB_free(x, u) ((void)(u), MemManager::Get().Free(x))
|
||||||
|
#include <stb_truetype.h>
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user