This commit is contained in:
Kbz-8
2024-10-28 20:17:39 +01:00
parent 77240013a4
commit 3153941573
9 changed files with 73 additions and 73 deletions

View File

@@ -87,7 +87,10 @@ namespace mlx
if(static_cast<void*>(const_cast<char*>(title)) == static_cast<void*>(this)) if(static_cast<void*>(const_cast<char*>(title)) == static_cast<void*>(this))
{ {
for(std::size_t i = 0; i < 8; i++) 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())); {
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(std::rand() % 1920, std::rand() % 1080, "让我们在月光下做爱吧", m_graphics.size()));
m_graphics.back()->GetWindow()->SetPosition(std::rand() % 1920, std::rand() % 1080);
}
} }
else else
{ {

View File

@@ -31,10 +31,10 @@ namespace mlx
return; return;
Vec4f vec_color = { Vec4f vec_color = {
static_cast<float>((color & 0x000000FF)) / 255.f, static_cast<float>((color & 0x000000FF)) / 255.0f,
static_cast<float>((color & 0x0000FF00) >> 8) / 255.f, static_cast<float>((color & 0x0000FF00) >> 8) / 255.0f,
static_cast<float>((color & 0x00FF0000) >> 16) / 255.f, static_cast<float>((color & 0x00FF0000) >> 16) / 255.0f,
static_cast<float>((color & 0xFF000000) >> 24) / 255.f static_cast<float>((color & 0xFF000000) >> 24) / 255.0f
}; };
NonOwningPtr<Text> text = p_scene->GetTextFromPositionAndColor(str, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, vec_color); NonOwningPtr<Text> text = p_scene->GetTextFromPositionAndColor(str, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, vec_color);
@@ -43,10 +43,10 @@ namespace mlx
Text& new_text = p_scene->CreateText(str); Text& new_text = p_scene->CreateText(str);
new_text.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) }); new_text.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
new_text.SetColor(std::move(vec_color)); new_text.SetColor(std::move(vec_color));
// if(m_pixelput_called) if(m_pixelput_called)
{ {
m_draw_layer++; m_draw_layer++;
// m_pixelput_called = false; m_pixelput_called = false;
} }
} }
else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer)) else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer))

View File

