Irrlicht.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #include "IrrCompileConfig.h"
  5. //static const char* const copyright = "Irrlicht Engine (c) 2002-2012 Nikolaus Gebhardt";
  6. #ifdef _IRR_WINDOWS_
  7. #include <windows.h>
  8. #if defined(_DEBUG) && !defined(__GNUWIN32__) && !defined(_WIN32_WCE)
  9. #include <crtdbg.h>
  10. #endif // _DEBUG
  11. #endif
  12. #include "irrlicht.h"
  13. #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
  14. #include "CIrrDeviceWin32.h"
  15. #endif
  16. #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
  17. #include "MacOSX/CIrrDeviceMacOSX.h"
  18. #endif
  19. #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
  20. #include "CIrrDeviceWinCE.h"
  21. #endif
  22. #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
  23. #include "CIrrDeviceLinux.h"
  24. #endif
  25. #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
  26. #include "CIrrDeviceSDL.h"
  27. #endif
  28. #ifdef _IRR_COMPILE_WITH_FB_DEVICE_
  29. #include "CIrrDeviceFB.h"
  30. #endif
  31. #ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
  32. #include "CIrrDeviceConsole.h"
  33. #endif
  34. #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
  35. #include "CIrrDeviceAndroid.h"
  36. #include <android/log.h>
  37. #endif
  38. namespace irr
  39. {
  40. //! stub for calling createDeviceEx
  41. IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
  42. const core::dimension2d<u32>& windowSize,
  43. u32 bits, bool fullscreen,
  44. bool stencilbuffer, bool vsync, IEventReceiver* res,
  45. io::IFileSystem *file_system)
  46. {
  47. SIrrlichtCreationParameters p;
  48. p.DriverType = driverType;
  49. p.WindowSize = windowSize;
  50. p.Bits = (u8)bits;
  51. p.Fullscreen = fullscreen;
  52. p.Stencilbuffer = stencilbuffer;
  53. p.Vsync = vsync;
  54. p.EventReceiver = res;
  55. p.FileSystem = file_system;
  56. return createDeviceEx(p);
  57. }
  58. extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& params)
  59. {
  60. IrrlichtDevice* dev = 0;
  61. #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
  62. if (params.DeviceType == EIDT_WIN32 || (!dev && params.DeviceType == EIDT_BEST))
  63. dev = new CIrrDeviceWin32(params);
  64. #endif
  65. #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
  66. if (params.DeviceType == EIDT_OSX || (!dev && params.DeviceType == EIDT_BEST))
  67. dev = new CIrrDeviceMacOSX(params);
  68. #endif
  69. #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
  70. if (params.DeviceType == EIDT_WINCE || (!dev && params.DeviceType == EIDT_BEST))
  71. dev = new CIrrDeviceWinCE(params);
  72. #endif
  73. #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
  74. if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST))
  75. dev = new CIrrDeviceLinux(params);
  76. #endif
  77. #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
  78. if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST))
  79. dev = new CIrrDeviceSDL(params);
  80. #endif
  81. #ifdef _IRR_COMPILE_WITH_FB_DEVICE_
  82. if (params.DeviceType == EIDT_FRAMEBUFFER || (!dev && params.DeviceType == EIDT_BEST))
  83. dev = new CIrrDeviceFB(params);
  84. #endif
  85. #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
  86. if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST))
  87. dev = new CIrrDeviceAndroid(params);
  88. #endif
  89. #ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
  90. if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST))
  91. dev = new CIrrDeviceConsole(params);
  92. #endif
  93. if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL)
  94. {
  95. dev->closeDevice(); // destroy window
  96. dev->run(); // consume quit message
  97. dev->drop();
  98. dev = 0;
  99. }
  100. return dev;
  101. }
  102. namespace core
  103. {
  104. const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);
  105. irr::core::stringc LOCALE_DECIMAL_POINTS(".");
  106. }
  107. namespace video
  108. {
  109. SMaterial IdentityMaterial;
  110. }
  111. } // end namespace irr
  112. #if defined(_IRR_WINDOWS_API_) && !defined(_IRR_STATIC_LIB_)
  113. BOOL APIENTRY DllMain( HANDLE hModule,
  114. DWORD ul_reason_for_call,
  115. LPVOID lpReserved )
  116. {
  117. // _crtBreakAlloc = 139;
  118. switch (ul_reason_for_call)
  119. {
  120. case DLL_PROCESS_ATTACH:
  121. #if defined(_DEBUG) && !defined(__GNUWIN32__) && !defined(__BORLANDC__) && !defined (_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_)
  122. _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
  123. #endif
  124. break;
  125. case DLL_THREAD_ATTACH:
  126. case DLL_THREAD_DETACH:
  127. case DLL_PROCESS_DETACH:
  128. break;
  129. }
  130. return TRUE;
  131. }
  132. #endif // defined(_IRR_WINDOWS_)