Oxygine  1
2g game engine
ResAtlas.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "Resource.h"
4 #include "ResAnim.h"
5 #include "CreateResourceContext.h"
6 
7 namespace oxygine
8 {
9  class ResAtlas: public Resource
10  {
11  INHERITED(Resource);
12  public:
13  static Resource* create(CreateResourceContext& context);
14  struct atlas
15  {
16  spNativeTexture base;
17  std::string base_path;
18 
19  spNativeTexture alpha;
20  std::string alpha_path;
21  };
22 
23 
24  ResAtlas();
25  ~ResAtlas();
26 
27  void addAtlas(TextureFormat tf, const std::string& base, const std::string& alpha, int w, int h);
28 
29  const atlas& getAtlas(int i) const {return _atlasses[i];}
30  int getNum() const { return (int)_atlasses.size(); }
31 
32  protected:
33  void _restore(Restorable* r, void* user);
34 
35  void _load(LoadResourcesContext*) override;
36  void _unload() override;
37 
38  //void loadAtlas(CreateResourceContext& context);
39  ResAnim* createEmpty(const XmlWalker& walker, CreateResourceContext& context);
40  static void init_resAnim(ResAnim* rs, const std::string& file, pugi::xml_node node);
41 
42  protected:
43  //settings from xml
44  bool _linearFilter;
45  bool _clamp2edge;
46 
47  void loadBase(pugi::xml_node node);
48 
49  std::vector<unsigned char> _hitTestBuffer;
50 
51  typedef std::vector<atlas> atlasses;
52  atlasses _atlasses;
53  };
54 
55  typedef void(*load_texture_hook)(const std::string& file, spNativeTexture nt, bool linearFilter, bool clamp2edge, LoadResourcesContext* load_context);
56  void set_load_texture_hook(load_texture_hook);
57  void load_texture_internal(const std::string& file, spNativeTexture nt, bool linearFilter, bool clamp2edge, LoadResourcesContext* load_context);
58 }
Definition: ResAtlas.h:9
–oxgl-end–!
Definition: Actor.h:14
Definition: Resource.h:10
Definition: ResAtlas.h:14
Definition: CreateResourceContext.h:60