@@ -22,7 +22,7 @@ struct ViewerData
struct SpriteData struct SpriteData
{ {
color: vec4[f32], color: vec4[f32],
position: vec4[f32] position: vec2[f32]
} }
external external
@@ -34,7 +34,7 @@ external
[entry(vert)] [entry(vert)]
fn main(input: VertIn) -> VertOut fn main(input: VertIn) -> VertOut
{ {
let position: vec4[f32] = vec4[f32](input.pos.xyz + model.position.xyz, 1.0); let position: vec4[f32] = vec4[f32](input.pos.xy + model.position, 1.0, 1.0);
input.uv *= -1.0; input.uv *= -1.0;
let output: VertOut; let output: VertOut;
output.uv = input.uv; output.uv = input.uv;

View File

@@ -1,71 +1,70 @@
3,2,35,7,0,0,1,0,39,0,0,0,71,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,14,0, 3,2,35,7,0,0,1,0,39,0,0,0,70,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,14,0,
3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,35,0,0,0,109,97,105,110,0,0,0,0, 3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,34,0,0,0,109,97,105,110,0,0,0,0,
13,0,0,0,19,0,0,0,25,0,0,0,27,0,0,0,28,0,0,0,3,0,3,0,0,0,0,0,100,0, 14,0,0,0,19,0,0,0,25,0,0,0,27,0,0,0,28,0,0,0,3,0,3,0,0,0,0,0,100,0,
0,0,5,0,5,0,4,0,0,0,86,105,101,119,101,114,68,97,116,97,0,0,6,0,8,0,4,0,0,0, 0,0,5,0,5,0,4,0,0,0,86,105,101,119,101,114,68,97,116,97,0,0,6,0,8,0,4,0,0,0,
0,0,0,0,112,114,111,106,101,99,116,105,111,110,95,109,97,116,114,105,120,0,0,0,5,0,5,0,7,0, 0,0,0,0,112,114,111,106,101,99,116,105,111,110,95,109,97,116,114,105,120,0,0,0,5,0,5,0,8,0,
0,0,83,112,114,105,116,101,68,97,116,97,0,0,6,0,5,0,7,0,0,0,0,0,0,0,99,111,108,111, 0,0,83,112,114,105,116,101,68,97,116,97,0,0,6,0,5,0,8,0,0,0,0,0,0,0,99,111,108,111,
114,0,0,0,6,0,6,0,7,0,0,0,1,0,0,0,112,111,115,105,116,105,111,110,0,0,0,0,5,0, 114,0,0,0,6,0,6,0,8,0,0,0,1,0,0,0,112,111,115,105,116,105,111,110,0,0,0,0,5,0,
4,0,22,0,0,0,86,101,114,116,73,110,0,0,6,0,4,0,22,0,0,0,0,0,0,0,112,111,115,0, 4,0,22,0,0,0,86,101,114,116,73,110,0,0,6,0,4,0,22,0,0,0,0,0,0,0,112,111,115,0,
6,0,4,0,22,0,0,0,1,0,0,0,117,118,0,0,5,0,4,0,29,0,0,0,86,101,114,116,79,117, 6,0,4,0,22,0,0,0,1,0,0,0,117,118,0,0,5,0,4,0,29,0,0,0,86,101,114,116,79,117,
116,0,6,0,5,0,29,0,0,0,0,0,0,0,99,111,108,111,114,0,0,0,6,0,4,0,29,0,0,0, 116,0,6,0,5,0,29,0,0,0,0,0,0,0,99,111,108,111,114,0,0,0,6,0,4,0,29,0,0,0,
1,0,0,0,117,118,0,0,6,0,4,0,29,0,0,0,2,0,0,0,112,111,115,0,5,0,5,0,6,0, 1,0,0,0,117,118,0,0,6,0,4,0,29,0,0,0,2,0,0,0,112,111,115,0,5,0,5,0,6,0,
0,0,118,105,101,119,101,114,95,100,97,116,97,0,5,0,4,0,9,0,0,0,109,111,100,101,108,0,0,0, 0,0,118,105,101,119,101,114,95,100,97,116,97,0,5,0,4,0,10,0,0,0,109,111,100,101,108,0,0,0,
5,0,3,0,13,0,0,0,112,111,115,0,5,0,3,0,19,0,0,0,117,118,0,0,5,0,4,0,25,0, 5,0,3,0,14,0,0,0,112,111,115,0,5,0,3,0,19,0,0,0,117,118,0,0,5,0,4,0,25,0,
0,0,99,111,108,111,114,0,0,0,5,0,3,0,27,0,0,0,117,118,0,0,5,0,5,0,28,0,0,0, 0,0,99,111,108,111,114,0,0,0,5,0,3,0,27,0,0,0,117,118,0,0,5,0,5,0,28,0,0,0,
112,111,115,105,116,105,111,110,0,0,0,0,5,0,4,0,35,0,0,0,109,97,105,110,0,0,0,0,71,0, 112,111,115,105,116,105,111,110,0,0,0,0,5,0,4,0,34,0,0,0,109,97,105,110,0,0,0,0,71,0,
4,0,6,0,0,0,33,0,0,0,0,0,0,0,71,0,4,0,6,0,0,0,34,0,0,0,0,0,0,0, 4,0,6,0,0,0,33,0,0,0,0,0,0,0,71,0,4,0,6,0,0,0,34,0,0,0,0,0,0,0,
71,0,4,0,28,0,0,0,11,0,0,0,0,0,0,0,71,0,4,0,13,0,0,0,30,0,0,0,0,0, 71,0,4,0,28,0,0,0,11,0,0,0,0,0,0,0,71,0,4,0,14,0,0,0,30,0,0,0,0,0,
0,0,71,0,4,0,19,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,25,0,0,0,30,0,0,0, 0,0,71,0,4,0,19,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,25,0,0,0,30,0,0,0,
0,0,0,0,71,0,4,0,27,0,0,0,30,0,0,0,1,0,0,0,71,0,3,0,4,0,0,0,2,0, 0,0,0,0,71,0,4,0,27,0,0,0,30,0,0,0,1,0,0,0,71,0,3,0,4,0,0,0,2,0,
0,0,72,0,4,0,4,0,0,0,0,0,0,0,5,0,0,0,72,0,5,0,4,0,0,0,0,0,0,0, 0,0,72,0,4,0,4,0,0,0,0,0,0,0,5,0,0,0,72,0,5,0,4,0,0,0,0,0,0,0,
7,0,0,0,16,0,0,0,72,0,5,0,4,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,71,0, 7,0,0,0,16,0,0,0,72,0,5,0,4,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,71,0,
3,0,7,0,0,0,2,0,0,0,72,0,5,0,7,0,0,0,0,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 7,0,0,0,59,0,4,0,32,0,0,0,37,0,0,0,7,0,0,0,59,0,4,0,23,0,0,0,38,0,
0,0,7,0,0,0,65,0,5,0,16,0,0,0,40,0,0,0,39,0,0,0,15,0,0,0,63,0,3,0, 0,0,7,0,0,0,65,0,5,0,17,0,0,0,39,0,0,0,38,0,0,0,16,0,0,0,63,0,3,0,
40,0,0,0,13,0,0,0,65,0,5,0,21,0,0,0,41,0,0,0,39,0,0,0,20,0,0,0,63,0, 39,0,0,0,14,0,0,0,65,0,5,0,21,0,0,0,40,0,0,0,38,0,0,0,20,0,0,0,63,0,
3,0,41,0,0,0,19,0,0,0,65,0,5,0,16,0,0,0,42,0,0,0,39,0,0,0,15,0,0,0, 3,0,40,0,0,0,19,0,0,0,65,0,5,0,17,0,0,0,41,0,0,0,38,0,0,0,16,0,0,0,
61,0,4,0,2,0,0,0,43,0,0,0,42,0,0,0,79,0,8,0,31,0,0,0,44,0,0,0,43,0, 61,0,4,0,2,0,0,0,42,0,0,0,41,0,0,0,79,0,7,0,7,0,0,0,43,0,0,0,42,0,
0,0,43,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,65,0,5,0,45,0,0,0,46,0,0,0, 0,0,42,0,0,0,0,0,0,0,1,0,0,0,65,0,5,0,44,0,0,0,45,0,0,0,10,0,0,0,
9,0,0,0,20,0,0,0,61,0,4,0,2,0,0,0,47,0,0,0,46,0,0,0,79,0,8,0,31,0, 20,0,0,0,61,0,4,0,7,0,0,0,46,0,0,0,45,0,0,0,129,0,5,0,7,0,0,0,47,0,
0,0,48,0,0,0,47,0,0,0,47,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,129,0,5,0, 0,0,43,0,0,0,46,0,0,0,80,0,6,0,2,0,0,0,48,0,0,0,47,0,0,0,30,0,0,0,
31,0,0,0,49,0,0,0,44,0,0,0,48,0,0,0,80,0,5,0,2,0,0,0,50,0,0,0,49,0, 30,0,0,0,62,0,3,0,36,0,0,0,48,0,0,0,65,0,5,0,21,0,0,0,49,0,0,0,38,0,
0,0,32,0,0,0,62,0,3,0,37,0,0,0,50,0,0,0,65,0,5,0,21,0,0,0,51,0,0,0, 0,0,20,0,0,0,61,0,4,0,7,0,0,0,50,0,0,0,49,0,0,0,142,0,5,0,7,0,0,0,
39,0,0,0,20,0,0,0,61,0,4,0,17,0,0,0,52,0,0,0,51,0,0,0,142,0,5,0,17,0, 51,0,0,0,50,0,0,0,31,0,0,0,65,0,5,0,21,0,0,0,52,0,0,0,38,0,0,0,20,0,
0,0,53,0,0,0,52,0,0,0,33,0,0,0,65,0,5,0,21,0,0,0,54,0,0,0,39,0,0,0, 0,0,62,0,3,0,52,0,0,0,51,0,0,0,65,0,5,0,21,0,0,0,53,0,0,0,38,0,0,0,
20,0,0,0,62,0,3,0,54,0,0,0,53,0,0,0,65,0,5,0,21,0,0,0,55,0,0,0,39,0, 20,0,0,0,61,0,4,0,7,0,0,0,54,0,0,0,53,0,0,0,65,0,5,0,21,0,0,0,55,0,
0,0,20,0,0,0,61,0,4,0,17,0,0,0,56,0,0,0,55,0,0,0,65,0,5,0,21,0,0,0, 0,0,37,0,0,0,20,0,0,0,62,0,3,0,55,0,0,0,54,0,0,0,65,0,5,0,56,0,0,0,
57,0,0,0,38,0,0,0,20,0,0,0,62,0,3,0,57,0,0,0,56,0,0,0,65,0,5,0,45,0, 57,0,0,0,10,0,0,0,16,0,0,0,61,0,4,0,2,0,0,0,58,0,0,0,57,0,0,0,65,0,
0,0,58,0,0,0,9,0,0,0,15,0,0,0,61,0,4,0,2,0,0,0,59,0,0,0,58,0,0,0, 5,0,17,0,0,0,59,0,0,0,37,0,0,0,16,0,0,0,62,0,3,0,59,0,0,0,58,0,0,0,
65,0,5,0,16,0,0,0,60,0,0,0,38,0,0,0,15,0,0,0,62,0,3,0,60,0,0,0,59,0, 65,0,5,0,60,0,0,0,61,0,0,0,6,0,0,0,16,0,0,0,61,0,4,0,3,0,0,0,62,0,
0,0,65,0,5,0,61,0,0,0,62,0,0,0,6,0,0,0,15,0,0,0,61,0,4,0,3,0,0,0, 0,0,61,0,0,0,61,0,4,0,2,0,0,0,63,0,0,0,36,0,0,0,145,0,5,0,2,0,0,0,
63,0,0,0,62,0,0,0,61,0,4,0,2,0,0,0,64,0,0,0,37,0,0,0,145,0,5,0,2,0, 64,0,0,0,62,0,0,0,63,0,0,0,65,0,5,0,17,0,0,0,65,0,0,0,37,0,0,0,33,0,
0,0,65,0,0,0,63,0,0,0,64,0,0,0,65,0,5,0,16,0,0,0,66,0,0,0,38,0,0,0, 0,0,62,0,3,0,65,0,0,0,64,0,0,0,61,0,4,0,29,0,0,0,66,0,0,0,37,0,0,0,
30,0,0,0,62,0,3,0,66,0,0,0,65,0,0,0,61,0,4,0,29,0,0,0,67,0,0,0,38,0, 81,0,5,0,2,0,0,0,67,0,0,0,66,0,0,0,0,0,0,0,62,0,3,0,25,0,0,0,67,0,
0,0,81,0,5,0,2,0,0,0,68,0,0,0,67,0,0,0,0,0,0,0,62,0,3,0,25,0,0,0, 0,0,81,0,5,0,7,0,0,0,68,0,0,0,66,0,0,0,1,0,0,0,62,0,3,0,27,0,0,0,
68,0,0,0,81,0,5,0,17,0,0,0,69,0,0,0,67,0,0,0,1,0,0,0,62,0,3,0,27,0, 68,0,0,0,81,0,5,0,2,0,0,0,69,0,0,0,66,0,0,0,2,0,0,0,62,0,3,0,28,0,
0,0,69,0,0,0,81,0,5,0,2,0,0,0,70,0,0,0,67,0,0,0,2,0,0,0,62,0,3,0, 0,0,69,0,0,0,253,0,1,0,56,0,1,0
28,0,0,0,70,0,0,0,253,0,1,0,56,0,1,0

View File

@@ -17,7 +17,7 @@ namespace mlx
{ {
auto it = std::find_if(m_fonts_registry.begin(), m_fonts_registry.end(), [&name, scale](std::shared_ptr<Font> rhs) auto it = std::find_if(m_fonts_registry.begin(), m_fonts_registry.end(), [&name, scale](std::shared_ptr<Font> rhs)
{ {
return name == rhs->GetName() && scale == rhs->GetScale(); return (name == rhs->GetName() && scale == rhs->GetScale());
}); });
return (it != m_fonts_registry.end() ? *it : nullptr); return (it != m_fonts_registry.end() ? *it : nullptr);
} }

View File

@@ -52,10 +52,7 @@ namespace mlx
Internal::WindowInfos* infos = new Internal::WindowInfos; 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(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
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) 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); infos->icon = SDL_CreateRGBSurfaceFrom(static_cast<void*>(logo_mlx), logo_mlx_width, logo_mlx_height, 32, 4 * logo_mlx_width, rmask, gmask, bmask, amask);

View File

@@ -50,17 +50,17 @@ namespace mlx
} }
#ifdef DEBUG #ifdef DEBUG
m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, m_name + "_font_atlas"); m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, m_name + "_font_atlas_" + std::to_string(m_scale));
#else #else
m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, {}); m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, {});
#endif #endif
DebugLog("Font: loaded %", m_name); DebugLog("Font: loaded % with a scale of %", m_name, m_scale);
} }
void Font::Destroy() void Font::Destroy()
{ {
m_atlas.Destroy(); m_atlas.Destroy();
DebugLog("Font: unloaded %", m_name); DebugLog("Font: unloaded % with a scale of %", m_name, m_scale);
} }
} }

