POSIXMain.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef __APPLE__
  23. #include "platform/platform.h"
  24. #include "platform/platformInput.h"
  25. #include "console/console.h"
  26. #include "platformPOSIX/platformPOSIX.h"
  27. #include "platformPOSIX/POSIXStdConsole.h"
  28. #include "platformPOSIX/POSIXState.h"
  29. extern void InitWindowingSystem();
  30. //------------------------------------------------------------------------------
  31. void Platform::init()
  32. {
  33. StdConsole::create();
  34. stdConsole->enable(true);
  35. // init process control stuff
  36. ProcessControlInit();
  37. Con::printf("Initializing platform...");
  38. // Set the platform variable for the scripts
  39. Con::setVariable( "$platform", "x86UNIX" );
  40. #if defined(__linux__)
  41. Con::setVariable( "$platformUnixType", "Linux" );
  42. #elif defined(__OpenBSD__)
  43. Con::setVariable( "$platformUnixType", "OpenBSD" );
  44. #else
  45. Con::setVariable( "$platformUnixType", "Unknown" );
  46. #endif
  47. Input::init();
  48. //installRedBookDevices();
  49. #ifndef TORQUE_DEDICATED
  50. // if we're not dedicated do more initialization
  51. InitWindowingSystem();
  52. #endif
  53. }
  54. //------------------------------------------------------------------------------
  55. void Platform::shutdown()
  56. {
  57. Cleanup();
  58. }
  59. //------------------------------------------------------------------------------
  60. extern "C"
  61. {
  62. bool torque_engineinit(int argc, const char **argv);
  63. int torque_enginetick();
  64. S32 torque_getreturnstatus();
  65. bool torque_engineshutdown();
  66. int torque_unixmain(int argc, const char **argv)
  67. {
  68. if (!torque_engineinit(argc, argv))
  69. return 1;
  70. while(torque_enginetick())
  71. {
  72. }
  73. torque_engineshutdown();
  74. return torque_getreturnstatus();
  75. }
  76. }
  77. extern S32 TorqueMain(S32 argc, const char **argv);
  78. #if !defined(TORQUE_SHARED)
  79. int main(int argc, const char **argv)
  80. {
  81. return TorqueMain(argc, argv);
  82. }
  83. #endif
  84. #endif