Effekseer
EffekseerRendererMetal.h
1 
2 #ifndef __EFFEKSEERRENDERER_METAL_BASE_PRE_H__
3 #define __EFFEKSEERRENDERER_METAL_BASE_PRE_H__
4 
5 #include <Effekseer.h>
6 
7 namespace EffekseerRendererMetal
8 {
9 
10 }
11 
12 #endif
13 
14 #ifndef __EFFEKSEERRENDERER_RENDERER_H__
15 #define __EFFEKSEERRENDERER_RENDERER_H__
16 
17 //----------------------------------------------------------------------------------
18 // Include
19 //----------------------------------------------------------------------------------
20 #include <Effekseer.h>
21 
22 //-----------------------------------------------------------------------------------
23 //
24 //-----------------------------------------------------------------------------------
25 
26 namespace Effekseer
27 {
28 namespace Backend
29 {
30 class VertexBuffer;
31 class IndexBuffer;
32 class GraphicsDevice;
33 } // namespace Backend
34 } // namespace Effekseer
35 
36 namespace EffekseerRenderer
37 {
38 
39 class Renderer;
40 using RendererRef = ::Effekseer::RefPtr<Renderer>;
41 
47 struct ExternalShaderSettings
48 {
49  Effekseer::Backend::ShaderRef StandardShader;
50  Effekseer::Backend::ShaderRef ModelShader;
51  Effekseer::AlphaBlendType Blend;
52 };
53 
60 class DistortingCallback
61 {
62 public:
63  DistortingCallback()
64  {
65  }
66  virtual ~DistortingCallback()
67  {
68  }
69 
78  virtual bool OnDistorting(Renderer* renderer)
79  {
80  return false;
81  }
82 };
83 
89 enum class UVStyle
90 {
91  Normal,
92  VerticalFlipped,
93 };
94 
100 enum class ProxyTextureType
101 {
102  White,
103  Normal,
104 };
105 
106 class CommandList : public ::Effekseer::IReference
107 {
108 public:
109  CommandList() = default;
110  virtual ~CommandList() = default;
111 };
112 
113 class SingleFrameMemoryPool : public ::Effekseer::IReference
114 {
115 public:
116  SingleFrameMemoryPool() = default;
117  virtual ~SingleFrameMemoryPool() = default;
118 
124  virtual void NewFrame()
125  {
126  }
127 };
128 
129 struct DepthReconstructionParameter
130 {
131  float DepthBufferScale = 1.0f;
132  float DepthBufferOffset = 0.0f;
133  float ProjectionMatrix33 = 0.0f;
134  float ProjectionMatrix34 = 0.0f;
135  float ProjectionMatrix43 = 0.0f;
136  float ProjectionMatrix44 = 0.0f;
137 };
138 
139 ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice, ::Effekseer::FileInterfaceRef fileInterface = nullptr);
140 
141 class Renderer : public ::Effekseer::IReference
142 {
143 protected:
144  Renderer();
145  virtual ~Renderer();
146 
147  class Impl;
148  std::unique_ptr<Impl> impl;
149 
150 public:
154  Impl* GetImpl();
155 
159  virtual void OnLostDevice() = 0;
160 
164  virtual void OnResetDevice() = 0;
165 
169  virtual void SetRestorationOfStatesFlag(bool flag) = 0;
170 
174  virtual bool BeginRendering() = 0;
175 
179  virtual bool EndRendering() = 0;
180 
184  virtual ::Effekseer::Vector3D GetLightDirection() const;
185 
189  virtual void SetLightDirection(const ::Effekseer::Vector3D& direction);
190 
194  virtual const ::Effekseer::Color& GetLightColor() const;
195 
199  virtual void SetLightColor(const ::Effekseer::Color& color);
200 
204  virtual const ::Effekseer::Color& GetLightAmbientColor() const;
205 
209  virtual void SetLightAmbientColor(const ::Effekseer::Color& color);
210 
214  virtual int32_t GetSquareMaxCount() const = 0;
215 
219  virtual ::Effekseer::Matrix44 GetProjectionMatrix() const;
220 
224  virtual void SetProjectionMatrix(const ::Effekseer::Matrix44& mat);
225 
229  virtual ::Effekseer::Matrix44 GetCameraMatrix() const;
230 
234  virtual void SetCameraMatrix(const ::Effekseer::Matrix44& mat);
235 
239  virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const;
240 
246  virtual ::Effekseer::Vector3D GetCameraFrontDirection() const;
247 
253  virtual ::Effekseer::Vector3D GetCameraPosition() const;
254 
262  virtual void SetCameraParameter(const ::Effekseer::Vector3D& front, const ::Effekseer::Vector3D& position);
263 
267  virtual ::Effekseer::SpriteRendererRef CreateSpriteRenderer() = 0;
268 
272  virtual ::Effekseer::RibbonRendererRef CreateRibbonRenderer() = 0;
273 
277  virtual ::Effekseer::RingRendererRef CreateRingRenderer() = 0;
278 
282  virtual ::Effekseer::ModelRendererRef CreateModelRenderer() = 0;
283 
287  virtual ::Effekseer::TrackRendererRef CreateTrackRenderer() = 0;
288 
292  virtual ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
293 
297  virtual ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
298 
305  virtual ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
306 
310  virtual void ResetRenderState() = 0;
311 
315  virtual DistortingCallback* GetDistortingCallback() = 0;
316 
320  virtual void SetDistortingCallback(DistortingCallback* callback) = 0;
321 
327  virtual int32_t GetDrawCallCount() const;
328 
334  virtual int32_t GetDrawVertexCount() const;
335 
341  virtual void ResetDrawCallCount();
342 
348  virtual void ResetDrawVertexCount();
349 
355  virtual Effekseer::RenderMode GetRenderMode() const;
356 
362  virtual void SetRenderMode(Effekseer::RenderMode renderMode);
363 
369  virtual UVStyle GetTextureUVStyle() const;
370 
376  virtual void SetTextureUVStyle(UVStyle style);
377 
383  virtual UVStyle GetBackgroundTextureUVStyle() const;
384 
390  virtual void SetBackgroundTextureUVStyle(UVStyle style);
391 
397  virtual float GetTime() const;
398 
404  virtual void SetTime(float time);
405 
411  virtual void SetCommandList(Effekseer::RefPtr<CommandList> commandList)
412  {
413  }
414 
422  virtual const ::Effekseer::Backend::TextureRef& GetBackground();
423 
429  virtual void SetBackground(::Effekseer::Backend::TextureRef texture);
430 
436  virtual ::Effekseer::Backend::TextureRef CreateProxyTexture(ProxyTextureType type);
437 
443  virtual void DeleteProxyTexture(Effekseer::Backend::TextureRef& texture);
444 
450  virtual void GetDepth(::Effekseer::Backend::TextureRef& texture, DepthReconstructionParameter& reconstructionParam);
451 
457  virtual void SetDepth(::Effekseer::Backend::TextureRef texture, const DepthReconstructionParameter& reconstructionParam);
458 
465  virtual void SetMaintainGammaColorInLinearColorSpace(bool value);
466 
472  virtual Effekseer::Backend::GraphicsDeviceRef GetGraphicsDevice() const;
473 
479  virtual std::shared_ptr<ExternalShaderSettings> GetExternalShaderSettings() const;
480 
486  virtual void SetExternalShaderSettings(const std::shared_ptr<ExternalShaderSettings>& settings);
487 };
488 
489 //----------------------------------------------------------------------------------
490 //
491 //----------------------------------------------------------------------------------
492 } // namespace EffekseerRenderer
493 //----------------------------------------------------------------------------------
494 //
495 //----------------------------------------------------------------------------------
496 #endif // __EFFEKSEERRENDERER_RENDERER_H__
497 #ifndef __EFFEKSEERRENDERER_TEXTURELOADER_H__
498 #define __EFFEKSEERRENDERER_TEXTURELOADER_H__
499 
500 #include <Effekseer.h>
501 
502 namespace EffekseerRenderer
503 {
504 
505 ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice,
506  ::Effekseer::FileInterfaceRef fileInterface = nullptr,
507  ::Effekseer::ColorSpaceType colorSpaceType = ::Effekseer::ColorSpaceType::Gamma);
508 
509 } // namespace EffekseerRenderer
510 
511 #endif // __EFFEKSEERRENDERER_TEXTURELOADER_H__
512 
513 #ifndef __EFFEKSEERRENDERER_METAL_RENDERER_H__
514 #define __EFFEKSEERRENDERER_METAL_RENDERER_H__
515 
516 #include <functional>
517 
518 #import <MetalKit/MetalKit.h>
519 
520 @class MTLRenderPassDescriptor;
521 @protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder, MTLTexture;
522 
523 namespace EffekseerRendererMetal
524 {
525 
526 ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice, ::Effekseer::FileInterfaceRef fileInterface = NULL);
527 
528 ::Effekseer::Backend::GraphicsDeviceRef CreateDevice();
529 
530 ::EffekseerRenderer::RendererRef Create(
531  ::Effekseer::Backend::GraphicsDeviceRef graphicsDevice,
532  int32_t squareMaxCount,
533  MTLPixelFormat renderTargetFormat,
534  MTLPixelFormat depthStencilFormat,
535  bool isReversedDepth);
536 
544 ::EffekseerRenderer::RendererRef Create(int32_t squareMaxCount,
545  MTLPixelFormat renderTargetFormat,
546  MTLPixelFormat depthStencilFormat,
547  bool isReversedDepth);
548 
549 Effekseer::Backend::TextureRef CreateTexture(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice, id<MTLTexture> texture);
550 
551 void BeginCommandList(Effekseer::RefPtr<EffekseerRenderer::CommandList> commandList, id<MTLRenderCommandEncoder> encoder);
552 
553 void EndCommandList(Effekseer::RefPtr<EffekseerRenderer::CommandList> commandList);
554 
555 } // namespace EffekseerRendererMetal
556 
557 #endif
558 
559 #ifndef __EFFEKSEERRENDERER_LLGI_COMMON_H__
560 #define __EFFEKSEERRENDERER_LLGI_COMMON_H__
561 
562 #include <Effekseer.h>
563 
564 namespace EffekseerRenderer
565 {
566 
567 struct RenderPassPipelineStateKey
568 {
569  std::array<Effekseer::Backend::TextureFormatType, 8> RenderTargetFormats;
570  int32_t RenderTargetCount = 0;
571  Effekseer::Backend::TextureFormatType DepthFormat = Effekseer::Backend::TextureFormatType::Unknown;
572 };
573 
574 void ChangeRenderPassPipelineState(EffekseerRenderer::RendererRef renderer, RenderPassPipelineStateKey key);
575 
576 void FlushAndWait(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice);
577 
578 Effekseer::RefPtr<EffekseerRenderer::CommandList> CreateCommandList(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice,
579  Effekseer::RefPtr<::EffekseerRenderer::SingleFrameMemoryPool> memoryPool);
580 
581 Effekseer::RefPtr<EffekseerRenderer::SingleFrameMemoryPool> CreateSingleFrameMemoryPool(::Effekseer::Backend::GraphicsDeviceRef renderer);
582 
583 } // namespace EffekseerRenderer
584 
585 #endif
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
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
EffekseerRenderer::Renderer::SetCommandList
virtual void SetCommandList(Effekseer::RefPtr< CommandList > commandList)
描画に使用するコマンドリストを設定する。この関数はDirectX9、DirectX11、OpenGL以外で使用できる。
Definition: EffekseerRendererMetal.h:411
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.
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
リングレンダラーを生成する。
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: EffekseerRendererMetal.h:124
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: EffekseerRendererMetal.h:78
EffekseerRenderer::Renderer::SetBackgroundTextureUVStyle
virtual void SetBackgroundTextureUVStyle(UVStyle style)
パーティクルを描画するときの背景のUVの状態を設定する。
EffekseerRenderer::Renderer::SetDistortingCallback
virtual void SetDistortingCallback(DistortingCallback *callback)=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
現在の時間を取得する。(秒)