candlewick 0.1.0
A renderer
Loading...
Searching...
No Matches
Texture.h
Go to the documentation of this file.
1#pragma once
2
3#include "Core.h"
4#include "Tags.h"
5#include <SDL3/SDL_gpu.h>
6
7namespace candlewick {
8
9class Texture {
10 SDL_GPUDevice *_device = nullptr;
11 SDL_GPUTexture *_texture = nullptr;
12 SDL_GPUTextureCreateInfo _description;
13
14public:
16 Texture(const Device &device, SDL_GPUTextureCreateInfo texture_desc,
17 const char *name = nullptr);
18
19 Texture(const Texture &) = delete;
20 Texture &operator=(const Texture &) = delete;
21 Texture(Texture &&other) noexcept;
22 Texture &operator=(Texture &&other) noexcept;
23
24 operator SDL_GPUTexture *() const noexcept { return _texture; }
25
26 bool hasValue() const { return bool(_texture); }
27 const auto &description() const { return _description; }
28 SDL_GPUTextureType type() const { return _description.type; }
29 SDL_GPUTextureFormat format() const { return _description.format; }
30 SDL_GPUTextureUsageFlags usage() const { return _description.usage; }
31 Uint32 width() const { return _description.width; }
32 Uint32 height() const { return _description.height; }
33 Uint32 depth() const { return _description.layer_count_or_depth; }
34 Uint32 layerCount() const { return _description.layer_count_or_depth; }
35
36 SDL_GPUBlitRegion blitRegion(Uint32 offset_x, Uint32 y_offset,
37 Uint32 layer_or_depth_plane = 0) const;
38
39 Uint32 textureSize() const;
40
41 void destroy() noexcept;
42 ~Texture() noexcept { this->destroy(); }
43};
44
45} // namespace candlewick
SDL_GPUTextureFormat format() const
Definition Texture.h:29
Texture(Texture &&other) noexcept
SDL_GPUBlitRegion blitRegion(Uint32 offset_x, Uint32 y_offset, Uint32 layer_or_depth_plane=0) const
Texture(const Texture &)=delete
Uint32 depth() const
Definition Texture.h:33
SDL_GPUTextureType type() const
Definition Texture.h:28
Texture(NoInitT)
Definition Texture.h:15
Texture & operator=(const Texture &)=delete
Uint32 textureSize() const
Uint32 height() const
Definition Texture.h:32
bool hasValue() const
Definition Texture.h:26
Texture(const Device &device, SDL_GPUTextureCreateInfo texture_desc, const char *name=nullptr)
SDL_GPUTextureUsageFlags usage() const
Definition Texture.h:30
void destroy() noexcept
Uint32 layerCount() const
Definition Texture.h:34
Texture & operator=(Texture &&other) noexcept
Uint32 width() const
Definition Texture.h:31
const auto & description() const
Definition Texture.h:27
Definition Camera.h:8
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6