diff options
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry.h')
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry.h | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry.h b/3rdparty/bgfx/examples/common/entry/entry.h index 75cbeb26ca3..443066e304f 100644 --- a/3rdparty/bgfx/examples/common/entry/entry.h +++ b/3rdparty/bgfx/examples/common/entry/entry.h @@ -1,12 +1,13 @@ /* - * Copyright 2011-2018 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + * Copyright 2011-2022 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE */ #ifndef ENTRY_H_HEADER_GUARD #define ENTRY_H_HEADER_GUARD #include "dbg.h" +#include <bgfx/bgfx.h> #include <bx/bx.h> #include <bx/filepath.h> #include <bx/string.h> @@ -24,25 +25,31 @@ extern "C" int _main_(int _argc, char** _argv); #endif // ENTRY_CONFIG_IMPLEMENT_MAIN #if ENTRY_CONFIG_IMPLEMENT_MAIN -#define ENTRY_IMPLEMENT_MAIN(_app, _name, _description) \ +#define ENTRY_IMPLEMENT_MAIN(_app, ...) \ int _main_(int _argc, char** _argv) \ { \ - _app app(_name, _description); \ + _app app(__VA_ARGS__); \ return entry::runApp(&app, _argc, _argv); \ } #else -#define ENTRY_IMPLEMENT_MAIN(_app, _name, _description) \ - _app s_ ## _app ## App(_name, _description) +#define ENTRY_IMPLEMENT_MAIN(_app, ...) \ + _app s_ ## _app ## App(__VA_ARGS__) #endif // ENTRY_CONFIG_IMPLEMENT_MAIN +/// +#define ENTRY_HANDLE(_name) \ + struct _name { uint16_t idx; }; \ + inline bool isValid(_name _handle) { return UINT16_MAX != _handle.idx; } + namespace entry { - struct WindowHandle { uint16_t idx; }; - inline bool isValid(WindowHandle _handle) { return UINT16_MAX != _handle.idx; } + ENTRY_HANDLE(WindowHandle); + ENTRY_HANDLE(GamepadHandle); - struct GamepadHandle { uint16_t idx; }; - inline bool isValid(GamepadHandle _handle) { return UINT16_MAX != _handle.idx; } + /// + constexpr WindowHandle kDefaultWindowHandle = { 0 }; + /// struct MouseButton { enum Enum @@ -56,6 +63,7 @@ namespace entry }; }; + /// struct GamepadAxis { enum Enum @@ -71,6 +79,7 @@ namespace entry }; }; + /// struct Modifier { enum Enum @@ -87,6 +96,7 @@ namespace entry }; }; + /// struct Key { enum Enum @@ -198,6 +208,7 @@ namespace entry }; }; + /// struct Suspend { enum Enum @@ -211,8 +222,10 @@ namespace entry }; }; + /// const char* getName(Key::Enum _key); + /// struct MouseState { MouseState() @@ -232,6 +245,7 @@ namespace entry uint8_t m_buttons[entry::MouseButton::Count]; }; + /// struct GamepadState { GamepadState() @@ -242,22 +256,55 @@ namespace entry int32_t m_axis[entry::GamepadAxis::Count]; }; + /// bool processEvents(uint32_t& _width, uint32_t& _height, uint32_t& _debug, uint32_t& _reset, MouseState* _mouse = NULL); + /// bx::FileReaderI* getFileReader(); + + /// bx::FileWriterI* getFileWriter(); + + /// bx::AllocatorI* getAllocator(); + /// WindowHandle createWindow(int32_t _x, int32_t _y, uint32_t _width, uint32_t _height, uint32_t _flags = ENTRY_WINDOW_FLAG_NONE, const char* _title = ""); + + /// void destroyWindow(WindowHandle _handle); + + /// void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y); + + /// void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height); + + /// void setWindowTitle(WindowHandle _handle, const char* _title); + + /// void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled); + + /// void toggleFullscreen(WindowHandle _handle); + + /// void setMouseLock(WindowHandle _handle, bool _lock); + + /// + void* getNativeWindowHandle(WindowHandle _handle); + + /// + void* getNativeDisplayHandle(); + + /// + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle); + + /// void setCurrentDir(const char* _dir); + /// struct WindowState { WindowState() @@ -276,13 +323,15 @@ namespace entry bx::FilePath m_dropFile; }; + /// bool processWindowEvents(WindowState& _state, uint32_t& _debug, uint32_t& _reset); + /// class BX_NO_VTABLE AppI { public: /// - AppI(const char* _name, const char* _description); + AppI(const char* _name, const char* _description, const char* _url = "https://bkaradzic.github.io/bgfx/index.html"); /// virtual ~AppI() = 0; @@ -303,13 +352,13 @@ namespace entry const char* getDescription() const; /// - AppI* getNext(); + const char* getUrl() const; - AppI* m_next; + /// + AppI* getNext(); private: - const char* m_name; - const char* m_description; + BX_ALIGN_DECL(16, uintptr_t) m_internal[4]; }; /// |