register_driver_types.cpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*************************************************/
  2. /* register_driver_types.cpp */
  3. /*************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /*************************************************/
  7. /* Source code within this file is: */
  8. /* (c) 2007-2010 Juan Linietsky, Ariel Manzur */
  9. /* All Rights Reserved. */
  10. /*************************************************/
  11. #include "register_driver_types.h"
  12. #include "png/image_loader_png.h"
  13. #include "webp/image_loader_webp.h"
  14. #include "png/resource_saver_png.h"
  15. #include "jpg/image_loader_jpg.h"
  16. #include "dds/texture_loader_dds.h"
  17. #include "pvr/texture_loader_pvr.h"
  18. #include "etc1/image_etc.h"
  19. #include "chibi/event_stream_chibi.h"
  20. #ifdef TOOLS_ENABLED
  21. #include "squish/image_compress_squish.h"
  22. #endif
  23. #ifdef TOOLS_ENABLED
  24. #include "convex_decomp/b2d_decompose.h"
  25. #endif
  26. #ifdef TOOLS_ENABLED
  27. #include "pe_bliss/pe_bliss_godot.h"
  28. #include "platform/windows/export/export.h"
  29. #endif
  30. #ifdef TREMOR_ENABLED
  31. #include "teora/audio_stream_ogg.h"
  32. #endif
  33. #ifdef VORBIS_ENABLED
  34. #include "vorbis/audio_stream_ogg_vorbis.h"
  35. #endif
  36. #ifdef OPUS_ENABLED
  37. #include "opus/audio_stream_opus.h"
  38. #endif
  39. #ifdef SPEEX_ENABLED
  40. #include "speex/audio_stream_speex.h"
  41. #endif
  42. #ifdef THEORA_ENABLED
  43. #include "theora/video_stream_theora.h"
  44. #endif
  45. #ifdef THEORAPLAYER_ENABLED
  46. #include "theoraplayer/video_stream_theoraplayer.h"
  47. #endif
  48. #include "drivers/nrex/regex.h"
  49. #ifdef MUSEPACK_ENABLED
  50. #include "mpc/audio_stream_mpc.h"
  51. #endif
  52. #ifdef PNG_ENABLED
  53. static ImageLoaderPNG *image_loader_png=NULL;
  54. static ResourceSaverPNG *resource_saver_png=NULL;
  55. #endif
  56. #ifdef WEBP_ENABLED
  57. static ImageLoaderWEBP *image_loader_webp=NULL;
  58. //static ResourceSaverPNG *resource_saver_png=NULL;
  59. #endif
  60. #ifdef JPG_ENABLED
  61. static ImageLoaderJPG *image_loader_jpg=NULL;
  62. #endif
  63. #ifdef DDS_ENABLED
  64. static ResourceFormatDDS *resource_loader_dds=NULL;
  65. #endif
  66. #ifdef PVR_ENABLED
  67. static ResourceFormatPVR *resource_loader_pvr=NULL;
  68. #endif
  69. #ifdef TREMOR_ENABLED
  70. static ResourceFormatLoaderAudioStreamOGG *vorbis_stream_loader=NULL;
  71. #endif
  72. #ifdef VORBIS_ENABLED
  73. static ResourceFormatLoaderAudioStreamOGGVorbis *vorbis_stream_loader=NULL;
  74. #endif
  75. #ifdef OPUS_ENABLED
  76. static ResourceFormatLoaderAudioStreamOpus *opus_stream_loader=NULL;
  77. #endif
  78. #ifdef SPEEX_ENABLED
  79. static ResourceFormatLoaderAudioStreamSpeex *speex_stream_loader=NULL;
  80. #endif
  81. #ifdef THEORA_ENABLED
  82. static ResourceFormatLoaderVideoStreamTheora* theora_stream_loader = NULL;
  83. #endif
  84. #ifdef THEORAPLAYER_ENABLED
  85. static ResourceFormatLoaderVideoStreamTheoraplayer* theoraplayer_stream_loader = NULL;
  86. #endif
  87. #ifdef MUSEPACK_ENABLED
  88. static ResourceFormatLoaderAudioStreamMPC * mpc_stream_loader=NULL;
  89. #endif
  90. #ifdef OPENSSL_ENABLED
  91. #include "openssl/register_openssl.h"
  92. #endif
  93. void register_core_driver_types() {
  94. #ifdef PNG_ENABLED
  95. image_loader_png = memnew( ImageLoaderPNG );
  96. ImageLoader::add_image_format_loader( image_loader_png );
  97. resource_saver_png = memnew( ResourceSaverPNG );
  98. ResourceSaver::add_resource_format_saver(resource_saver_png);
  99. #endif
  100. #ifdef WEBP_ENABLED
  101. image_loader_webp = memnew( ImageLoaderWEBP );
  102. ImageLoader::add_image_format_loader( image_loader_webp );
  103. // resource_saver_png = memnew( ResourceSaverPNG );
  104. // ResourceSaver::add_resource_format_saver(resource_saver_png);
  105. #endif
  106. #ifdef JPG_ENABLED
  107. image_loader_jpg = memnew( ImageLoaderJPG );
  108. ImageLoader::add_image_format_loader( image_loader_jpg );
  109. #endif
  110. ObjectTypeDB::register_type<RegEx>();
  111. }
  112. void unregister_core_driver_types() {
  113. #ifdef PNG_ENABLED
  114. if (image_loader_png)
  115. memdelete( image_loader_png );
  116. if (resource_saver_png)
  117. memdelete( resource_saver_png );
  118. #endif
  119. #ifdef WEBP_ENABLED
  120. if (image_loader_webp)
  121. memdelete( image_loader_webp );
  122. // if (resource_saver_png)
  123. // memdelete( resource_saver_png );
  124. #endif
  125. #ifdef JPG_ENABLED
  126. if (image_loader_jpg)
  127. memdelete( image_loader_jpg );
  128. #endif
  129. }
  130. void register_driver_types() {
  131. #ifdef TREMOR_ENABLED
  132. vorbis_stream_loader=memnew( ResourceFormatLoaderAudioStreamOGG );
  133. ResourceLoader::add_resource_format_loader(vorbis_stream_loader );
  134. ObjectTypeDB::register_type<AudioStreamOGG>();
  135. #endif
  136. #ifdef VORBIS_ENABLED
  137. vorbis_stream_loader=memnew( ResourceFormatLoaderAudioStreamOGGVorbis );
  138. ResourceLoader::add_resource_format_loader(vorbis_stream_loader );
  139. ObjectTypeDB::register_type<AudioStreamOGGVorbis>();
  140. #endif
  141. #ifdef OPUS_ENABLED
  142. opus_stream_loader=memnew( ResourceFormatLoaderAudioStreamOpus );
  143. ResourceLoader::add_resource_format_loader( opus_stream_loader );
  144. ObjectTypeDB::register_type<AudioStreamOpus>();
  145. #endif
  146. #ifdef DDS_ENABLED
  147. resource_loader_dds = memnew( ResourceFormatDDS );
  148. ResourceLoader::add_resource_format_loader(resource_loader_dds );
  149. #endif
  150. #ifdef PVR_ENABLED
  151. resource_loader_pvr = memnew( ResourceFormatPVR );
  152. ResourceLoader::add_resource_format_loader(resource_loader_pvr );
  153. #endif
  154. #ifdef TOOLS_ENABLED
  155. Geometry::_decompose_func=b2d_decompose;
  156. #endif
  157. #ifdef SPEEX_ENABLED
  158. speex_stream_loader=memnew( ResourceFormatLoaderAudioStreamSpeex );
  159. ResourceLoader::add_resource_format_loader(speex_stream_loader);
  160. ObjectTypeDB::register_type<AudioStreamSpeex>();
  161. #endif
  162. #ifdef MUSEPACK_ENABLED
  163. mpc_stream_loader=memnew( ResourceFormatLoaderAudioStreamMPC );
  164. ResourceLoader::add_resource_format_loader(mpc_stream_loader);
  165. ObjectTypeDB::register_type<AudioStreamMPC>();
  166. #endif
  167. #ifdef OPENSSL_ENABLED
  168. register_openssl();
  169. #endif
  170. #ifdef THEORA_ENABLED
  171. theora_stream_loader = memnew( ResourceFormatLoaderVideoStreamTheora );
  172. ResourceLoader::add_resource_format_loader(theora_stream_loader);
  173. ObjectTypeDB::register_type<VideoStreamTheora>();
  174. #endif
  175. #ifdef THEORAPLAYER_ENABLED
  176. theoraplayer_stream_loader = memnew( ResourceFormatLoaderVideoStreamTheoraplayer );
  177. ResourceLoader::add_resource_format_loader(theoraplayer_stream_loader);
  178. ObjectTypeDB::register_type<VideoStreamTheoraplayer>();
  179. #endif
  180. #ifdef TOOLS_ENABLED
  181. #ifdef SQUISH_ENABLED
  182. Image::set_compress_bc_func(image_compress_squish);
  183. #endif
  184. #endif
  185. #ifdef ETC1_ENABLED
  186. _register_etc1_compress_func();
  187. #endif
  188. initialize_chibi();
  189. }
  190. void unregister_driver_types() {
  191. #ifdef TREMOR_ENABLED
  192. memdelete( vorbis_stream_loader );
  193. #endif
  194. #ifdef VORBIS_ENABLED
  195. memdelete( vorbis_stream_loader );
  196. #endif
  197. #ifdef OPUS_ENABLED
  198. memdelete( opus_stream_loader );
  199. #endif
  200. #ifdef SPEEX_ENABLED
  201. memdelete( speex_stream_loader );
  202. #endif
  203. #ifdef THEORA_ENABLED
  204. memdelete (theora_stream_loader);
  205. #endif
  206. #ifdef THEORAPLAYER_ENABLED
  207. memdelete (theoraplayer_stream_loader);
  208. #endif
  209. #ifdef MUSEPACK_ENABLED
  210. memdelete (mpc_stream_loader);
  211. #endif
  212. #ifdef DDS_ENABLED
  213. memdelete(resource_loader_dds);
  214. #endif
  215. #ifdef PVR_ENABLED
  216. memdelete(resource_loader_pvr);
  217. #endif
  218. #ifdef OPENSSL_ENABLED
  219. unregister_openssl();
  220. #endif
  221. finalize_chibi();
  222. }