2
0

os_osx.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*************************************************************************/
  2. /* os_osx.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef OS_OSX_H
  30. #define OS_OSX_H
  31. #include "os/input.h"
  32. #include "drivers/unix/os_unix.h"
  33. #include "servers/visual_server.h"
  34. #include "servers/visual/visual_server_wrap_mt.h"
  35. #include "servers/visual/rasterizer.h"
  36. #include "servers/physics_server.h"
  37. #include "servers/audio/audio_server_sw.h"
  38. #include "servers/audio/sample_manager_sw.h"
  39. #include "servers/spatial_sound/spatial_sound_server_sw.h"
  40. #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
  41. #include "drivers/rtaudio/audio_driver_rtaudio.h"
  42. #include "drivers/alsa/audio_driver_alsa.h"
  43. #include "servers/physics_2d/physics_2d_server_sw.h"
  44. #include "platform/osx/audio_driver_osx.h"
  45. #include <ApplicationServices/ApplicationServices.h>
  46. //bitch
  47. #undef CursorShape
  48. /**
  49. @author Juan Linietsky <[email protected]>
  50. */
  51. class OS_OSX : public OS_Unix {
  52. public:
  53. bool force_quit;
  54. Rasterizer *rasterizer;
  55. VisualServer *visual_server;
  56. VideoMode current_videomode;
  57. List<String> args;
  58. MainLoop *main_loop;
  59. unsigned int event_id;
  60. PhysicsServer *physics_server;
  61. Physics2DServer *physics_2d_server;
  62. IP_Unix *ip_unix;
  63. AudioDriverOSX audio_driver_osx;
  64. AudioServerSW *audio_server;
  65. SampleManagerMallocSW *sample_manager;
  66. SpatialSoundServerSW *spatial_sound_server;
  67. SpatialSound2DServerSW *spatial_sound_2d_server;
  68. InputDefault *input;
  69. /* objc */
  70. CGEventSourceRef eventSource;
  71. void process_events();
  72. void* framework;
  73. // pthread_key_t current;
  74. bool mouse_grab;
  75. Point2 mouse_pos;
  76. uint32_t last_id;
  77. id delegate;
  78. id window_delegate;
  79. id window_object;
  80. id window_view;
  81. id autoreleasePool;
  82. id cursor;
  83. id pixelFormat;
  84. id context;
  85. CursorShape cursor_shape;
  86. protected:
  87. virtual int get_video_driver_count() const;
  88. virtual const char * get_video_driver_name(int p_driver) const;
  89. virtual VideoMode get_default_video_mode() const;
  90. virtual void initialize_core();
  91. virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver);
  92. virtual void finalize();
  93. virtual void set_main_loop( MainLoop * p_main_loop );
  94. virtual void delete_main_loop();
  95. public:
  96. static OS_OSX* singleton;
  97. virtual String get_name();
  98. virtual void set_cursor_shape(CursorShape p_shape);
  99. virtual void set_mouse_show(bool p_show);
  100. virtual void set_mouse_grab(bool p_grab);
  101. virtual bool is_mouse_grab_enabled() const;
  102. virtual Point2 get_mouse_pos() const;
  103. virtual int get_mouse_button_state() const;
  104. virtual void set_window_title(const String& p_title);
  105. virtual void set_icon(const Image& p_icon);
  106. virtual MainLoop *get_main_loop() const;
  107. virtual bool can_draw() const;
  108. virtual void set_clipboard(const String& p_text);
  109. virtual String get_clipboard() const;
  110. virtual void release_rendering_thread();
  111. virtual void make_rendering_thread();
  112. virtual void swap_buffers();
  113. Error shell_open(String p_uri);
  114. void push_input(const InputEvent& p_event);
  115. virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
  116. virtual VideoMode get_video_mode(int p_screen=0) const;
  117. virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
  118. virtual String get_executable_path() const;
  119. virtual void move_window_to_foreground();
  120. void run();
  121. OS_OSX();
  122. };
  123. #endif