absence_thelab
diff src/demosystem/demosys.h @ 0:1cffe3409164
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Oct 2014 01:46:07 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/demosystem/demosys.h Thu Oct 23 01:46:07 2014 +0300 1.3 @@ -0,0 +1,97 @@ 1.4 +#ifndef _DEMOSYS_H_ 1.5 +#define _DEMOSYS_H_ 1.6 + 1.7 +#include <list> 1.8 +#include "typedefs.h" 1.9 +#include "timing.h" 1.10 + 1.11 +#ifdef NUC3D_API_OPENGL 1.12 +#include "n3dgl/nuc3dhw.h" 1.13 +#else 1.14 +#include "3deng/3deng.h" 1.15 +#endif 1.16 + 1.17 +enum {TIMETYPE_ABSOLUTE, TIMETYPE_RELATIVE}; 1.18 +enum RenderMode {RenderModeNormal, RenderModeTexture}; 1.19 + 1.20 +// ----- Abstract Base Class Part ----- 1.21 +class Part { 1.22 +protected: 1.23 + GraphicsContext *gc; 1.24 + Scene *scene; // REMOVE 1.25 + 1.26 + dword StartTime, EndTime, Duration; // in milliseconds 1.27 + Timer timer; // local part timer 1.28 + 1.29 + Texture *RenderTexture; 1.30 + RenderMode rmode; 1.31 + 1.32 + bool paused; 1.33 + 1.34 +public: 1.35 + 1.36 + Part(); 1.37 + 1.38 + virtual void SetGraphicsContext(GraphicsContext *gc); 1.39 + virtual GraphicsContext *GetGraphicsContext(); 1.40 + 1.41 + virtual void SetTimingAbs(dword start, dword end); 1.42 + virtual void SetTimingRel(dword start, dword dur); 1.43 + virtual void Pause(); 1.44 + virtual void Resume(); 1.45 + 1.46 + virtual dword GetStartTime() const; 1.47 + virtual dword GetEndTime() const; 1.48 + virtual dword GetDuration() const; 1.49 + virtual dword GetTimePosition() const; 1.50 + virtual float GetParametricPosition() const; 1.51 + 1.52 + virtual void SetRenderMode(RenderMode rmode); 1.53 + virtual void SetRenderTexture(Texture *tex); 1.54 + 1.55 + virtual RenderMode GetRenderMode() const; 1.56 + virtual Texture *GetRenderTexture() const; 1.57 + 1.58 + virtual void Launch(); 1.59 + virtual void ShutDown(); 1.60 + virtual void MainLoop() = 0; 1.61 + 1.62 + virtual Scene *GetScene(); 1.63 +}; 1.64 + 1.65 +enum DemoState {DemoStateRunning, DemoStateStopped, DemoStatePaused}; 1.66 + 1.67 +class DemoSystem { 1.68 +private: 1.69 + GraphicsContext *gc; 1.70 + 1.71 + std::list<Part*> parts; // list of all parts 1.72 + std::list<Part*> active; // currently running 1.73 + std::list<Part*> inactive; // waiting to run 1.74 + 1.75 + Timer timer; // global demo timer 1.76 + DemoState state; 1.77 + 1.78 +public: 1.79 + 1.80 + DemoSystem(GraphicsContext *gc); 1.81 + 1.82 + void AddPart(Part *part); 1.83 + Part *GetActivePart(); 1.84 + 1.85 + void Run(); 1.86 + void Pause(); 1.87 + void Resume(); 1.88 + void Stop(); 1.89 + 1.90 + void Update(); 1.91 + 1.92 + int LoadTiming(const char *filename); 1.93 +}; 1.94 + 1.95 + 1.96 +/////////////// exceptions ////////////// 1.97 +class InvalidParam{}; 1.98 + 1.99 + 1.100 +#endif //_DEMOSYS_H_ 1.101 \ No newline at end of file