MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_d3d11_texture_resource.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_D3D11_TEXTURE_RESOURCE_H_1614592401
12#define INCGUARD_MGL_D3D11_TEXTURE_RESOURCE_H_1614592401
13
14#include <mgl/mgl_environment.h>
15#if defined(MGL_RENDERER_ENABLE_D3D11)
16
19#include <d3d11_1.h>
20#include <atlbase.h>
21
22namespace MGL::Render::D3D11
23{
26{
27public:
28 TextureResource(bool isMainRenderTarget = false) noexcept;
29
30 /* ------------------------------------------------------------------------- */
35 /* ------------------------------------------------------------------------- */
36 virtual RendererType GetRendererType() const noexcept override
37 {
39 }
40
41 /* ------------------------------------------------------------------------- */
47 /* ------------------------------------------------------------------------- */
48 virtual bool IsValid() const noexcept override
49 {
50 return _isMainRenderTarget || (_texture != nullptr);
51 }
52
53 /* ------------------------------------------------------------------------- */
59 /* ------------------------------------------------------------------------- */
60 virtual bool IsRenderTarget() const noexcept override
61 {
62 return _isMainRenderTarget || (_renderTargetView != nullptr);
63 }
64
65 virtual bool Create(const void *pixelData, PixelFormat pixelFormat, uint32_t width, uint32_t height) noexcept override;
66 virtual bool CreateRenderTarget(uint32_t width, uint32_t height) noexcept override;
67 virtual void Destroy() noexcept override;
68
69 virtual Vector2 GetSize() const noexcept override;
70 virtual PixelFormat GetPixelFormat() const noexcept override;
71
72 /* ------------------------------------------------------------------------- */
77 /* ------------------------------------------------------------------------- */
78 ID3D11RenderTargetView *GetRenderTargetView() noexcept
79 {
80 return _renderTargetView.p;
81 }
82
83 /* ------------------------------------------------------------------------- */
88 /* ------------------------------------------------------------------------- */
89 ID3D11ShaderResourceView *GetShaderResourceView() noexcept
90 {
91 return _shaderResourceView.p;
92 }
93
94 ID3D11Buffer *GetOrthogonalMatrixBuffer() const noexcept;
95
96private:
97 DXGI_FORMAT GetDXPixelFormat(PixelFormat pixelFormat) const noexcept;
98 PixelFormat GetPixelFormat(DXGI_FORMAT dxPixelFormat) const noexcept;
99
100 bool _isMainRenderTarget;
101
102 CComPtr<ID3D11Texture2D> _texture;
103 CComPtr<ID3D11ShaderResourceView> _shaderResourceView;
104 CComPtr<ID3D11RenderTargetView> _renderTargetView;
105 CComPtr<ID3D11Buffer> _orthogonalMatrixBuffer;
106
107 uint32_t _width;
108 uint32_t _height;
109
110 PixelFormat _pixelFormat;
111};
112} // namespace MGL::Render::D3D11
113
114#endif // MGL_RENDERER_ENABLE_D3D11
115#endif // INCGUARD_MGL_D3D11_TEXTURE_RESOURCE_H_1614592401
116
117// vim: et ts=4 sw=4 sts=4
MGL Direct3D11用テクスチャリソース
Definition mgl_d3d11_texture_resource.h:26
virtual RendererType GetRendererType() const noexcept override
リソースがどのレンダラ用のものかを返す
Definition mgl_d3d11_texture_resource.h:36
ID3D11ShaderResourceView * GetShaderResourceView() noexcept
シェーダリソースビューの取得
Definition mgl_d3d11_texture_resource.h:89
ID3D11RenderTargetView * GetRenderTargetView() noexcept
レンダーターゲットビューの取得
Definition mgl_d3d11_texture_resource.h:78
virtual bool IsRenderTarget() const noexcept override
レンダーターゲットに設定可能かを取得
Definition mgl_d3d11_texture_resource.h:60
virtual bool Create(const void *pixelData, PixelFormat pixelFormat, uint32_t width, uint32_t height) noexcept override
テクスチャの生成
Definition mgl_d3d11_texture_resource.cc:49
virtual Vector2 GetSize() const noexcept override
テクスチャのサイズを取得  *
Definition mgl_d3d11_texture_resource.cc:218
virtual PixelFormat GetPixelFormat() const noexcept override
テクスチャのピクセルフォーマットを取得
Definition mgl_d3d11_texture_resource.cc:235
virtual void Destroy() noexcept override
リソースの破棄
Definition mgl_d3d11_texture_resource.cc:201
virtual bool IsValid() const noexcept override
有効状態の取得
Definition mgl_d3d11_texture_resource.h:48
ID3D11Buffer * GetOrthogonalMatrixBuffer() const noexcept
平行投影行列のバッファを取得
Definition mgl_d3d11_texture_resource.cc:329
virtual bool CreateRenderTarget(uint32_t width, uint32_t height) noexcept override
レンダーターゲットの生成
Definition mgl_d3d11_texture_resource.cc:118
テクスチャリソース
Definition mgl_texture_resource.h:25
constexpr TextureResource() noexcept
コンストラクタ
Definition mgl_texture_resource.h:32
MGL Direct3D11用定義
constexpr auto kRendererTypeDirect3D11
Direct3D11用のレンダラタイプを表す値
Definition mgl_d3d11_defs.h:19
MGL 環境定義
RendererType
レンダラタイプの型
Definition mgl_render_types.h:21
PixelFormat
ピクセルフォーマット
Definition mgl_render_types.h:37
MGL テクスチャリソース
2Dベクトル
Definition mgl_vector2.h:23