Effekseer
EffekseerRendererDX11.h
1 
2 #ifndef __EFFEKSEERRENDERER_DX11_BASE_PRE_H__
3 #define __EFFEKSEERRENDERER_DX11_BASE_PRE_H__
4 
5 //----------------------------------------------------------------------------------
6 // Include
7 //----------------------------------------------------------------------------------
8 #include <Effekseer.h>
9 
10 #include <d3d11.h>
11 #include <windows.h>
12 
13 #if _WIN32
14 #pragma comment(lib, "d3d11.lib")
15 #endif
16 
17 //----------------------------------------------------------------------------------
18 //
19 //----------------------------------------------------------------------------------
20 namespace EffekseerRendererDX11
21 {
22 //----------------------------------------------------------------------------------
23 //
24 //----------------------------------------------------------------------------------
25 class Renderer;
26 
27 //----------------------------------------------------------------------------------
28 //
29 //----------------------------------------------------------------------------------
30 } // namespace EffekseerRendererDX11
31 //----------------------------------------------------------------------------------
32 //
33 //----------------------------------------------------------------------------------
34 #endif // __EFFEKSEERRENDERER_DX11_PRE_BASE_H__
35 
36 #ifndef __EFFEKSEERRENDERER_RENDERER_H__
37 #define __EFFEKSEERRENDERER_RENDERER_H__
38 
39 //----------------------------------------------------------------------------------
40 // Include
41 //----------------------------------------------------------------------------------
42 #include <Effekseer.h>
43 
44 //-----------------------------------------------------------------------------------
45 //
46 //-----------------------------------------------------------------------------------
47 
48 namespace Effekseer
49 {
50 namespace Backend
51 {
52 class VertexBuffer;
53 class IndexBuffer;
54 class GraphicsDevice;
55 } // namespace Backend
56 } // namespace Effekseer
57 
58 namespace EffekseerRenderer
59 {
60 
61 class Renderer;
62 using RendererRef = ::Effekseer::RefPtr<Renderer>;
63 
69 struct ExternalShaderSettings
70 {
71  Effekseer::Backend::ShaderRef StandardShader;
72  Effekseer::Backend::ShaderRef ModelShader;
73  Effekseer::AlphaBlendType Blend;
74 };
75 
82 class DistortingCallback
83 {
84 public:
85  DistortingCallback()
86  {
87  }
88  virtual ~DistortingCallback()
89  {
90  }
91 
100  virtual bool OnDistorting(Renderer* renderer)
101  {
102  return false;
103  }
104 };
105 
111 enum class UVStyle
112 {
113  Normal,
114  VerticalFlipped,
115 };
116 
122 enum class ProxyTextureType
123 {
124  White,
125  Normal,
126 };
127 
128 class CommandList : public ::Effekseer::IReference
129 {
130 public:
131  CommandList() = default;
132  virtual ~CommandList() = default;
133 };
134 
135 class SingleFrameMemoryPool : public ::Effekseer::IReference
136 {
137 public:
138  SingleFrameMemoryPool() = default;
139  virtual ~SingleFrameMemoryPool() = default;
140 
146  virtual void NewFrame()
147  {
148  }
149 };
150 
151 struct DepthReconstructionParameter
152 {
153  float DepthBufferScale = 1.0f;
154  float DepthBufferOffset = 0.0f;
155  float ProjectionMatrix33 = 0.0f;
156  float ProjectionMatrix34 = 0.0f;
157  float ProjectionMatrix43 = 0.0f;
158  float ProjectionMatrix44 = 0.0f;
159 };
160 
161 ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice, ::Effekseer::FileInterfaceRef fileInterface = nullptr);
162 
163 class Renderer : public ::Effekseer::IReference
164 {
165 protected:
166  Renderer();
167  virtual ~Renderer();
168 
169  class Impl;
170  std::unique_ptr<Impl> impl;
171 
172 public:
176  Impl* GetImpl();
177 
181  virtual void OnLostDevice() = 0;
182 
186  virtual void OnResetDevice() = 0;
187 
191  virtual void SetRestorationOfStatesFlag(bool flag) = 0;
192 
196  virtual bool BeginRendering() = 0;
197 
201  virtual bool EndRendering() = 0;
202 
206  virtual ::Effekseer::Vector3D GetLightDirection() const;
207 
211  virtual void SetLightDirection(const ::Effekseer::Vector3D& direction);
212 
216  virtual const ::Effekseer::Color& GetLightColor() const;
217 
221  virtual void SetLightColor(const ::Effekseer::Color& color);
222 
226  virtual const ::Effekseer::Color& GetLightAmbientColor() const;
227 
231  virtual void SetLightAmbientColor(const ::Effekseer::Color& color);
232 
236  virtual int32_t GetSquareMaxCount() const = 0;
237 
241  virtual ::Effekseer::Matrix44 GetProjectionMatrix() const;
242 
246  virtual void SetProjectionMatrix(const ::Effekseer::Matrix44& mat);
247 
251  virtual ::Effekseer::Matrix44 GetCameraMatrix() const;
252 
256  virtual void SetCameraMatrix(const ::Effekseer::Matrix44& mat);
257 
261  virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const;
262 
268  virtual ::Effekseer::Vector3D GetCameraFrontDirection() const;
269 
275  virtual ::Effekseer::Vector3D GetCameraPosition() const;
276 
284  virtual void SetCameraParameter(const ::Effekseer::Vector3D& front, const ::Effekseer::Vector3D& position);
285 
289  virtual ::Effekseer::SpriteRendererRef CreateSpriteRenderer() = 0;
290 
294  virtual ::Effekseer::RibbonRendererRef CreateRibbonRenderer() = 0;
295 
299  virtual ::Effekseer::RingRendererRef CreateRingRenderer() = 0;
300 
304  virtual ::Effekseer::ModelRendererRef CreateModelRenderer() = 0;
305 
309  virtual ::Effekseer::TrackRendererRef CreateTrackRenderer() = 0;
310 
314  virtual ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
315 
319  virtual ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
320 
327  virtual ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
328 
332  virtual void ResetRenderState() = 0;
333 
337  virtual DistortingCallback* GetDistortingCallback() = 0;
338 
342  virtual void SetDistortingCallback(DistortingCallback* callback) = 0;
343 
349  virtual int32_t GetDrawCallCount() const;
350 
356  virtual int32_t GetDrawVertexCount() const;
357 
363  virtual void ResetDrawCallCount();
364 
370  virtual void ResetDrawVertexCount();
371 
377  virtual Effekseer::RenderMode GetRenderMode() const;
378 
384  virtual void SetRenderMode(Effekseer::RenderMode renderMode);
385 
391  virtual UVStyle GetTextureUVStyle() const;
392 
398  virtual void SetTextureUVStyle(UVStyle style);
399 
405  virtual UVStyle GetBackgroundTextureUVStyle() const;
406 
412  virtual void SetBackgroundTextureUVStyle(UVStyle style);
413 
419  virtual float GetTime() const;
420 
426  virtual void SetTime(float time);
427 
433  virtual void SetCommandList(Effekseer::RefPtr<CommandList> commandList)
434  {
435  }
436 
444  virtual const ::Effekseer::Backend::TextureRef& GetBackground();
445 
451  virtual void SetBackground(::Effekseer::Backend::TextureRef texture);
452 
458  virtual ::Effekseer::Backend::TextureRef CreateProxyTexture(ProxyTextureType type);
459 
465  virtual void DeleteProxyTexture(Effekseer::Backend::TextureRef& texture);
466 
472  virtual void GetDepth(::Effekseer::Backend::TextureRef& texture, DepthReconstructionParameter& reconstructionParam);
473 
479  virtual void SetDepth(::Effekseer::Backend::TextureRef texture, const DepthReconstructionParameter& reconstructionParam);
480 
487  virtual void SetMaintainGammaColorInLinearColorSpace(bool value);
488 
494  virtual Effekseer::Backend::GraphicsDeviceRef GetGraphicsDevice() const;
495 
501  virtual std::shared_ptr<ExternalShaderSettings> GetExternalShaderSettings() const;
502 
508  virtual void SetExternalShaderSettings(const std::shared_ptr<ExternalShaderSettings>& settings);
509 };
510 
511 //----------------------------------------------------------------------------------
512 //
513 //----------------------------------------------------------------------------------
514 } // namespace EffekseerRenderer
515 //----------------------------------------------------------------------------------
516 //
517 //----------------------------------------------------------------------------------
518 #endif // __EFFEKSEERRENDERER_RENDERER_H__
519 #ifndef __EFFEKSEERRENDERER_TEXTURELOADER_H__
520 #define __EFFEKSEERRENDERER_TEXTURELOADER_H__
521 
522 #include <Effekseer.h>
523 
524 namespace EffekseerRenderer
525 {
526 
527 ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice,
528  ::Effekseer::FileInterfaceRef fileInterface = nullptr,
529  ::Effekseer::ColorSpaceType colorSpaceType = ::Effekseer::ColorSpaceType::Gamma);
530 
531 } // namespace EffekseerRenderer
532 
533 #endif // __EFFEKSEERRENDERER_TEXTURELOADER_H__
534 
535 #ifndef __EFFEKSEERRENDERER_DX11_RENDERER_H__
536 #define __EFFEKSEERRENDERER_DX11_RENDERER_H__
537 
538 //----------------------------------------------------------------------------------
539 // Include
540 //----------------------------------------------------------------------------------
541 
542 //----------------------------------------------------------------------------------
543 //
544 //----------------------------------------------------------------------------------
545 namespace EffekseerRendererDX11
546 {
547 //----------------------------------------------------------------------------------
548 //
549 //----------------------------------------------------------------------------------
550 
551 ::Effekseer::Backend::GraphicsDeviceRef CreateGraphicsDevice(ID3D11Device* device,
552  ID3D11DeviceContext* context);
553 
554 ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice, ::Effekseer::FileInterfaceRef fileInterface = nullptr);
555 
556 ::Effekseer::Backend::TextureRef CreateTexture(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice, ID3D11ShaderResourceView* srv, ID3D11RenderTargetView* rtv, ID3D11DepthStencilView* dsv);
557 
566 {
567  ID3D11ShaderResourceView* ShaderResourceViewPtr = nullptr;
568  ID3D11RenderTargetView* RenderTargetViewPtr = nullptr;
569  ID3D11DepthStencilView* DepthStencilViewPtr = nullptr;
570 };
571 
572 TextureProperty GetTextureProperty(::Effekseer::Backend::TextureRef texture);
573 
574 class Renderer;
575 using RendererRef = ::Effekseer::RefPtr<Renderer>;
576 
578 {
579 protected:
580  Renderer()
581  {
582  }
583  virtual ~Renderer()
584  {
585  }
586 
587 public:
600  static RendererRef Create(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice,
601  int32_t squareMaxCount,
602  D3D11_COMPARISON_FUNC depthFunc = D3D11_COMPARISON_LESS_EQUAL,
603  bool isMSAAEnabled = false);
617  static RendererRef Create(ID3D11Device* device,
618  ID3D11DeviceContext* context,
619  int32_t squareMaxCount,
620  D3D11_COMPARISON_FUNC depthFunc = D3D11_COMPARISON_LESS_EQUAL,
621  bool isMSAAEnabled = false);
622 
623  virtual ID3D11Device* GetDevice() = 0;
624 
625  virtual ID3D11DeviceContext* GetContext() = 0;
626 
631  [[deprecated("please use EffekseerRenderer::SetBackground")]] virtual void SetBackground(ID3D11ShaderResourceView* background) = 0;
632 
639  virtual void ResetStateForDefferedContext() = 0;
640 };
641 
642 //----------------------------------------------------------------------------------
643 //
644 //----------------------------------------------------------------------------------
645 } // namespace EffekseerRendererDX11
646 //----------------------------------------------------------------------------------
647 //
648 //----------------------------------------------------------------------------------
649 #endif // __EFFEKSEERRENDERER_DX11_RENDERER_H__
EffekseerRenderer::Renderer::GetDepth
virtual void GetDepth(::Effekseer::Backend::TextureRef &texture, DepthReconstructionParameter &reconstructionParam)
深度画像とZから深度を復元するためのパラメーターを取得する。
EffekseerRenderer::Renderer::SetExternalShaderSettings
virtual void SetExternalShaderSettings(const std::shared_ptr< ExternalShaderSettings > &settings)
Specify external shader settings
EffekseerRenderer::Renderer::SetCameraParameter
virtual void SetCameraParameter(const ::Effekseer::Vector3D &front, const ::Effekseer::Vector3D &position)
Set a front direction and position of camera manually
EffekseerRenderer::Renderer::GetRenderMode
virtual Effekseer::RenderMode GetRenderMode() const
描画モードを取得する。
EffekseerRenderer::Renderer::ResetDrawVertexCount
virtual void ResetDrawVertexCount()
描画された頂点数をリセットする
EffekseerRenderer::Renderer::GetDrawVertexCount
virtual int32_t GetDrawVertexCount() const
描画された頂点数をリセットする
EffekseerRenderer::Renderer::SetTime
virtual void SetTime(float time)
現在の時間を設定する。(秒)
EffekseerRenderer::DepthReconstructionParameter
Definition: EffekseerRendererDX9.h:151
EffekseerRenderer::Renderer::GetCameraMatrix
virtual ::Effekseer::Matrix44 GetCameraMatrix() const
Get a camera matrix
EffekseerRenderer::Renderer::GetDrawCallCount
virtual int32_t GetDrawCallCount() const
ドローコールの回数を取得する
EffekseerRenderer::Renderer::GetExternalShaderSettings
virtual std::shared_ptr< ExternalShaderSettings > GetExternalShaderSettings() const
Get external shader settings
EffekseerRenderer::Renderer::CreateTextureLoader
virtual ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::FileInterfaceRef fileInterface=nullptr)=0
標準のテクスチャ読込クラスを生成する。
EffekseerRenderer::Renderer::SetMaintainGammaColorInLinearColorSpace
virtual void SetMaintainGammaColorInLinearColorSpace(bool value)
リニア空間でもガンマカラーを維持するようにするか、を設定する。
EffekseerRenderer::Renderer::GetBackgroundTextureUVStyle
virtual UVStyle GetBackgroundTextureUVStyle() const
パーティクルを描画するときの背景のUVの状態を取得する。
EffekseerRenderer::Renderer::ResetDrawCallCount
virtual void ResetDrawCallCount()
ドローコールの回数をリセットする
EffekseerRenderer::Renderer::GetCameraFrontDirection
virtual ::Effekseer::Vector3D GetCameraFrontDirection() const
Get a front direction of camera
EffekseerRendererDX11::Renderer
Definition: EffekseerRendererDX11.h:577
EffekseerRenderer::Renderer::GetCameraProjectionMatrix
virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const
Get a camera projection matrix
EffekseerRenderer::Renderer::SetLightColor
virtual void SetLightColor(const ::Effekseer::Color &color)
Specify the color of light
EffekseerRendererDX11::Renderer::ResetStateForDefferedContext
virtual void ResetStateForDefferedContext()=0
DefferedContextのために、内部の状態をリセットする。
EffekseerRenderer::Renderer::SetCommandList
virtual void SetCommandList(Effekseer::RefPtr< CommandList > commandList)
描画に使用するコマンドリストを設定する。この関数はDirectX9、DirectX11、OpenGL以外で使用できる。
Definition: EffekseerRendererDX11.h:433
EffekseerRenderer::Renderer::CreateRibbonRenderer
virtual ::Effekseer::RibbonRendererRef CreateRibbonRenderer()=0
リボンレンダラーを生成する。
EffekseerRenderer::Renderer::SetLightAmbientColor
virtual void SetLightAmbientColor(const ::Effekseer::Color &color)
Specify the color of ambient
EffekseerRenderer::Renderer::GetImpl
Impl * GetImpl()
only for Effekseer backend developer. Effekseer User doesn't need it.
EffekseerRendererDX11::Renderer::Create
static RendererRef Create(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice, int32_t squareMaxCount, D3D11_COMPARISON_FUNC depthFunc=D3D11_COMPARISON_LESS_EQUAL, bool isMSAAEnabled=false)
インスタンスを生成する。
EffekseerRenderer::Renderer::SetTextureUVStyle
virtual void SetTextureUVStyle(UVStyle style)
パーティクルを描画するときのUVの状態を設定する。
EffekseerRenderer::Renderer::SetCameraMatrix
virtual void SetCameraMatrix(const ::Effekseer::Matrix44 &mat)
Set a camera matrix
EffekseerRenderer::Renderer::ResetRenderState
virtual void ResetRenderState()=0
レンダーステートを強制的にリセットする。
EffekseerRenderer::Renderer::SetRenderMode
virtual void SetRenderMode(Effekseer::RenderMode renderMode)
描画モードを設定する。
EffekseerRenderer::Renderer
Definition: EffekseerRendererDX9.h:163
EffekseerRenderer::Renderer::DeleteProxyTexture
virtual void DeleteProxyTexture(Effekseer::Backend::TextureRef &texture)
代替のテクスチャを削除する
EffekseerRenderer::Renderer::BeginRendering
virtual bool BeginRendering()=0
描画を開始する時に実行する。
EffekseerRenderer::Renderer::CreateSpriteRenderer
virtual ::Effekseer::SpriteRendererRef CreateSpriteRenderer()=0
スプライトレンダラーを生成する。
EffekseerRenderer::Renderer::SetProjectionMatrix
virtual void SetProjectionMatrix(const ::Effekseer::Matrix44 &mat)
Set a projection matrix
EffekseerRenderer::Renderer::GetTextureUVStyle
virtual UVStyle GetTextureUVStyle() const
パーティクルを描画するときのUVの状態を取得する。
EffekseerRenderer::Renderer::GetProjectionMatrix
virtual ::Effekseer::Matrix44 GetProjectionMatrix() const
Get a projection matrix
EffekseerRenderer::Renderer::SetBackground
virtual void SetBackground(::Effekseer::Backend::TextureRef texture)
背景のテクスチャを設定する。
EffekseerRenderer::Renderer::EndRendering
virtual bool EndRendering()=0
描画を終了する時に実行する。
EffekseerRenderer::Renderer::SetLightDirection
virtual void SetLightDirection(const ::Effekseer::Vector3D &direction)
Specifiy the direction of light
EffekseerRenderer::Renderer::CreateRingRenderer
virtual ::Effekseer::RingRendererRef CreateRingRenderer()=0
リングレンダラーを生成する。
EffekseerRendererDX11::TextureProperty
テクスチャ内のプロパティ
Definition: EffekseerRendererDX11.h:565
EffekseerRenderer::Renderer::SetDepth
virtual void SetDepth(::Effekseer::Backend::TextureRef texture, const DepthReconstructionParameter &reconstructionParam)
深度画像とZから深度を復元するためのパラメーターを設定する。
EffekseerRenderer::Renderer::CreateTrackRenderer
virtual ::Effekseer::TrackRendererRef CreateTrackRenderer()=0
軌跡レンダラーを生成する。
EffekseerRenderer::Renderer::SetRestorationOfStatesFlag
virtual void SetRestorationOfStatesFlag(bool flag)=0
ステートを復帰するかどうかのフラグを設定する。
EffekseerRenderer::Renderer::OnLostDevice
virtual void OnLostDevice()=0
デバイスロストが発生した時に実行する。
EffekseerRenderer::Renderer::OnResetDevice
virtual void OnResetDevice()=0
デバイスがリセットされた時に実行する。
EffekseerRenderer::Renderer::GetBackground
virtual const ::Effekseer::Backend::TextureRef & GetBackground()
背景を取得する。
EffekseerRenderer::Renderer::GetLightColor
virtual const ::Effekseer::Color & GetLightColor() const
Get the color of light
EffekseerRenderer::SingleFrameMemoryPool::NewFrame
virtual void NewFrame()
新規フレームが始ったことを通知する。
Definition: EffekseerRendererDX11.h:146
EffekseerRenderer::Renderer::CreateMaterialLoader
virtual ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::FileInterfaceRef fileInterface=nullptr)=0
標準のマテリアル読込クラスを生成する。
EffekseerRenderer::Renderer::GetLightDirection
virtual ::Effekseer::Vector3D GetLightDirection() const
Get the direction of light
EffekseerRenderer::Renderer::CreateProxyTexture
virtual ::Effekseer::Backend::TextureRef CreateProxyTexture(ProxyTextureType type)
代替のテクスチャを生成する
EffekseerRenderer::DistortingCallback::OnDistorting
virtual bool OnDistorting(Renderer *renderer)
コールバック
Definition: EffekseerRendererDX11.h:100
EffekseerRenderer::Renderer::SetBackgroundTextureUVStyle
virtual void SetBackgroundTextureUVStyle(UVStyle style)
パーティクルを描画するときの背景のUVの状態を設定する。
EffekseerRenderer::Renderer::SetDistortingCallback
virtual void SetDistortingCallback(DistortingCallback *callback)=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを設定する。
EffekseerRendererDX11::Renderer::SetBackground
virtual void SetBackground(ID3D11ShaderResourceView *background)=0
背景を設定する
EffekseerRenderer::Renderer::CreateModelLoader
virtual ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::FileInterfaceRef fileInterface=nullptr)=0
標準のモデル読込クラスを生成する。
EffekseerRenderer::Renderer::GetCameraPosition
virtual ::Effekseer::Vector3D GetCameraPosition() const
Get a position of camera
EffekseerRenderer::Renderer::GetGraphicsDevice
virtual Effekseer::Backend::GraphicsDeviceRef GetGraphicsDevice() const
グラフィクスデバイスを取得する。
EffekseerRenderer::Renderer::CreateModelRenderer
virtual ::Effekseer::ModelRendererRef CreateModelRenderer()=0
モデルレンダラーを生成する。
EffekseerRenderer::Renderer::GetLightAmbientColor
virtual const ::Effekseer::Color & GetLightAmbientColor() const
Get the color of ambient
EffekseerRenderer::Renderer::GetDistortingCallback
virtual DistortingCallback * GetDistortingCallback()=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを取得する。
EffekseerRenderer::Renderer::GetSquareMaxCount
virtual int32_t GetSquareMaxCount() const =0
最大描画スプライト数を取得する。
EffekseerRenderer::Renderer::GetTime
virtual float GetTime() const
現在の時間を取得する。(秒)