absence_thelab

view src/demosystem/demosys.h @ 1:4d5933c261c3

todo and .hgignore
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 02:18:43 +0300
parents
children
line source
1 #ifndef _DEMOSYS_H_
2 #define _DEMOSYS_H_
4 #include <list>
5 #include "typedefs.h"
6 #include "timing.h"
8 #ifdef NUC3D_API_OPENGL
9 #include "n3dgl/nuc3dhw.h"
10 #else
11 #include "3deng/3deng.h"
12 #endif
14 enum {TIMETYPE_ABSOLUTE, TIMETYPE_RELATIVE};
15 enum RenderMode {RenderModeNormal, RenderModeTexture};
17 // ----- Abstract Base Class Part -----
18 class Part {
19 protected:
20 GraphicsContext *gc;
21 Scene *scene; // REMOVE
23 dword StartTime, EndTime, Duration; // in milliseconds
24 Timer timer; // local part timer
26 Texture *RenderTexture;
27 RenderMode rmode;
29 bool paused;
31 public:
33 Part();
35 virtual void SetGraphicsContext(GraphicsContext *gc);
36 virtual GraphicsContext *GetGraphicsContext();
38 virtual void SetTimingAbs(dword start, dword end);
39 virtual void SetTimingRel(dword start, dword dur);
40 virtual void Pause();
41 virtual void Resume();
43 virtual dword GetStartTime() const;
44 virtual dword GetEndTime() const;
45 virtual dword GetDuration() const;
46 virtual dword GetTimePosition() const;
47 virtual float GetParametricPosition() const;
49 virtual void SetRenderMode(RenderMode rmode);
50 virtual void SetRenderTexture(Texture *tex);
52 virtual RenderMode GetRenderMode() const;
53 virtual Texture *GetRenderTexture() const;
55 virtual void Launch();
56 virtual void ShutDown();
57 virtual void MainLoop() = 0;
59 virtual Scene *GetScene();
60 };
62 enum DemoState {DemoStateRunning, DemoStateStopped, DemoStatePaused};
64 class DemoSystem {
65 private:
66 GraphicsContext *gc;
68 std::list<Part*> parts; // list of all parts
69 std::list<Part*> active; // currently running
70 std::list<Part*> inactive; // waiting to run
72 Timer timer; // global demo timer
73 DemoState state;
75 public:
77 DemoSystem(GraphicsContext *gc);
79 void AddPart(Part *part);
80 Part *GetActivePart();
82 void Run();
83 void Pause();
84 void Resume();
85 void Stop();
87 void Update();
89 int LoadTiming(const char *filename);
90 };
93 /////////////// exceptions //////////////
94 class InvalidParam{};
97 #endif //_DEMOSYS_H_