mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
yes
This commit is contained in:
@@ -44,11 +44,11 @@ namespace mlx
|
||||
std::shared_ptr<Window> p_window;
|
||||
std::unique_ptr<Scene> p_scene;
|
||||
|
||||
std::uint64_t m_current_depth = 0;
|
||||
|
||||
int m_id;
|
||||
|
||||
bool m_has_window;
|
||||
|
||||
bool m_insert_new_pixel_put_texture = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <Core/Graphics.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -9,20 +8,19 @@ namespace mlx
|
||||
MLX_PROFILE_FUNCTION();
|
||||
p_scene->ResetSprites();
|
||||
m_put_pixel_manager.ResetRenderData();
|
||||
m_current_depth = 0;
|
||||
m_insert_new_pixel_put_texture = true;
|
||||
}
|
||||
|
||||
void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
/*
|
||||
NonOwningPtr<Texture> texture = m_put_pixel_manager.DrawPixel(x, y, m_current_depth, color);
|
||||
NonOwningPtr<Texture> texture = m_put_pixel_manager.DrawPixel(x, y, m_insert_new_pixel_put_texture, color);
|
||||
if(texture)
|
||||
{
|
||||
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
||||
new_sprite.SetPosition(Vec3f{ 0.0f, 0.0f, static_cast<float>(m_current_depth) });
|
||||
new_sprite.SetPosition(Vec2f{ 0.0f, 0.0f });
|
||||
}
|
||||
*/
|
||||
m_insert_new_pixel_put_texture = false;
|
||||
}
|
||||
|
||||
void GraphicsSupport::StringPut(int x, int y, std::uint32_t color, std::string str)
|
||||
@@ -41,11 +39,11 @@ namespace mlx
|
||||
if(!sprite)
|
||||
{
|
||||
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
||||
new_sprite.SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
|
||||
m_current_depth++;
|
||||
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||
m_insert_new_pixel_put_texture = true;
|
||||
}
|
||||
else
|
||||
sprite->SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
|
||||
p_scene->BringToFront(std::move(sprite));
|
||||
}
|
||||
|
||||
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
3,2,35,7,0,0,1,0,39,0,0,0,51,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,48,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,8,0,4,0,0,0,28,0,0,0,109,97,105,110,0,0,0,0,
|
||||
10,0,0,0,16,0,0,0,22,0,0,0,16,0,3,0,28,0,0,0,7,0,0,0,3,0,3,0,0,0,
|
||||
0,0,100,0,0,0,5,0,4,0,19,0,0,0,86,101,114,116,79,117,116,0,6,0,5,0,19,0,0,0,
|
||||
@@ -29,16 +29,14 @@
|
||||
7,0,0,0,248,0,2,0,29,0,0,0,59,0,4,0,24,0,0,0,30,0,0,0,7,0,0,0,59,0,
|
||||
4,0,20,0,0,0,31,0,0,0,7,0,0,0,65,0,5,0,13,0,0,0,32,0,0,0,31,0,0,0,
|
||||
12,0,0,0,63,0,3,0,32,0,0,0,10,0,0,0,65,0,5,0,18,0,0,0,33,0,0,0,31,0,
|
||||
0,0,17,0,0,0,63,0,3,0,33,0,0,0,16,0,0,0,65,0,5,0,13,0,0,0,34,0,0,0,
|
||||
31,0,0,0,12,0,0,0,61,0,4,0,8,0,0,0,35,0,0,0,34,0,0,0,61,0,4,0,3,0,
|
||||
0,0,36,0,0,0,5,0,0,0,65,0,5,0,18,0,0,0,37,0,0,0,31,0,0,0,17,0,0,0,
|
||||
61,0,4,0,14,0,0,0,38,0,0,0,37,0,0,0,87,0,5,0,8,0,0,0,39,0,0,0,36,0,
|
||||
0,0,38,0,0,0,133,0,5,0,8,0,0,0,40,0,0,0,35,0,0,0,39,0,0,0,65,0,5,0,
|
||||
13,0,0,0,41,0,0,0,30,0,0,0,12,0,0,0,62,0,3,0,41,0,0,0,40,0,0,0,65,0,
|
||||
5,0,13,0,0,0,45,0,0,0,30,0,0,0,12,0,0,0,61,0,4,0,8,0,0,0,46,0,0,0,
|
||||
45,0,0,0,81,0,5,0,1,0,0,0,47,0,0,0,46,0,0,0,3,0,0,0,180,0,5,0,27,0,
|
||||
0,0,48,0,0,0,47,0,0,0,26,0,0,0,247,0,3,0,42,0,0,0,0,0,0,0,250,0,4,0,
|
||||
48,0,0,0,43,0,0,0,44,0,0,0,248,0,2,0,43,0,0,0,252,0,1,0,248,0,2,0,44,0,
|
||||
0,0,249,0,2,0,42,0,0,0,248,0,2,0,42,0,0,0,61,0,4,0,23,0,0,0,49,0,0,0,
|
||||
30,0,0,0,81,0,5,0,8,0,0,0,50,0,0,0,49,0,0,0,0,0,0,0,62,0,3,0,22,0,
|
||||
0,0,50,0,0,0,253,0,1,0,56,0,1,0
|
||||
0,0,17,0,0,0,63,0,3,0,33,0,0,0,16,0,0,0,61,0,4,0,3,0,0,0,34,0,0,0,
|
||||
5,0,0,0,65,0,5,0,18,0,0,0,35,0,0,0,31,0,0,0,17,0,0,0,61,0,4,0,14,0,
|
||||
0,0,36,0,0,0,35,0,0,0,87,0,5,0,8,0,0,0,37,0,0,0,34,0,0,0,36,0,0,0,
|
||||
65,0,5,0,13,0,0,0,38,0,0,0,30,0,0,0,12,0,0,0,62,0,3,0,38,0,0,0,37,0,
|
||||
0,0,65,0,5,0,13,0,0,0,42,0,0,0,30,0,0,0,12,0,0,0,61,0,4,0,8,0,0,0,
|
||||
43,0,0,0,42,0,0,0,81,0,5,0,1,0,0,0,44,0,0,0,43,0,0,0,3,0,0,0,180,0,
|
||||
5,0,27,0,0,0,45,0,0,0,44,0,0,0,26,0,0,0,247,0,3,0,39,0,0,0,0,0,0,0,
|
||||
250,0,4,0,45,0,0,0,40,0,0,0,41,0,0,0,248,0,2,0,40,0,0,0,252,0,1,0,248,0,
|
||||
2,0,41,0,0,0,249,0,2,0,39,0,0,0,248,0,2,0,39,0,0,0,61,0,4,0,23,0,0,0,
|
||||
46,0,0,0,30,0,0,0,81,0,5,0,8,0,0,0,47,0,0,0,46,0,0,0,0,0,0,0,62,0,
|
||||
3,0,22,0,0,0,47,0,0,0,253,0,1,0,56,0,1,0
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace mlx
|
||||
PutPixelManager(NonOwningPtr<class Renderer> renderer) : p_renderer(renderer) {}
|
||||
|
||||
// Return a valid pointer when a new texture has been created
|
||||
NonOwningPtr<Texture> DrawPixel(int x, int y, std::uint64_t z, std::uint32_t color);
|
||||
NonOwningPtr<Texture> DrawPixel(int x, int y, bool insert_new_texture, std::uint32_t color);
|
||||
void ResetRenderData();
|
||||
|
||||
~PutPixelManager();
|
||||
|
||||
private:
|
||||
std::map<std::uint64_t, Texture> m_textures;
|
||||
std::list<Texture> m_textures;
|
||||
NonOwningPtr<class Renderer> p_renderer;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,21 +20,20 @@ namespace mlx
|
||||
|
||||
Sprite& CreateSprite(NonOwningPtr<class Texture> texture) noexcept;
|
||||
NonOwningPtr<Sprite> GetSpriteFromTextureAndPosition(NonOwningPtr<Texture> texture, const Vec2f& position) const;
|
||||
void BringToFront(NonOwningPtr<Sprite> sprite);
|
||||
void TryEraseSpriteFromTexture(NonOwningPtr<Texture> texture);
|
||||
|
||||
inline void ResetSprites() { m_sprites.clear(); }
|
||||
|
||||
[[nodiscard]] MLX_FORCEINLINE const std::vector<std::shared_ptr<Sprite>>& GetSprites() const noexcept { return m_sprites; }
|
||||
[[nodiscard]] MLX_FORCEINLINE const SceneDescriptor& GetDescription() const noexcept { return m_descriptor; }
|
||||
[[nodiscard]] MLX_FORCEINLINE DepthImage& GetDepth() noexcept { return m_depth; }
|
||||
[[nodiscard]] MLX_FORCEINLINE ViewerData& GetViewerData() noexcept { return m_viewer_data; }
|
||||
|
||||
~Scene();
|
||||
~Scene() = default;
|
||||
|
||||
private:
|
||||
SceneDescriptor m_descriptor;
|
||||
std::vector<std::shared_ptr<Sprite>> m_sprites;
|
||||
DepthImage m_depth;
|
||||
ViewerData m_viewer_data;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace mlx
|
||||
Sprite(class Renderer& renderer, NonOwningPtr<Texture> texture);
|
||||
|
||||
inline void SetColor(Vec4f color) noexcept { m_color = color; }
|
||||
inline void SetPosition(Vec3f position) noexcept { m_position = position; }
|
||||
inline void SetPosition(Vec2f position) noexcept { m_position = position; }
|
||||
|
||||
[[nodiscard]] MLX_FORCEINLINE const Vec4f& GetColor() const noexcept { return m_color; }
|
||||
[[nodiscard]] MLX_FORCEINLINE const Vec3f& GetPosition() const noexcept { return m_position; }
|
||||
[[nodiscard]] MLX_FORCEINLINE const Vec2f& GetPosition() const noexcept { return m_position; }
|
||||
[[nodiscard]] MLX_FORCEINLINE std::shared_ptr<Mesh> GetMesh() const { return p_mesh; }
|
||||
[[nodiscard]] MLX_FORCEINLINE NonOwningPtr<Texture> GetTexture() const { return p_texture; }
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace mlx
|
||||
NonOwningPtr<Texture> p_texture;
|
||||
std::shared_ptr<Mesh> p_mesh;
|
||||
Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
Vec3f m_position = Vec3f{ 0.0f, 0.0f, 0.0f };
|
||||
Vec2f m_position = Vec2f{ 0.0f, 0.0f };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <string_view>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
#include <ranges>
|
||||
|
||||
#ifndef MLX_PLAT_WINDOWS
|
||||
#include <dlfcn.h>
|
||||
|
||||
@@ -67,22 +67,6 @@ namespace mlx
|
||||
bool m_is_multisampled = false;
|
||||
};
|
||||
|
||||
class DepthImage : public Image
|
||||
{
|
||||
public:
|
||||
DepthImage() = default;
|
||||
inline void Init(std::uint32_t width, std::uint32_t height, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
std::vector<VkFormat> candidates = { VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT };
|
||||
VkFormat format = kvfFindSupportFormatInCandidates(RenderCore::Get().GetDevice(), candidates.data(), candidates.size(), VK_IMAGE_TILING_OPTIMAL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
||||
Image::Init(ImageType::Depth, width, height, format, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, is_multisampled, std::move(debug_name));
|
||||
Image::CreateImageView(VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
Image::TransitionLayout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
}
|
||||
~DepthImage() = default;
|
||||
};
|
||||
|
||||
class Texture : public Image
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace mlx
|
||||
std::shared_ptr<Shader> fragment_shader;
|
||||
std::vector<NonOwningPtr<Texture>> color_attachments;
|
||||
NonOwningPtr<class Renderer> renderer = nullptr;
|
||||
NonOwningPtr<DepthImage> depth = nullptr;
|
||||
bool clear_color_attachments = true;
|
||||
bool no_vertex_inputs = false;
|
||||
};
|
||||
@@ -55,7 +54,6 @@ namespace mlx
|
||||
VkPipeline m_pipeline = VK_NULL_HANDLE;
|
||||
VkPipelineLayout m_pipeline_layout = VK_NULL_HANDLE;
|
||||
NonOwningPtr<class Renderer> p_renderer;
|
||||
NonOwningPtr<DepthImage> p_depth;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user