MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_d3d11_renderer_2d.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_D3D11_RENDERER_2D_H_1614581032
12#define INCGUARD_MGL_D3D11_RENDERER_2D_H_1614581032
13
14#include <mgl/mgl_environment.h>
15#if defined(MGL_RENDERER_ENABLE_D3D11)
16
17#include <atlbase.h>
18#include <d3d11_1.h>
26
27namespace MGL::Render::D3D11
28{
31{
32public:
33 Renderer2D() noexcept;
34
35 /* ------------------------------------------------------------------------- */
40 /* ------------------------------------------------------------------------- */
41 virtual RendererType GetRendererType() const noexcept override
42 {
44 }
45
46 virtual bool CanInitialize() const noexcept override;
47 virtual bool Initialize() noexcept override;
48
49 virtual void Flush() noexcept override;
50 virtual void Clear(const Color &color) noexcept override;
51
52 virtual void DrawLine(const Vector2 &start, const Vector2 &end, const Color &color) noexcept override;
53 virtual void DrawRectangle(const Rectangle &rectangle, const Color &color, const DrawOption2D &option = DrawOption2D()) noexcept override;
54 virtual void DrawSprite(
55 const Vector2 &position,
56 SharedTextureResource textureResource,
57 const Rectangle &sourceRectangle,
58 const DrawOption2D &option = DrawOption2D()) noexcept override;
59
60 virtual bool SetRenderTarget(SharedTextureResource renderTarget) noexcept override;
61 virtual SharedTextureResource GetRenderTarget() const noexcept override;
62 virtual SharedTextureResource GetMainRenderTarget() const noexcept override;
63
64 virtual void SetScissor(bool isEnabled, const Rectangle &rectangle = Rectangle()) noexcept override;
65 virtual bool IsEnabledScissor() const noexcept override;
66 virtual Rectangle GetScissorRectangle() const noexcept override;
67
68private:
69 bool InitializeRasterizerState() noexcept;
70 bool InitializeBlendState() noexcept;
71
72 ObjectRenderer::FlushParameter GetFlushParameter() noexcept;
73 ID3D11Buffer *GetOrthogonalMatrixBuffer() const noexcept;
74
75 void ChangeObjectRenderer(ObjectRenderer *objectRenderer) noexcept;
76
77 void ApplyAnchor(float *offset, const Vector2 &size, const DrawOption2D &option) const noexcept;
78
79 CComPtr<ID3D11RasterizerState> _mainRasterizerState;
80 CComPtr<ID3D11RasterizerState> _clippedRasterizerState;
81 CComPtr<ID3D11BlendState> _blendState;
82
83 bool _isEnabledScissor;
84 Rectangle _scissorRectangle;
85
86 SharedTextureResource _mainRenderTarget;
87 SharedTextureResource _currentRenderTarget;
88
89 ObjectRenderer *_currentObjectRenderer;
90 LineRenderer _lineRenderer;
91 RectangleRenderer _rectangleRenderer;
92 SpriteRenderer _spriteRenderer;
93};
94} // namespace MGL::Render::D3D11
95
96#endif // MGL_RENDERER_ENABLE_D3D11
97#endif // INCGUARD_MGL_D3D11_RENDERER_2D_H_1614581032
98
99// vim: et ts=4 sw=4 sts=4
Direct3D11用ラインレンダラ
Definition mgl_d3d11_line_renderer.h:29
Direct3D11用オブジェクトレンダラ基底クラス
Definition mgl_d3d11_object_renderer.h:23
Direct3D11用矩形レンダラ
Definition mgl_d3d11_rectangle_renderer.h:27
MGL Direct3D11 2Dレンダラ
Definition mgl_d3d11_renderer_2d.h:31
virtual void DrawSprite(const Vector2 &position, SharedTextureResource textureResource, const Rectangle &sourceRectangle, const DrawOption2D &option=DrawOption2D()) noexcept override
スプライトの描画
Definition mgl_d3d11_renderer_2d.cc:203
virtual void DrawRectangle(const Rectangle &rectangle, const Color &color, const DrawOption2D &option=DrawOption2D()) noexcept override
矩形の描画
Definition mgl_d3d11_renderer_2d.cc:153
virtual void SetScissor(bool isEnabled, const Rectangle &rectangle=Rectangle()) noexcept override
シザーを設定
Definition mgl_d3d11_renderer_2d.cc:355
virtual void Flush() noexcept override
描画の実行
Definition mgl_d3d11_renderer_2d.cc:110
virtual void Clear(const Color &color) noexcept override
描画領域のクリア
Definition mgl_d3d11_renderer_2d.cc:122
virtual SharedTextureResource GetMainRenderTarget() const noexcept override
メインレンダーターゲットを取得
Definition mgl_d3d11_renderer_2d.cc:342
virtual bool IsEnabledScissor() const noexcept override
シザーが有効かどうかを取得
Definition mgl_d3d11_renderer_2d.cc:408
virtual SharedTextureResource GetRenderTarget() const noexcept override
現在のレンダーターゲットを取得
Definition mgl_d3d11_renderer_2d.cc:330
virtual void DrawLine(const Vector2 &start, const Vector2 &end, const Color &color) noexcept override
ラインの描画
Definition mgl_d3d11_renderer_2d.cc:136
virtual bool CanInitialize() const noexcept override
レンダラが初期化可能な状態かを取得
Definition mgl_d3d11_renderer_2d.cc:47
virtual bool SetRenderTarget(SharedTextureResource renderTarget) noexcept override
レンダーターゲットの設定
Definition mgl_d3d11_renderer_2d.cc:290
virtual RendererType GetRendererType() const noexcept override
レンダラタイプを取得
Definition mgl_d3d11_renderer_2d.h:41
Renderer2D() noexcept
コンストラクタ
Definition mgl_d3d11_renderer_2d.cc:24
virtual bool Initialize() noexcept override
初期化処理
Definition mgl_d3d11_renderer_2d.cc:60
virtual Rectangle GetScissorRectangle() const noexcept override
シザー矩形を取得
Definition mgl_d3d11_renderer_2d.cc:420
Direct3D11用スプライトレンダラ
Definition mgl_d3d11_sprite_renderer.h:28
2D描画オプション
Definition mgl_draw_option_2d.h:23
MGL 2Dレンダラデリゲート
Definition mgl_renderer_2d_delegate.h:25
MGL Direct3D11用定義
constexpr auto kRendererTypeDirect3D11
Direct3D11用のレンダラタイプを表す値
Definition mgl_d3d11_defs.h:19
MGL Direct3D11用ラインレンダラ
MGL Direct3D11用矩形レンダラ
MGL Direct3D11用スプライトレンダラ
MGL 環境定義
MGL 4x4行列
MGL 描画関連の定義
RendererType
レンダラタイプの型
Definition mgl_render_types.h:21
MGL 2Dレンダラ デリゲート
std::shared_ptr< MGL::Render::TextureResource > SharedTextureResource
共有するテクスチャリソースの型
Definition mgl_texture_resource.h:145
色情報
Definition mgl_color.h:22
矩形
Definition mgl_rectangle.h:20
2Dベクトル
Definition mgl_vector2.h:23