Effekseer
EffekseerRendererGL.h
1 
2 #ifndef __EFFEKSEERRENDERER_GL_BASE_PRE_H__
3 #define __EFFEKSEERRENDERER_GL_BASE_PRE_H__
4 
5 #include <Effekseer.h>
6 #include <vector>
7 
8 #if defined(_WIN32)
9 #include <windows.h>
10 #endif
11 
12 #if defined(__EFFEKSEER_RENDERER_GLES2__)
13 
14 #if defined(__APPLE__)
15 #include <OpenGLES/ES2/gl.h>
16 #include <OpenGLES/ES2/glext.h>
17 #else
18 #include <GLES2/gl2.h>
19 #include <GLES2/gl2ext.h>
20 #endif
21 
22 #elif defined(__EFFEKSEER_RENDERER_GLES3__)
23 
24 #if defined(__APPLE__)
25 #include <OpenGLES/ES3/gl.h>
26 #else
27 #define GL_GLEXT_PROTOTYPES
28 #include <GLES3/gl3.h>
29 #endif
30 
31 #elif defined(__EFFEKSEER_RENDERER_GL2__)
32 
33 #if _WIN32
34 #include <GL/gl.h>
35 #elif defined(__APPLE__)
36 #define GL_SILENCE_DEPRECATION
37 #include <OpenGL/gl.h>
38 #else
39 #include <GL/gl.h>
40 #endif
41 
42 #else
43 
44 #if defined(_WIN32)
45 #include <GL/gl.h>
46 #elif defined(__APPLE__)
47 #define GL_SILENCE_DEPRECATION
48 #include <OpenGL/gl3.h>
49 #else
50 #define GL_GLEXT_PROTOTYPES
51 #include <GL/gl.h>
52 #endif
53 
54 #endif
55 
56 #if _WIN32
57 #pragma comment(lib, "opengl32.lib")
58 #endif
59 
60 namespace EffekseerRendererGL
61 {
62 
63 class Renderer;
64 
65 enum class OpenGLDeviceType
66 {
67  OpenGL2,
68  OpenGL3,
69  OpenGLES2,
70  OpenGLES3,
71 };
72 
73 } // namespace EffekseerRendererGL
74 
75 #endif // __EFFEKSEERRENDERER_GL_BASE_PRE_H__
76 
77 #ifndef __EFFEKSEERRENDERER_RENDERER_H__
78 #define __EFFEKSEERRENDERER_RENDERER_H__
79 
80 //----------------------------------------------------------------------------------
81 // Include
82 //----------------------------------------------------------------------------------
83 #include <Effekseer.h>
84 
85 //-----------------------------------------------------------------------------------
86 //
87 //-----------------------------------------------------------------------------------
88 
89 namespace Effekseer
90 {
91 namespace Backend
92 {
93 class VertexBuffer;
94 class IndexBuffer;
95 class GraphicsDevice;
96 } // namespace Backend
97 } // namespace Effekseer
98 
99 namespace EffekseerRenderer
100 {
101 
102 class Renderer;
103 using RendererRef = ::Effekseer::RefPtr<Renderer>;
104 
110 struct ExternalShaderSettings
111 {
112  Effekseer::Backend::ShaderRef StandardShader;
113  Effekseer::Backend::ShaderRef ModelShader;
114  Effekseer::AlphaBlendType Blend;
115 };
116 
123 class DistortingCallback
124 {
125 public:
126  DistortingCallback()
127  {
128  }
129  virtual ~DistortingCallback()
130  {
131  }
132 
141  virtual bool OnDistorting(Renderer* renderer)
142  {
143  return false;
144  }
145 };
146 
152 enum class UVStyle
153 {
154  Normal,
155  VerticalFlipped,
156 };
157 
163 enum class ProxyTextureType
164 {
165  White,
166  Normal,
167 };
168 
169 class CommandList : public ::Effekseer::IReference
170 {
171 public:
172  CommandList() = default;
173  virtual ~CommandList() = default;
174 };
175 
176 class SingleFrameMemoryPool : public ::Effekseer::IReference
177 {
178 public:
179  SingleFrameMemoryPool() = default;
180  virtual ~SingleFrameMemoryPool() = default;
181 
187  virtual void NewFrame()
188  {
189  }
190 };
191 
192 struct DepthReconstructionParameter
193 {
194  float DepthBufferScale = 1.0f;
195  float DepthBufferOffset = 0.0f;
196  float ProjectionMatrix33 = 0.0f;
197  float ProjectionMatrix34 = 0.0f;
198  float ProjectionMatrix43 = 0.0f;
199  float ProjectionMatrix44 = 0.0f;
200 };
201 
202 ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice, ::Effekseer::FileInterfaceRef fileInterface = nullptr);
203 
204 class Renderer : public ::Effekseer::IReference
205 {
206 protected:
207  Renderer();
208  virtual ~Renderer();
209 
210  class Impl;
211  std::unique_ptr<Impl> impl;
212 
213 public:
217  Impl* GetImpl();
218 
222  virtual void OnLostDevice() = 0;
223 
227  virtual void OnResetDevice() = 0;
228 
232  virtual void SetRestorationOfStatesFlag(bool flag) = 0;
233 
237  virtual bool BeginRendering() = 0;
238 
242  virtual bool EndRendering() = 0;
243 
247  virtual ::Effekseer::Vector3D GetLightDirection() const;
248 
252  virtual void SetLightDirection(const ::Effekseer::Vector3D& direction);
253 
257  virtual const ::Effekseer::Color& GetLightColor() const;
258 
262  virtual void SetLightColor(const ::Effekseer::Color& color);
263 
267  virtual const ::Effekseer::Color& GetLightAmbientColor() const;
268 
272  virtual void SetLightAmbientColor(const ::Effekseer::Color& color);
273 
277  virtual int32_t GetSquareMaxCount() const = 0;
278 
282  virtual ::Effekseer::Matrix44 GetProjectionMatrix() const;
283 
287  virtual void SetProjectionMatrix(const ::Effekseer::Matrix44& mat);
288 
292  virtual ::Effekseer::Matrix44 GetCameraMatrix() const;
293 
297  virtual void SetCameraMatrix(const ::Effekseer::Matrix44& mat);
298 
302  virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const;
303 
309  virtual ::Effekseer::Vector3D GetCameraFrontDirection() const;
310 
316  virtual ::Effekseer::Vector3D GetCameraPosition() const;
317 
325  virtual void SetCameraParameter(const ::Effekseer::Vector3D& front, const ::Effekseer::Vector3D& position);
326 
330  virtual ::Effekseer::SpriteRendererRef CreateSpriteRenderer() = 0;
331 
335  virtual ::Effekseer::RibbonRendererRef CreateRibbonRenderer() = 0;
336 
340  virtual ::Effekseer::RingRendererRef CreateRingRenderer() = 0;
341 
345  virtual ::Effekseer::ModelRendererRef CreateModelRenderer() = 0;
346 
350  virtual ::Effekseer::TrackRendererRef CreateTrackRenderer() = 0;
351 
355  virtual ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
356 
360  virtual ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
361 
368  virtual ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
369 
373  virtual void ResetRenderState() = 0;
374 
378  virtual DistortingCallback* GetDistortingCallback() = 0;
379 
383  virtual void SetDistortingCallback(DistortingCallback* callback) = 0;
384 
390  virtual int32_t GetDrawCallCount() const;
391 
397  virtual int32_t GetDrawVertexCount() const;
398 
404  virtual void ResetDrawCallCount();
405 
411  virtual void ResetDrawVertexCount();
412 
418  virtual Effekseer::RenderMode GetRenderMode() const;
419 
425  virtual void SetRenderMode(Effekseer::RenderMode renderMode);
426 
432  virtual UVStyle GetTextureUVStyle() const;
433 
439  virtual void SetTextureUVStyle(UVStyle style);
440 
446  virtual UVStyle GetBackgroundTextureUVStyle() const;
447 
453  virtual void SetBackgroundTextureUVStyle(UVStyle style);
454 
460  virtual float GetTime() const;
461 
467  virtual void SetTime(float time);
468 
474  virtual void SetCommandList(Effekseer::RefPtr<CommandList> commandList)
475  {
476  }
477 
485  virtual const ::Effekseer::Backend::TextureRef& GetBackground();
486 
492  virtual void SetBackground(::Effekseer::Backend::TextureRef texture);
493 
499  virtual ::Effekseer::Backend::TextureRef CreateProxyTexture(ProxyTextureType type);
500 
506  virtual void DeleteProxyTexture(Effekseer::Backend::TextureRef& texture);
507 
513  virtual void GetDepth(::Effekseer::Backend::TextureRef& texture, DepthReconstructionParameter& reconstructionParam);
514 
520  virtual void SetDepth(::Effekseer::Backend::TextureRef texture, const DepthReconstructionParameter& reconstructionParam);
521 
528  virtual void SetMaintainGammaColorInLinearColorSpace(bool value);
529 
535  virtual Effekseer::Backend::GraphicsDeviceRef GetGraphicsDevice() const;
536 
542  virtual std::shared_ptr<ExternalShaderSettings> GetExternalShaderSettings() const;
543 
549  virtual void SetExternalShaderSettings(const std::shared_ptr<ExternalShaderSettings>& settings);
550 };
551 
552 //----------------------------------------------------------------------------------
553 //
554 //----------------------------------------------------------------------------------
555 } // namespace EffekseerRenderer
556 //----------------------------------------------------------------------------------
557 //
558 //----------------------------------------------------------------------------------
559 #endif // __EFFEKSEERRENDERER_RENDERER_H__
560 #ifndef __EFFEKSEERRENDERER_TEXTURELOADER_H__
561 #define __EFFEKSEERRENDERER_TEXTURELOADER_H__
562 
563 #include <Effekseer.h>
564 
565 namespace EffekseerRenderer
566 {
567 
568 ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice,
569  ::Effekseer::FileInterfaceRef fileInterface = nullptr,
570  ::Effekseer::ColorSpaceType colorSpaceType = ::Effekseer::ColorSpaceType::Gamma);
571 
572 } // namespace EffekseerRenderer
573 
574 #endif // __EFFEKSEERRENDERER_TEXTURELOADER_H__
575 
576 #ifndef __EFFEKSEERRENDERER_GL_RENDERER_H__
577 #define __EFFEKSEERRENDERER_GL_RENDERER_H__
578 
579 //----------------------------------------------------------------------------------
580 // Include
581 //----------------------------------------------------------------------------------
582 
583 //----------------------------------------------------------------------------------
584 // Lib
585 //----------------------------------------------------------------------------------
586 
587 //----------------------------------------------------------------------------------
588 //
589 //----------------------------------------------------------------------------------
590 namespace EffekseerRendererGL
591 {
592 
593 ::Effekseer::Backend::GraphicsDeviceRef CreateGraphicsDevice(OpenGLDeviceType deviceType, bool isExtensionsEnabled = true);
594 
595 ::Effekseer::MaterialLoaderRef CreateMaterialLoader(Effekseer::Backend::GraphicsDeviceRef graphicsDevice,
596  ::Effekseer::FileInterfaceRef fileInterface = nullptr);
597 
598 Effekseer::Backend::TextureRef CreateTexture(Effekseer::Backend::GraphicsDeviceRef graphicsDevice, GLuint buffer, bool hasMipmap, const std::function<void()>& onDisposed);
599 
605 {
606  GLuint Buffer = 0;
607 };
608 
609 TextureProperty GetTextureProperty(::Effekseer::Backend::TextureRef texture);
610 
611 class Renderer;
612 using RendererRef = ::Effekseer::RefPtr<Renderer>;
613 
615 {
616 protected:
617  Renderer()
618  {
619  }
620  virtual ~Renderer()
621  {
622  }
623 
624 public:
642  static RendererRef Create(int32_t squareMaxCount, OpenGLDeviceType deviceType = OpenGLDeviceType::OpenGL2, bool isExtensionsEnabled = true);
643 
644  static RendererRef Create(Effekseer::Backend::GraphicsDeviceRef graphicsDevice, int32_t squareMaxCount);
645 
649  virtual int32_t GetSquareMaxCount() const = 0;
650 
656  virtual void SetSquareMaxCount(int32_t count) = 0;
657 
663  virtual void SetBackground(GLuint background, bool hasMipmap = false) = 0;
664 
670  virtual OpenGLDeviceType GetDeviceType() const = 0;
671 
677  virtual bool IsVertexArrayObjectSupported() const = 0;
678 };
679 
680 } // namespace EffekseerRendererGL
681 //----------------------------------------------------------------------------------
682 //
683 //----------------------------------------------------------------------------------
684 #endif // __EFFEKSEERRENDERER_GL_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
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: EffekseerRendererGL.h:474
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の状態を取得する。
EffekseerRendererGL::Renderer::GetDeviceType
virtual OpenGLDeviceType GetDeviceType() const =0
デバイスの種類を取得する。
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
描画を終了する時に実行する。
EffekseerRendererGL::Renderer::SetSquareMaxCount
virtual void SetSquareMaxCount(int32_t count)=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から深度を復元するためのパラメーターを設定する。
EffekseerRendererGL::Renderer
Definition: EffekseerRendererGL.h:614
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: EffekseerRendererGL.h:187
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: EffekseerRendererGL.h:141
EffekseerRenderer::Renderer::SetBackgroundTextureUVStyle
virtual void SetBackgroundTextureUVStyle(UVStyle style)
パーティクルを描画するときの背景のUVの状態を設定する。
EffekseerRenderer::Renderer::SetDistortingCallback
virtual void SetDistortingCallback(DistortingCallback *callback)=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを設定する。
EffekseerRendererGL::Renderer::SetBackground
virtual void SetBackground(GLuint background, bool hasMipmap=false)=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
グラフィクスデバイスを取得する。
EffekseerRendererGL::Renderer::IsVertexArrayObjectSupported
virtual bool IsVertexArrayObjectSupported() const =0
VAOがサポートされているか取得する。
EffekseerRendererGL::Renderer::Create
static RendererRef Create(int32_t squareMaxCount, OpenGLDeviceType deviceType=OpenGLDeviceType::OpenGL2, bool isExtensionsEnabled=true)
インスタンスを生成する。
EffekseerRendererGL::Renderer::GetSquareMaxCount
virtual int32_t GetSquareMaxCount() const =0
最大描画スプライト数を取得する。
EffekseerRenderer::Renderer::CreateModelRenderer
virtual ::Effekseer::ModelRendererRef CreateModelRenderer()=0
モデルレンダラーを生成する。
EffekseerRenderer::Renderer::GetLightAmbientColor
virtual const ::Effekseer::Color & GetLightAmbientColor() const
Get the color of ambient
EffekseerRendererGL::TextureProperty
テクスチャ内のプロパティ
Definition: EffekseerRendererGL.h:604
EffekseerRenderer::Renderer::GetDistortingCallback
virtual DistortingCallback * GetDistortingCallback()=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを取得する。
EffekseerRenderer::Renderer::GetSquareMaxCount
virtual int32_t GetSquareMaxCount() const =0
最大描画スプライト数を取得する。
EffekseerRenderer::Renderer::GetTime
virtual float GetTime() const
現在の時間を取得する。(秒)