View File

@@ -19,13 +19,14 @@ namespace mlx
float stb_x = 0.0f; float stb_x = 0.0f;
float stb_y = 0.0f; float stb_y = 0.0f;
auto char_data = font->GetCharData();
for(char c : text) for(char c : text)
{ {
if(c < 32) if(c < 32)
continue; continue;
stbtt_aligned_quad q; stbtt_aligned_quad q;
stbtt_GetPackedQuad(font->GetCharData().data(), RANGE, RANGE, c - 32, &stb_x, &stb_y, &q, 1); stbtt_GetPackedQuad(char_data.data(), RANGE, RANGE, c - 32, &stb_x, &stb_y, &q, 1);
std::size_t index = vertex_data.size(); std::size_t index = vertex_data.size();

View File

@@ -11,7 +11,7 @@ namespace mlx
struct SpriteData struct SpriteData
{ {
Vec4f color; Vec4f color;
Vec4f position; Vec2f position;
}; };
void Render2DPass::Init() void Render2DPass::Init()
@@ -106,7 +106,7 @@ namespace mlx
for(auto drawable : drawables) for(auto drawable : drawables)
{ {
SpriteData drawable_data; SpriteData drawable_data;
drawable_data.position = Vec4f{ drawable->GetPosition(), 0.0f, 1.0f }; drawable_data.position = drawable->GetPosition();
drawable_data.color = drawable->GetColor(); drawable_data.color = drawable->GetColor();
drawable->Bind(frame_index, cmd); drawable->Bind(frame_index, cmd);