register_server_types.cpp 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*************************************************************************/
  2. /* register_server_types.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2015 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. #include "register_server_types.h"
  30. #include "globals.h"
  31. #include "visual_server.h"
  32. #include "audio_server.h"
  33. #include "physics_server.h"
  34. #include "physics_2d_server.h"
  35. #include "spatial_sound_server.h"
  36. #include "spatial_sound_2d_server.h"
  37. #include "script_debugger_remote.h"
  38. static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsage>* r_usage) {
  39. List<VS::TextureInfo> tinfo;
  40. VS::get_singleton()->texture_debug_usage(&tinfo);
  41. for (List<VS::TextureInfo>::Element *E=tinfo.front();E;E=E->next()) {
  42. ScriptDebuggerRemote::ResourceUsage usage;
  43. usage.path=E->get().path;
  44. usage.vram=E->get().bytes;
  45. usage.id=E->get().texture;
  46. usage.type="Texture";
  47. usage.format=itos(E->get().size.width)+"x"+itos(E->get().size.height)+" "+Image::get_format_name(E->get().format);
  48. r_usage->push_back(usage);
  49. }
  50. }
  51. void register_server_types() {
  52. Globals::get_singleton()->add_singleton( Globals::Singleton("VisualServer",VisualServer::get_singleton()) );
  53. Globals::get_singleton()->add_singleton( Globals::Singleton("VS",VisualServer::get_singleton()) );
  54. Globals::get_singleton()->add_singleton( Globals::Singleton("AudioServer",AudioServer::get_singleton()) );
  55. Globals::get_singleton()->add_singleton( Globals::Singleton("AS",AudioServer::get_singleton()) );
  56. Globals::get_singleton()->add_singleton( Globals::Singleton("PhysicsServer",PhysicsServer::get_singleton()) );
  57. Globals::get_singleton()->add_singleton( Globals::Singleton("PS",PhysicsServer::get_singleton()) );
  58. Globals::get_singleton()->add_singleton( Globals::Singleton("Physics2DServer",Physics2DServer::get_singleton()) );
  59. Globals::get_singleton()->add_singleton( Globals::Singleton("PS2D",Physics2DServer::get_singleton()) );
  60. Globals::get_singleton()->add_singleton( Globals::Singleton("SpatialSoundServer",SpatialSound2DServer::get_singleton()) );
  61. Globals::get_singleton()->add_singleton( Globals::Singleton("SS",SpatialSound2DServer::get_singleton()) );
  62. Globals::get_singleton()->add_singleton( Globals::Singleton("SpatialSound2DServer",SpatialSound2DServer::get_singleton()) );
  63. Globals::get_singleton()->add_singleton( Globals::Singleton("SS2D",SpatialSound2DServer::get_singleton()) );
  64. ObjectTypeDB::register_virtual_type<Physics2DDirectBodyState>();
  65. ObjectTypeDB::register_virtual_type<Physics2DDirectSpaceState>();
  66. ObjectTypeDB::register_virtual_type<Physics2DShapeQueryResult>();
  67. ObjectTypeDB::register_type<Physics2DTestMotionResult>();
  68. ObjectTypeDB::register_type<Physics2DShapeQueryParameters>();
  69. ObjectTypeDB::register_type<PhysicsShapeQueryParameters>();
  70. ObjectTypeDB::register_virtual_type<PhysicsDirectBodyState>();
  71. ObjectTypeDB::register_virtual_type<PhysicsDirectSpaceState>();
  72. ObjectTypeDB::register_virtual_type<PhysicsShapeQueryResult>();
  73. ScriptDebuggerRemote::resource_usage_func=_debugger_get_resource_usage;
  74. }
  75. void unregister_server_types(){
  76. }