le2d v0.4.6
2D game engine framework
 
Loading...
Searching...
No Matches
texture.hpp
Go to the documentation of this file.
1#pragma once
4#include <kvf/bitmap.hpp>
5#include <kvf/render_device_fwd.hpp>
6#include <kvf/vma.hpp>
7#include <gsl/pointers>
8
9namespace kvf {
10class RenderPass;
11} // namespace kvf
12
13namespace le {
15class ITextureBase : public IResource {
16 public:
17 [[nodiscard]] virtual auto get_image() const -> vk::ImageView = 0;
18 [[nodiscard]] virtual auto get_size() const -> glm::ivec2 = 0;
19
20 [[nodiscard]] virtual auto descriptor_info() const -> vk::DescriptorImageInfo = 0;
21};
22
25 vk::SamplerAddressMode wrap{vk::SamplerAddressMode::eClampToEdge};
26 vk::Filter filter{vk::Filter::eLinear};
27 vk::BorderColor border{vk::BorderColor::eIntOpaqueBlack};
28};
29
31class ITexture : public ITextureBase {
32 public:
35 virtual void overwrite(kvf::Bitmap const& bitmap) = 0;
39 virtual auto load_and_write(std::span<std::byte const> compressed_image) -> bool = 0;
40};
41
43class ITileSheet : public ITexture {
44 public:
48 [[nodiscard]] auto get_uv(TileId const id) const -> kvf::UvRect { return tile_set.get_uv(id); }
49
50 TileSet tile_set{};
51};
52
56 public:
58 explicit RenderTexture(gsl::not_null<kvf::RenderPass const*> render_pass);
59
60 [[nodiscard]] auto is_ready() const -> bool final;
61
62 [[nodiscard]] auto get_image() const -> vk::ImageView final;
63 [[nodiscard]] auto get_size() const -> glm::ivec2 final;
64
65 [[nodiscard]] auto descriptor_info() const -> vk::DescriptorImageInfo final;
66
67 private:
68 gsl::not_null<kvf::RenderPass const*> m_render_pass;
69};
70} // namespace le
Interface for all shared resources in the engine.
Definition resource.hpp:6
Interface for drawable texture.
Definition texture.hpp:15
virtual auto descriptor_info() const -> vk::DescriptorImageInfo=0
virtual auto get_size() const -> glm::ivec2=0
virtual auto get_image() const -> vk::ImageView=0
Concrete drawable Texture.
Definition texture.hpp:31
virtual void overwrite(kvf::Bitmap const &bitmap)=0
Write bitmap to image.
virtual auto load_and_write(std::span< std::byte const > compressed_image) -> bool=0
Load a compressed bitmap and write to image.
Texture with a TileSet.
Definition texture.hpp:43
auto get_uv(TileId const id) const -> kvf::UvRect
Get the UV coordinates for a given Tile ID.
Definition texture.hpp:48
Wraps a RenderTarget as a texture.
Definition texture.hpp:55
RenderTexture(gsl::not_null< kvf::RenderPass const * > render_pass)
auto is_ready() const -> bool final
Check if resource is ready to use.
Sorted set of Tiles.
Definition tile_set.hpp:9
Definition texture.hpp:9
Definition animation.hpp:8
TileId
Unique identifier for a Tile.
Definition tile_id.hpp:6
Texture Sampler metadata.
Definition texture.hpp:24