diff options
| author | Yong He <yonghe@outlook.com> | 2021-04-16 10:34:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-16 10:34:26 -0700 |
| commit | 79e92395f8ce3d92c446e3bb3250d19ce33decd5 (patch) | |
| tree | 2ac277fa299200da72cf03a2b5b96338f66aee5d /examples/example-base/example-base.h | |
| parent | bad484d838590d0a2aaf1b5b8ac820634af2decb (diff) | |
Update `model-viewer` example and fixing compiler bugs. (#1795)
Diffstat (limited to 'examples/example-base/example-base.h')
| -rw-r--r-- | examples/example-base/example-base.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/example-base/example-base.h b/examples/example-base/example-base.h index ab7522f06..67f722c11 100644 --- a/examples/example-base/example-base.h +++ b/examples/example-base/example-base.h @@ -4,6 +4,10 @@ #include "tools/platform/window.h" #include "source/core/slang-basic.h" +#ifdef _WIN32 +void _Win32OutputDebugString(const char* str); +#endif + struct WindowedAppBase { protected: @@ -35,6 +39,40 @@ public: virtual void finalize() { gQueue->wait(); } }; +int64_t getCurrentTime(); +int64_t getTimerFrequency(); + +template<typename ... TArgs> inline void reportError(const char* format, TArgs... args) +{ + printf(format, args...); +#ifdef _WIN32 + char buffer[4096]; + sprintf_s(buffer, format, args...); + _Win32OutputDebugString(buffer); +#endif +} + +template <typename... TArgs> inline void log(const char* format, TArgs... args) +{ + reportError(format, args...); +} + +// Many Slang API functions return detailed diagnostic information +// (error messages, warnings, etc.) as a "blob" of data, or return +// a null blob pointer instead if there were no issues. +// +// For convenience, we define a subroutine that will dump the information +// in a diagnostic blob if one is produced, and skip it otherwise. +// +inline void diagnoseIfNeeded(slang::IBlob* diagnosticsBlob) +{ + if (diagnosticsBlob != nullptr) + { + reportError("%s", (const char*)diagnosticsBlob->getBufferPointer()); + } +} + + template<typename TApp> int innerMain() { |
