mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 23:23:34 +00:00
working
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* texture.h :+: :+: :+: */
|
||||
/* Texture.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/08 02:24:58 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/25 19:09:56 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/28 22:11:21 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_TEXTURE__
|
||||
#define __MLX_TEXTURE__
|
||||
|
||||
#include <renderer/images/vk_image.h>
|
||||
#include <renderer/descriptors/vk_descriptor_set.h>
|
||||
#include <renderer/buffers/vk_ibo.h>
|
||||
#include <renderer/buffers/vk_vbo.h>
|
||||
#include <Renderer/Images/Image.h>
|
||||
#include <Renderer/Descriptors/DescriptorSet.h>
|
||||
#include <Renderer/Buffers/IndexBuffer.h>
|
||||
#include <Renderer/Buffers/VertexBuffer.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -25,39 +25,39 @@ namespace mlx
|
||||
public:
|
||||
Texture() = default;
|
||||
|
||||
void create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false);
|
||||
void render(std::array<VkDescriptorSet, 2>& sets, class Renderer& renderer, int x, int y);
|
||||
void destroy() noexcept override;
|
||||
void Create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false);
|
||||
void Render(std::array<VkDescriptorSet, 2>& sets, class Renderer& renderer, int x, int y);
|
||||
void Destroy() noexcept override;
|
||||
|
||||
void setPixel(int x, int y, std::uint32_t color) noexcept;
|
||||
int getPixel(int x, int y) noexcept;
|
||||
void SetPixel(int x, int y, std::uint32_t color) noexcept;
|
||||
int GetPixel(int x, int y) noexcept;
|
||||
|
||||
inline void setDescriptor(DescriptorSet&& set) noexcept { _set = set; }
|
||||
inline VkDescriptorSet getSet() noexcept { return _set.isInit() ? _set.get() : VK_NULL_HANDLE; }
|
||||
inline void updateSet(int binding) noexcept { _set.writeDescriptor(binding, *this); _has_set_been_updated = true; }
|
||||
inline bool hasBeenUpdated() const noexcept { return _has_set_been_updated; }
|
||||
inline constexpr void resetUpdate() noexcept { _has_set_been_updated = false; }
|
||||
inline void SetDescriptor(DescriptorSet&& set) noexcept { m_set = set; }
|
||||
inline VkDescriptorSet GetSet() noexcept { return m_set.isInit() ? m_set.get() : VK_NULL_HANDLE; }
|
||||
inline void UpdateSet(int binding) noexcept { m_set.writeDescriptor(binding, *this); m_has_set_been_updated = true; }
|
||||
inline bool HasBeenUpdated() const noexcept { return m_has_set_been_updated; }
|
||||
inline constexpr void ResetUpdate() noexcept { m_has_set_been_updated = false; }
|
||||
|
||||
~Texture() = default;
|
||||
|
||||
private:
|
||||
void openCPUmap();
|
||||
void OpenCPUmap();
|
||||
|
||||
private:
|
||||
C_VBO _vbo;
|
||||
C_IBO _ibo;
|
||||
ConstantVertexBuffer m_vbo;
|
||||
ConstantIndexBuffer m_ibo;
|
||||
#ifdef DEBUG
|
||||
std::string _name;
|
||||
std::string m_name;
|
||||
#endif
|
||||
DescriptorSet _set;
|
||||
std::vector<std::uint32_t> _cpu_map;
|
||||
std::optional<Buffer> _buf_map = std::nullopt;
|
||||
void* _map = nullptr;
|
||||
bool _has_been_modified = false;
|
||||
bool _has_set_been_updated = false;
|
||||
DescriptorSet m_set;
|
||||
std::vector<std::uint32_t> m_cpu_map;
|
||||
std::optional<Buffer> m_buf_map = std::nullopt;
|
||||
void* m_map = nullptr;
|
||||
bool m_has_been_modified = false;
|
||||
bool m_has_set_been_updated = false;
|
||||
};
|
||||
|
||||
Texture stbTextureLoad(std::filesystem::path file, int* w, int* h);
|
||||
Texture StbTextureLoad(std::filesystem::path file, int* w, int* h);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user