MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_texture_resource.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_TEXTURE_RESOURCE_H_1607408595
12#define INCGUARD_MGL_TEXTURE_RESOURCE_H_1607408595
13
14#include <atomic>
15#include <cstdint>
16#include <memory>
17
20
21namespace MGL::Render
22{
25{
26public:
27 /* ------------------------------------------------------------------------- */
31 /* ------------------------------------------------------------------------- */
32 constexpr TextureResource() noexcept
33 : _isLoading(false)
34 {
35 }
36
37 /* ------------------------------------------------------------------------- */
41 /* ------------------------------------------------------------------------- */
42 virtual ~TextureResource() noexcept = default;
43
44 /* ------------------------------------------------------------------------- */
49 /* ------------------------------------------------------------------------- */
50 [[nodiscard]] virtual RendererType GetRendererType() const noexcept = 0;
51
52 /* ------------------------------------------------------------------------- */
58 /* ------------------------------------------------------------------------- */
59 [[nodiscard]] virtual bool IsValid() const noexcept = 0;
60
61 /* ------------------------------------------------------------------------- */
67 /* ------------------------------------------------------------------------- */
68 [[nodiscard]] virtual bool IsRenderTarget() const noexcept = 0;
69
70 /* ------------------------------------------------------------------------- */
80 /* ------------------------------------------------------------------------- */
81 virtual bool Create(const void *pixelData, PixelFormat pixelFormat, uint32_t width, uint32_t height) noexcept = 0;
82
83 /* ------------------------------------------------------------------------- */
91 /* ------------------------------------------------------------------------- */
92 virtual bool CreateRenderTarget(uint32_t width, uint32_t height) noexcept = 0;
93
94 /* ------------------------------------------------------------------------- */
98 /* ------------------------------------------------------------------------- */
99 virtual void Destroy() noexcept = 0;
100
101 /* ------------------------------------------------------------------------- */
106 /* ------------------------------------------------------------------------- */
107 [[nodiscard]] virtual Vector2 GetSize() const noexcept = 0;
108
109 /* ------------------------------------------------------------------------- */
114 /* ------------------------------------------------------------------------- */
115 [[nodiscard]] virtual PixelFormat GetPixelFormat() const noexcept = 0;
116
117 /* ------------------------------------------------------------------------- */
123 /* ------------------------------------------------------------------------- */
124 [[nodiscard]] bool IsLoading() const noexcept
125 {
126 return _isLoading;
127 }
128
129 /* ------------------------------------------------------------------------- */
134 /* ------------------------------------------------------------------------- */
135 void SetLoading(bool isLoading) noexcept
136 {
137 _isLoading = isLoading;
138 }
139
140private:
141 std::atomic<bool> _isLoading;
142};
143
145using SharedTextureResource = std::shared_ptr<MGL::Render::TextureResource>;
146
147} // namespace MGL::Render
148#endif // INCGUARD_MGL_TEXTURE_RESOURCE_H_1607408595
149
150// vim: et ts=4 sw=4 sts=4
テクスチャリソース
Definition mgl_texture_resource.h:25
virtual bool Create(const void *pixelData, PixelFormat pixelFormat, uint32_t width, uint32_t height) noexcept=0
テクスチャの生成
bool IsLoading() const noexcept
読み込み中かを取得
Definition mgl_texture_resource.h:124
virtual bool IsValid() const noexcept=0
有効状態の取得
virtual PixelFormat GetPixelFormat() const noexcept=0
テクスチャのピクセルフォーマットを取得
virtual ~TextureResource() noexcept=default
デストラクタ
virtual Vector2 GetSize() const noexcept=0
テクスチャのサイズを取得
virtual void Destroy() noexcept=0
リソースの破棄
void SetLoading(bool isLoading) noexcept
読み込み中かを設定
Definition mgl_texture_resource.h:135
virtual bool IsRenderTarget() const noexcept=0
レンダーターゲットに設定可能かを取得
virtual bool CreateRenderTarget(uint32_t width, uint32_t height) noexcept=0
レンダーターゲットの生成
constexpr TextureResource() noexcept
コンストラクタ
Definition mgl_texture_resource.h:32
virtual RendererType GetRendererType() const noexcept=0
リソースがどのレンダラ用のものかを返す
MGL 描画関連の定義
RendererType
レンダラタイプの型
Definition mgl_render_types.h:21
PixelFormat
ピクセルフォーマット
Definition mgl_render_types.h:37
std::shared_ptr< MGL::Render::TextureResource > SharedTextureResource
共有するテクスチャリソースの型
Definition mgl_texture_resource.h:145
MGL 2Dベクトル
2Dベクトル
Definition mgl_vector2.h:23