Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
renderable.hpp
1 //////////////////////////////
2 //
3 // File: lxs/coregraphics/renderable.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Nov 27 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_RENDERABLE__
15 #define __LXS_RENDERABLE__
16 #include<list>
17 
18 
19 namespace LxS
20 {
21  namespace CoreGraphics
22  {
23  class Shader;
24  class Model;
25  //! @brief main interface for "renderable" objects,
26  //!
27  //! Renderable, that is self-contained thing that CAN be rendered (be it a 3D model, a map or player character (incorporating various renderables), form, anything.
29  {
30  public:
31  IRenderable(){}
32  virtual ~IRenderable() {}
33  //! purpose of rendering. ForReal is "to display", ForCoords3D is "to determine where user has clicked"
34  enum
35  Rendermode {
36  //! proper rendering for display
38  //! rendering for coordinate detection
40  //! for detection of ingame coordinate system - unused
42  //! set up resources. (this is to facilitate late (delayed) initialization.
43  virtual void Initialize() =0; // load and set up some resources
44  //! render something
45  virtual void Render(Rendermode mode) =0 ;
46  //! free up consumed resources while (possibly temporarily) object is not critical
47  virtual void UnloadResources() =0;
48  //! move contents dt=delta time in seconds since last call to animate;
49  virtual void Animate(float dt) = 0;
50  //! sum of dimensionsxdepths of all textures
51  virtual unsigned long GetTexelsCount() = 0;
52  //! all 3D faces
53  virtual unsigned long GetFacesCount() = 0;
54  //! 0= uninitialized; 100=ready; other? for progress bars
55  virtual float GetInitializedPercentage()=0;
56  //! To facilitate refreshing app after switching OpenGL Context (as in Android lifecycle)
57  virtual void RefreshAssets() =0;
58  };
59 
60  //! basic class for most of implementations of IRenderable interface.
61  class Renderable : public IRenderable
62  {
63  protected:
64  //! 0-100; 0- just constructed; 100 - redy to render; 0-100 - for progressbar
66  public:
67  Renderable();
69  virtual ~Renderable() {}
70  virtual void RefreshAssets() {Initialize();}
71  };
72  }
73 }
74 
75 #endif