platformOSX.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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. #import <Cocoa/Cocoa.h>
  23. #import <AppKit/AppKit.h>
  24. #import "platformOSX/osxTorqueView.h"
  25. #include "platform/platform.h"
  26. #include "platform/types.h"
  27. #include "math/mPoint.h"
  28. #include "math/mRandom.h"
  29. #define GL_SILENCE_DEPRECATION
  30. @interface osxPlatState : NSObject
  31. {
  32. // Main application Window
  33. NSWindow* _window;
  34. // Main view for Torque 2D engine display
  35. OSXTorqueView* _torqueView;
  36. // Core graphics display ID the app will start with
  37. CGDirectDisplayID _cgDisplay;
  38. // Process ID for this application instance
  39. id _applicationID;
  40. // Version of operating system
  41. U32 osVersion;
  42. // Number of arguments passed into this application
  43. U32 _argc;
  44. // Arguments passed into this application
  45. const char** _argv;
  46. Point2I _windowSize;
  47. // Bit depth of the screen (desktop)
  48. U32 _desktopBitsPixel;
  49. // Horizontal resolution of user's desktop
  50. U32 _desktopWidth;
  51. // Vertical resolution of user's desktop
  52. U32 _desktopHeight;
  53. // Time sync from the desktop
  54. U32 _currentSimTime;
  55. U32 _lastTimeTick;
  56. U32 _sleepTicks;
  57. // Location of the folder containing the main.cs
  58. NSString* _mainCSDirectory;
  59. // Title for the main window
  60. NSString* _windowTitle;
  61. // Threaded alert object
  62. void* _alertSemaphore;
  63. // Random generator
  64. RandomLCG* _platformRandom;
  65. // Used to report is mouse is locked to the main window or not
  66. BOOL _mouseLocked;
  67. // Used to report if the window has been pushed to the background or not
  68. BOOL _backgrounded;
  69. // Use to report if the window has been minimized or not
  70. BOOL _minimized;
  71. // Used to report windowed vs fullscreen status
  72. BOOL _fullscreen;
  73. // Reports the quit state for the applications
  74. BOOL _quit;
  75. // Timer
  76. NSTimer* _osxTimer;
  77. }
  78. @property (strong) NSWindow* window;
  79. @property (strong) OSXTorqueView* torqueView;
  80. @property CGDirectDisplayID cgDisplay;
  81. @property (strong) id applicationID;
  82. @property void* alertSemaphore;
  83. @property RandomLCG* platformRandom;
  84. @property BOOL fullScreen;
  85. @property U32 argc;
  86. @property const char** argv;
  87. @property U32 desktopBitsPixel;
  88. @property U32 desktopWidth;
  89. @property U32 desktopHeight;
  90. @property U32 currentSimTime;
  91. @property U32 lastTimeTick;
  92. @property U32 sleepTicks;
  93. @property (nonatomic,retain) NSString* mainCSDirectory;
  94. @property (nonatomic,retain) NSString* windowTitle;
  95. @property BOOL mouseLocked;
  96. @property BOOL backgrounded;
  97. @property BOOL minimized;
  98. @property BOOL quit;
  99. @property (strong)NSTimer* osxTimer;
  100. + (id)sharedPlatState;
  101. - (BOOL)initializeTorque2D;
  102. - (void)runTorque2D;
  103. - (void)shutDownTorque2D;
  104. - (void)updateWindowTitle:(const char*)title;
  105. - (void)setWindowSize:(int)width height:(int)height;
  106. - (Point2I&)getWindowSize;
  107. - (U32)windowWidth;
  108. - (U32)windowHeight;
  109. @end