aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/direct3d/evas_direct3d_scene.h
blob: e2f5f944ce0ea686ace80278ef5dad5af98ca3a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef __EVAS_DIRECT3D_SCENE_H__
#define __EVAS_DIRECT3D_SCENE_H__

#include "evas_engine.h"

#include <assert.h>
#include <typeinfo>

#include "ref.h"
#include "array.h"

#include "evas_direct3d_object.h"

class D3DDevice;

class D3DScene : virtual public Referenc
{
public:
   D3DScene();

   void FreeObjects();

   inline void AddObject(D3DObject *object);
   inline int GetObjectCount();
   void DeleteObject(D3DObject *object);

   void DrawAll(D3DDevice *d3d);

   template <class T> T *GetFreeObject()
   {
      for (int i = 0; i < _objects.Length(); i++)
      {
         if (typeid(T) == typeid(*_objects[i].Addr()) && _objects[i]->IsFree())
            return (T *)_objects[i].Addr();
      }
      return NULL;
   }

   template <class T> void GetObjectsOfType(TArray<T *> &res)
   {
      for (int i = 0; i < _objects.Length(); i++)
      {
         if (typeid(T) == typeid(*_objects[i].Addr()))
            res.Add((T *)_objects[i].Addr());
      }
   }

private:
   TArray<Ref<D3DObject> > _objects;
};

void D3DScene::AddObject(D3DObject *object)
{
   assert(object != NULL);
   _objects.Add(object);
}

int D3DScene::GetObjectCount()
{
   return _objects.Length();
}

#endif  // __EVAS_DIRECT3D_SCENE_H__