Oxygine  1
2g game engine
Stage.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "Actor.h"
4 
5 
6 namespace oxygine
7 {
8  DECLARE_SMART(Stage, spStage);
9  class Stage : public Actor
10  {
11  INHERITED(Actor);
12  public:
13  enum
14  {
15  ACTIVATE = sysEventID('S', 'A', 'c'),
16  DEACTIVATE = sysEventID('S', 'D', 'c'),
17  LOST_CONTEXT = sysEventID('S', 'L', 'C'),
18  };
19 
20  static spStage instance;
21  static Rect calcCenteredViewport(const Point& displaySize, const Point& gameSize);
22 
23  Stage(bool autoHandleReset = false);
24  ~Stage();
25 
30  void init(const Point& displaySize, const Point& gameSize);
31 
33  void setClipOuterArea(bool clip) {_clipOuter = clip;}
35  void render(const Color* clearColor, const Rect& viewport, const Matrix& view, const Matrix& proj);
37  void render(const Color& clearColor, const Rect& viewport);
38 
39  //const Rect &getArea();
40 
42  void update();
43 
44  void cleanup();
45 
46  RectF getDestRect() const override;
47 
48 
49  std::string dump(const dumpOptions& opt) const override;
50 
51 #if OXYGINE_SDL
52  void associateWithWindow(SDL_Window* wnd);
53  SDL_Window* getAssociatedWindow() const;
54  static Stage* getStageFromWindow(SDL_Window* wnd);
55 #endif
56 
57  protected:
58  void onDeactivate(Event*);
59  void onActivate(Event*);
60 
61  //bool _active;
62 
63  bool isOn(const Vector2& localPosition, float localScale) override;
64 
65  private:
66 
67  timeMS _statUpdate;
68  bool _clipOuter;
69  Rect _viewport;
70 
71 #if OXYGINE_SDL
72  SDL_Window* _window;
73 #endif // OXYGINE_SDL
74 
75 
76  friend class DebugActor;
77  };
78 
79  inline const spStage& getStage() {return Stage::instance;}
80 }
void setClipOuterArea(bool clip)
Definition: Stage.h:33
Definition: Actor.h:42
Definition: Event.h:10
Definition: DebugActor.h:11
std::string dump(const dumpOptions &opt) const override
–oxgl-end–!
Definition: Actor.h:14
void init(const Point &displaySize, const Point &gameSize)
bool isOn(const Vector2 &localPosition, float localScale) override
void render(const Color *clearColor, const Rect &viewport, const Matrix &view, const Matrix &proj)
Definition: Color.h:8
Definition: Stage.h:9