arsa  2.7
EffekseerRendererGL.h
Go to the documentation of this file.
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 __EFFEKSEER_RENDERER_GLES2_ONLY__
9 #else
10 
11 #ifdef _WIN32
12 #include <Windows.h>
13 #endif
14 
15 #endif // #if __EFFEKSEER_RENDERER_GLES2_ONLY__
16 
17 #if defined(__EFFEKSEER_RENDERER_GLES2__)
18 
19 #if defined(__APPLE__)
20 #include <OpenGLES/ES2/gl.h>
21 #include <OpenGLES/ES2/glext.h>
22 #else
23 #include <GLES2/gl2.h>
24 #include <GLES2/gl2ext.h>
25 #endif
26 
27 #elif defined(__EFFEKSEER_RENDERER_GLES3__)
28 
29 #if defined(__APPLE__)
30 #include <OpenGLES/ES3/gl.h>
31 #else
32 #define GL_GLEXT_PROTOTYPES
33 #include <GLES3/gl3.h>
34 #endif
35 
36 #elif defined(__EFFEKSEER_RENDERER_GL2__)
37 
38 #if _WIN32
39 #include <GL/gl.h>
40 #elif defined(__APPLE__)
41 #define GL_SILENCE_DEPRECATION
42 #include <OpenGL/gl.h>
43 #else
44 #include <GL/gl.h>
45 #endif
46 
47 #else
48 
49 #if _WIN32
50 #include <GL/gl.h>
51 #elif defined(__APPLE__)
52 #define GL_SILENCE_DEPRECATION
53 #include <OpenGL/gl3.h>
54 #else
55 #define GL_GLEXT_PROTOTYPES
56 #include <GL/gl.h>
57 #endif
58 
59 #endif
60 
61 #if __EFFEKSEER_RENDERER_GLES2_ONLY__
62 #else
63 
64 #if _WIN32
65 #pragma comment(lib, "gdiplus.lib")
66 #pragma comment(lib, "opengl32.lib")
67 #endif
68 
69 #endif // #if __EFFEKSEER_RENDERER_GLES2_ONLY__
70 
72 {
73 
74 class Renderer;
75 
76 enum class OpenGLDeviceType
77 {
78  OpenGL2,
79  OpenGL3,
80  OpenGLES2,
81  OpenGLES3,
82  Emscripten,
83 };
84 
85 } // namespace EffekseerRendererGL
86 
87 #endif // __EFFEKSEERRENDERER_GL_BASE_PRE_H__
88 
89 #ifndef __EFFEKSEERRENDERER_GL_DEVICEOBJECT_COLLECTION_H__
90 #define __EFFEKSEERRENDERER_GL_DEVICEOBJECT_COLLECTION_H__
91 
92 #include <set>
93 #include <Effekseer.h>
94 
95 namespace EffekseerRendererGL
96 {
97 
98 class DeviceObject;
99 
101 {
102  friend class DeviceObject;
103 
104 private:
105  std::set<DeviceObject*> deviceObjects_;
106 
110  void Register(DeviceObject* device);
111 
115  void Unregister(DeviceObject* device);
116 
117 public:
118  DeviceObjectCollection() = default;
119 
120  ~DeviceObjectCollection() = default;
121 
127  void OnLostDevice();
128 
134  void OnResetDevice();
135 };
136 
137 } // namespace EffekseerRendererGL
138 
139 #endif // __EFFEKSEERRENDERER_GL_DEVICEOBJECT_H__
140 #ifndef __EFFEKSEERRENDERER_RENDERER_H__
141 #define __EFFEKSEERRENDERER_RENDERER_H__
142 
143 //----------------------------------------------------------------------------------
144 // Include
145 //----------------------------------------------------------------------------------
146 #include <Effekseer.h>
147 
148 //-----------------------------------------------------------------------------------
149 //
150 //-----------------------------------------------------------------------------------
151 namespace EffekseerRenderer
152 {
153 //-----------------------------------------------------------------------------------
154 //
155 //-----------------------------------------------------------------------------------
156 
160 class DistortingCallback
161 {
162 public:
164  virtual ~DistortingCallback() {}
165 
166  virtual bool OnDistorting() { return false; }
167 };
168 
174 enum class UVStyle
175 {
176  Normal,
178 };
179 
186 {
187  White,
188  Normal,
189 };
190 
196 class GraphicsDevice : public ::Effekseer::IReference
197 {
198 public:
199  GraphicsDevice() = default;
200  virtual ~GraphicsDevice() = default;
201 };
202 
203 class CommandList : public ::Effekseer::IReference
204 {
205 public:
206  CommandList() = default;
207  virtual ~CommandList() = default;
208 };
209 
210 class SingleFrameMemoryPool : public ::Effekseer::IReference
211 {
212 public:
213  SingleFrameMemoryPool() = default;
214  virtual ~SingleFrameMemoryPool() = default;
215 
221  virtual void NewFrame() {}
222 };
223 
224 class Renderer
225  : public ::Effekseer::IReference
226 {
227 protected:
228  Renderer();
229  virtual ~Renderer();
230 
231  class Impl;
232  Impl* impl = nullptr;
233 
234 public:
235 
239  Impl* GetImpl();
240 
244  virtual void OnLostDevice() = 0;
245 
249  virtual void OnResetDevice() = 0;
250 
254  virtual void Destroy() = 0;
255 
259  virtual void SetRestorationOfStatesFlag(bool flag) = 0;
260 
264  virtual bool BeginRendering() = 0;
265 
269  virtual bool EndRendering() = 0;
270 
274  virtual ::Effekseer::Vector3D GetLightDirection() const;
275 
279  virtual void SetLightDirection(const ::Effekseer::Vector3D& direction);
280 
284  virtual const ::Effekseer::Color& GetLightColor() const;
285 
289  virtual void SetLightColor(const ::Effekseer::Color& color);
290 
294  virtual const ::Effekseer::Color& GetLightAmbientColor() const;
295 
299  virtual void SetLightAmbientColor(const ::Effekseer::Color& color);
300 
304  virtual int32_t GetSquareMaxCount() const = 0;
305 
309  virtual ::Effekseer::Matrix44 GetProjectionMatrix() const;
310 
314  virtual void SetProjectionMatrix( const ::Effekseer::Matrix44& mat );
315 
319  virtual ::Effekseer::Matrix44 GetCameraMatrix() const;
320 
324  virtual void SetCameraMatrix( const ::Effekseer::Matrix44& mat );
325 
329  virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const;
330 
336  virtual ::Effekseer::Vector3D GetCameraFrontDirection() const;
337 
343  virtual ::Effekseer::Vector3D GetCameraPosition() const;
344 
352  virtual void SetCameraParameter(const ::Effekseer::Vector3D& front, const ::Effekseer::Vector3D& position);
353 
357  virtual ::Effekseer::SpriteRenderer* CreateSpriteRenderer() = 0;
358 
362  virtual ::Effekseer::RibbonRenderer* CreateRibbonRenderer() = 0;
363 
367  virtual ::Effekseer::RingRenderer* CreateRingRenderer() = 0;
368 
372  virtual ::Effekseer::ModelRenderer* CreateModelRenderer() = 0;
373 
377  virtual ::Effekseer::TrackRenderer* CreateTrackRenderer() = 0;
378 
382  virtual ::Effekseer::TextureLoader* CreateTextureLoader( ::Effekseer::FileInterface* fileInterface = NULL ) = 0;
383 
387  virtual ::Effekseer::ModelLoader* CreateModelLoader( ::Effekseer::FileInterface* fileInterface = NULL ) = 0;
388 
395  virtual ::Effekseer::MaterialLoader* CreateMaterialLoader(::Effekseer::FileInterface* fileInterface = nullptr) = 0;
396 
400  virtual void ResetRenderState() = 0;
401 
405  virtual DistortingCallback* GetDistortingCallback() = 0;
406 
410  virtual void SetDistortingCallback(DistortingCallback* callback) = 0;
411 
417  virtual int32_t GetDrawCallCount() const;
418 
424  virtual int32_t GetDrawVertexCount() const;
425 
431  virtual void ResetDrawCallCount();
432 
438  virtual void ResetDrawVertexCount();
439 
445  virtual Effekseer::RenderMode GetRenderMode() const;
446 
452  virtual void SetRenderMode(Effekseer::RenderMode renderMode);
453 
459  virtual UVStyle GetTextureUVStyle() const;
460 
466  virtual void SetTextureUVStyle(UVStyle style);
467 
473  virtual UVStyle GetBackgroundTextureUVStyle() const;
474 
480  virtual void SetBackgroundTextureUVStyle(UVStyle style);
481 
487  virtual float GetTime() const;
488 
494  virtual void SetTime(float time);
495 
501  virtual void SetCommandList(CommandList* commandList) {}
502 
511  virtual void SetBackgroundTexture(::Effekseer::TextureData* textureData);
512 
519 
526 };
527 
528 //----------------------------------------------------------------------------------
529 //
530 //----------------------------------------------------------------------------------
531 }
532 //----------------------------------------------------------------------------------
533 //
534 //----------------------------------------------------------------------------------
535 #endif // __EFFEKSEERRENDERER_RENDERER_H__
536 
537 #ifndef __EFFEKSEERRENDERER_GL_RENDERER_H__
538 #define __EFFEKSEERRENDERER_GL_RENDERER_H__
539 
540 //----------------------------------------------------------------------------------
541 // Include
542 //----------------------------------------------------------------------------------
543 
544 //----------------------------------------------------------------------------------
545 // Lib
546 //----------------------------------------------------------------------------------
547 
548 //----------------------------------------------------------------------------------
549 //
550 //----------------------------------------------------------------------------------
551 namespace EffekseerRendererGL
552 {
553 
554 class DeviceObjectCollection;
555 
556 //----------------------------------------------------------------------------------
557 //
558 //----------------------------------------------------------------------------------
559 
564 
569 
573 class Renderer
575 {
576 protected:
577  Renderer() {}
578  virtual ~Renderer() {}
579 
580 public:
598  static Renderer* Create(int32_t squareMaxCount,
600  DeviceObjectCollection* deviceObjectCollection = nullptr);
601 
605  virtual int32_t GetSquareMaxCount() const = 0;
606 
612  virtual void SetSquareMaxCount(int32_t count) = 0;
613 
619  virtual Effekseer::TextureData* GetBackground() = 0;
620 
626  virtual void SetBackground(GLuint background, bool hasMipmap = false) = 0;
627 
633  virtual OpenGLDeviceType GetDeviceType() const = 0;
634 
640  virtual bool IsVertexArrayObjectSupported() const = 0;
641 };
642 
643 //----------------------------------------------------------------------------------
644 //
645 //----------------------------------------------------------------------------------
649 class Model
650  : public Effekseer::Model
651 {
652 private:
653 
654 public:
656  {
661 
662  std::vector<uint8_t> delayVertexBuffer;
663  std::vector<uint8_t> delayIndexBuffer;
664 
665  InternalModel();
666 
667  virtual ~InternalModel();
668 
669  bool TryDelayLoad();
670  };
671 
672 
675 
676 
677  Model(void* data, int32_t size);
678  ~Model();
679 };
680 
681 //----------------------------------------------------------------------------------
682 //
683 //----------------------------------------------------------------------------------
684 }
685 //----------------------------------------------------------------------------------
686 //
687 //----------------------------------------------------------------------------------
688 #endif // __EFFEKSEERRENDERER_GL_RENDERER_H__
virtual void ResetDrawCallCount()
Reset draw call count.
virtual void ResetDrawVertexCount()
Reset the number of vertex drawn.
virtual OpenGLDeviceType GetDeviceType() const =0
get a device type
virtual void SetCameraMatrix(const ::Effekseer::Matrix44 &mat)
Set a camera matrix.
virtual void SetTime(float time)
Set a current time (s)
virtual ::Effekseer::TrackRenderer * CreateTrackRenderer()=0
軌跡レンダラーを生成する。
signed int int32_t
virtual int32_t GetSquareMaxCount() const =0
最大描画スプライト数を取得する。
virtual void SetBackground(GLuint background, bool hasMipmap=false)=0
Specify a background.
virtual float GetTime() const
Get a current time (s)
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
virtual ::Effekseer::MaterialLoader * CreateMaterialLoader(::Effekseer::FileInterface *fileInterface=nullptr)=0
Create default material loader.
virtual void SetCommandList(CommandList *commandList)
specify a command list to render. This function is available except DirectX9, DirectX11 and OpenGL.
virtual void SetSquareMaxCount(int32_t count)=0
最大描画スプライト数を設定する。
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
virtual void SetLightColor(const ::Effekseer::Color &color)
Specify the color of light.
virtual UVStyle GetTextureUVStyle() const
Get an UV Style of texture when particles are rendered.
virtual void SetBackgroundTextureUVStyle(UVStyle style)
Set an UV Style of background when particles are rendered.
virtual void DeleteProxyTexture(Effekseer::TextureData *data)
Delete a proxy texture.
virtual ::Effekseer::RingRenderer * CreateRingRenderer()=0
リングレンダラーを生成する。
virtual ~CommandList()=default
static Renderer * Create(int32_t squareMaxCount, OpenGLDeviceType deviceType=OpenGLDeviceType::OpenGL2, DeviceObjectCollection *deviceObjectCollection=nullptr)
Create an instance the number of maximum sprites device type of opengl for a middleware....
factory class for io
Definition: Effekseer.h:1484
GLsizeiptr size
virtual void SetCameraParameter(const ::Effekseer::Vector3D &front, const ::Effekseer::Vector3D &position)
Set a front direction and position of camera manually.
virtual void SetRenderMode(Effekseer::RenderMode renderMode)
Specify a render mode.
virtual bool BeginRendering()=0
描画を開始する時に実行する。
virtual int32_t GetSquareMaxCount() const =0
最大描画スプライト数を取得する。
Texture data.
Definition: Effekseer.h:541
virtual ::Effekseer::Vector3D GetCameraFrontDirection() const
Get a front direction of camera.
virtual void SetLightDirection(const ::Effekseer::Vector3D &direction)
Specifiy the direction of light.
virtual ::Effekseer::SpriteRenderer * CreateSpriteRenderer()=0
スプライトレンダラーを生成する。
virtual void SetProjectionMatrix(const ::Effekseer::Matrix44 &mat)
Set a projection matrix.
virtual Effekseer::RenderMode GetRenderMode() const
Get a render mode.
virtual void NewFrame()
notify that new frame is started.
::Effekseer::TextureLoader * CreateTextureLoader(::Effekseer::FileInterface *fileInterface=nullptr, ::Effekseer::ColorSpaceType colorSpaceType=::Effekseer::ColorSpaceType::Gamma)
テクスチャ読込クラスを生成する。
virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const
Get a camera projection matrix.
virtual ::Effekseer::ModelRenderer * CreateModelRenderer()=0
モデルレンダラーを生成する。
virtual int32_t GetDrawCallCount() const
Get draw call count.
テクスチャ読み込み破棄関数指定クラス
Definition: Effekseer.h:3012
モデル読み込み破棄関数指定クラス
Definition: Effekseer.h:3091
virtual void ResetRenderState()=0
レンダーステートを強制的にリセットする。
virtual void SetRestorationOfStatesFlag(bool flag)=0
ステートを復帰するかどうかのフラグを設定する。
virtual void OnLostDevice()=0
デバイスロストが発生した時に実行する。
Model(void *data, int32_t size)
void OnResetDevice()
Call when device reset causes.
virtual ::Effekseer::TextureLoader * CreateTextureLoader(::Effekseer::FileInterface *fileInterface=NULL)=0
標準のテクスチャ読込クラスを生成する。
virtual ::Effekseer::Vector3D GetCameraPosition() const
Get a position of camera.
ProxyTextureType
A type of texture which is rendered when textures are not assigned.
参照カウンタのインターフェース
Definition: Effekseer.h:416
Impl * GetImpl()
only for Effekseer backend developer. Effekseer User doesn't need it.
virtual void SetBackgroundTexture(::Effekseer::TextureData *textureData)
Specify a background texture. Specified texture is not deleted by the renderer. This function is avai...
#define NULL
Definition: begin_code.h:167
virtual bool IsVertexArrayObjectSupported() const =0
get whether VAO is supported
unsigned int GLuint
Definition: SDL_opengl.h:185
virtual ::Effekseer::ModelLoader * CreateModelLoader(::Effekseer::FileInterface *fileInterface=NULL)=0
標準のモデル読込クラスを生成する。
virtual void SetDistortingCallback(DistortingCallback *callback)=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを設定する。
virtual void Destroy()=0
このインスタンスを破棄する。
virtual Effekseer::TextureData * GetBackground()=0
Get a background.
GLuint color
Model class.
Definition: Effekseer.h:3244
UVStyle
A status of UV when particles are rendered.
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
virtual const ::Effekseer::Color & GetLightColor() const
Get the color of light.
virtual ::Effekseer::Matrix44 GetProjectionMatrix() const
Get a projection matrix.
virtual DistortingCallback * GetDistortingCallback()=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを取得する。
virtual ::Effekseer::Vector3D GetLightDirection() const
Get the direction of light.
virtual UVStyle GetBackgroundTextureUVStyle() const
Get an UV Style of background when particles are rendered.
virtual int32_t GetDrawVertexCount() const
Get the number of vertex drawn.
virtual void SetLightAmbientColor(const ::Effekseer::Color &color)
Specify the color of ambient.
virtual Effekseer::TextureData * CreateProxyTexture(ProxyTextureType type)
Create a proxy texture.
::Effekseer::ModelLoader * CreateModelLoader(::Effekseer::FileInterface *fileInterface=NULL)
モデル読込クラスを生成する。
virtual ::Effekseer::Matrix44 GetCameraMatrix() const
Get a camera matrix.
virtual void SetTextureUVStyle(UVStyle style)
Set an UV Style of texture when particles are rendered.
参照カウンタオブジェクト
Definition: Effekseer.h:473
virtual bool EndRendering()=0
描画を終了する時に実行する。
virtual ::Effekseer::RibbonRenderer * CreateRibbonRenderer()=0
リボンレンダラーを生成する。
virtual void OnResetDevice()=0
デバイスがリセットされた時に実行する。
virtual const ::Effekseer::Color & GetLightAmbientColor() const
Get the color of ambient.
void OnLostDevice()
Call when device lost causes.