123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #ifndef CORE_WINDOW_H
- #define CORE_WINDOW_H
- void window(void);
- /*namespace Window {
- typedef bool (*ShouldRun)();
- typedef void (*Tick)();
- typedef void (*Render)(float);
- struct Options final {
- int majorVersion;
- int minorVersion;
- const IntVector2& size;
- bool fullscreen;
- bool es;
- bool vsync;
- const char* name;
- Options(int majorVersion, int minorVersion, const IntVector2& size,
- bool es, const char* name);
- };
- Error open(const Options& options);
- void close();
- float getTicksPerSecond();
- float getFramesPerSecond();
- void trapCursor();
- void freeCursor();
- bool isCursorTrapped();
- const IntVector2& getSize();
- bool hasSizeChanged();
- void show();
- bool shouldClose();
- Error startFrame(Clock::Nanos& n);
- void endFrame();
- Error tick();
- void postTick();
- template<ShouldRun SR, Tick T, Render R>
- Error run(Clock::Nanos nanosPerTick) {
- Clock::Nanos lag = 0;
- while(SR()) {
- Clock::Nanos passedTime = 0;
- Error e = startFrame(passedTime);
- if(e.has()) {
- return e;
- }
- lag += passedTime;
- while(lag >= nanosPerTick) {
- lag -= nanosPerTick;
- e = tick();
- if(e.has()) {
- return e;
- }
- T();
- postTick();
- }
- R(static_cast<float>(lag) / static_cast<float>(nanosPerTick));
- endFrame();
- }
- return Error();
- }
- namespace Input {
- void setLimit(int limit);
- void reset();
- void enable();
- void disable();
- bool isEnabled();
- void fill(const char* s);
- int getCursor();
- void setCursor(int index);
- const List<uint32>& getUnicode();
- template<int N>
- void toString(StringBuffer<N>& s) {
- for(uint32 c : getUnicode()) {
- s.appendUnicode(c);
- }
- }
- }
- namespace Controls {
- typedef StringBuffer<32> ButtonName;
- typedef int ButtonId;
- ButtonId add(const ButtonName& name);
- void bindKey(ButtonId id, int key);
- void bindGamepad(ButtonId id, int gamepadButton);
- void bindMouse(ButtonId id, int mouseButton);
- Vector2 getLastMousePosition();
- Vector2 getMousePosition();
- Vector2 getLeftGamepadAxis();
- Vector2 getRightGamepadAxis();
- float getLeftGamepadTrigger();
- float getRightGamepadTrigger();
- bool isDown(ButtonId id);
- int getDownTime(ButtonId id);
- bool wasReleased(ButtonId id);
- const ButtonName& getName(ButtonId id);
- }
- }*/
- #endif
|