platformEmscripten.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. // Portions Copyright (c) 2014 James S Urquhart
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //-----------------------------------------------------------------------------
  23. #ifndef _PLATFORMEMSCRIPTEN_H_
  24. #define _PLATFORMEMSCRIPTEN_H_
  25. #include "platform/platform.h"
  26. #include "math/mMath.h"
  27. #include "platformEmscripten/EmscriptenOGLVideo.h"
  28. #include <SDL/SDL.h>
  29. #define PREF_DIR_ROOT "/.torque"
  30. #define PREF_DIR_GAME_NAME "T2D"
  31. // event codes for custom SDL events
  32. const S32 TORQUE_SETVIDEOMODE = 1;
  33. class EmscriptenPlatState
  34. {
  35. public:
  36. bool captureDisplay;
  37. bool fadeWindows;
  38. char appWindowTitle[256];
  39. bool quit;
  40. bool ctxNeedsUpdate;
  41. bool portrait;
  42. U32 currentTime;
  43. bool fullscreen;
  44. U32 osVersion;
  45. U32 firstThreadId;
  46. U32 torqueThreadId;
  47. RandomLCG platRandom;
  48. bool mouseLocked;
  49. bool backgrounded;
  50. bool minimized;
  51. U32 sleepTicks;
  52. U32 lastTimeTick;
  53. Point2I windowSize;
  54. bool windowCreated;
  55. U32 appReturn;
  56. int argc;
  57. const char** argv;
  58. bool useRedirect;
  59. bool dedicated;
  60. // JMQTODO: make these be class members
  61. const int MaxEvents = 255;
  62. Vector<SDL_Event> eventList;
  63. StringTableEntry mainDotCsDir;
  64. EmscriptenPlatState();
  65. void setWindowTitle(const char *title)
  66. {
  67. dStrncpy(appWindowTitle, title, sizeof(appWindowTitle));
  68. }
  69. };
  70. /// Global singleton that encapsulates a lot of mac platform state & globals.
  71. extern EmscriptenPlatState gPlatState;
  72. /// @name Misc Emscripten Plat Functions
  73. /// Functions that are used by multiple files in the mac plat, but too trivial
  74. /// to require their own header file.
  75. /// @{
  76. /// Fills gGLState with info about this gl renderer's capabilities.
  77. void getGLCapabilities(void);
  78. /// Display a file dialog.
  79. /// calls FileDialog::Execute() on \p dialog
  80. /// @param dialog The FileDialog object to Execute. A void* is used to cut down on header dependencies.
  81. /// @see platform/nativeDialogs/fileDialog.h
  82. void EmscriptenShowDialog(void* dialog);
  83. /// @}
  84. #endif //_PLATFORMEMSCRIPTEN_H_