SIrrCreationParameters.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. #ifndef IRR_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED
  5. #define IRR_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED
  6. #include "EDriverTypes.h"
  7. #include "EDeviceTypes.h"
  8. #include "dimension2d.h"
  9. #include "ILogger.h"
  10. #include "position2d.h"
  11. namespace irr
  12. {
  13. class IEventReceiver;
  14. //! Structure for holding Irrlicht Device creation parameters.
  15. /** This structure is used in the createDeviceEx() function. */
  16. struct SIrrlichtCreationParameters
  17. {
  18. //! Constructs a SIrrlichtCreationParameters structure with default values.
  19. SIrrlichtCreationParameters() :
  20. DeviceType(EIDT_BEST),
  21. DriverType(video::EDT_BURNINGSVIDEO),
  22. WindowSize(core::dimension2d<u32>(800, 600)),
  23. WindowPosition(core::position2di(-1,-1)),
  24. Bits(32),
  25. ZBufferBits(24),
  26. Fullscreen(false),
  27. WindowResizable(2),
  28. Stencilbuffer(true),
  29. Vsync(false),
  30. AntiAlias(0),
  31. HandleSRGB(false),
  32. WithAlphaChannel(false),
  33. Doublebuffer(true),
  34. IgnoreInput(false),
  35. Stereobuffer(false),
  36. HighPrecisionFPU(false),
  37. EventReceiver(0),
  38. WindowId(0),
  39. #ifdef _DEBUG
  40. LoggingLevel(ELL_DEBUG),
  41. #else
  42. LoggingLevel(ELL_INFORMATION),
  43. #endif
  44. DisplayAdapter(0),
  45. DriverMultithreaded(false),
  46. UsePerformanceTimer(true),
  47. SDK_version_do_not_use(IRRLICHT_SDK_VERSION)
  48. {
  49. }
  50. SIrrlichtCreationParameters(const SIrrlichtCreationParameters& other) :
  51. SDK_version_do_not_use(IRRLICHT_SDK_VERSION)
  52. {*this = other;}
  53. SIrrlichtCreationParameters& operator=(const SIrrlichtCreationParameters& other)
  54. {
  55. DeviceType = other.DeviceType;
  56. DriverType = other.DriverType;
  57. WindowSize = other.WindowSize;
  58. WindowPosition = other.WindowPosition;
  59. Bits = other.Bits;
  60. ZBufferBits = other.ZBufferBits;
  61. Fullscreen = other.Fullscreen;
  62. WindowResizable = other.WindowResizable;
  63. Stencilbuffer = other.Stencilbuffer;
  64. Vsync = other.Vsync;
  65. AntiAlias = other.AntiAlias;
  66. HandleSRGB = other.HandleSRGB;
  67. WithAlphaChannel = other.WithAlphaChannel;
  68. Doublebuffer = other.Doublebuffer;
  69. IgnoreInput = other.IgnoreInput;
  70. Stereobuffer = other.Stereobuffer;
  71. HighPrecisionFPU = other.HighPrecisionFPU;
  72. EventReceiver = other.EventReceiver;
  73. WindowId = other.WindowId;
  74. LoggingLevel = other.LoggingLevel;
  75. DisplayAdapter = other.DisplayAdapter;
  76. DriverMultithreaded = other.DriverMultithreaded;
  77. UsePerformanceTimer = other.UsePerformanceTimer;
  78. return *this;
  79. }
  80. //! Type of the device.
  81. /** This setting decides the windowing system used by the device, most device types are native
  82. to a specific operating system and so may not be available.
  83. EIDT_WIN32 is only available on Windows desktops,
  84. EIDT_WINCE is only available on Windows mobile devices,
  85. EIDT_COCOA is only available on Mac OSX,
  86. EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
  87. EIDT_SDL is available on most systems if compiled in,
  88. EIDT_CONSOLE is usually available but can only render to text,
  89. EIDT_BEST will select the best available device for your operating system.
  90. Default: EIDT_BEST. */
  91. E_DEVICE_TYPE DeviceType;
  92. //! Type of video driver used to render graphics.
  93. /** This can currently be video::EDT_NULL, video::EDT_SOFTWARE,
  94. video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D9, and video::EDT_OPENGL.
  95. Default: EDT_BURNINGSVIDEO. */
  96. video::E_DRIVER_TYPE DriverType;
  97. //! Size of the window or the video mode in fullscreen mode. Default: 800x600
  98. core::dimension2d<u32> WindowSize;
  99. //! Position of the window on-screen. Default: (-1, -1) or centered.
  100. core::position2di WindowPosition;
  101. //! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 32.
  102. u8 Bits;
  103. //! Minimum Bits per pixel of the depth buffer. Default: 24.
  104. u8 ZBufferBits;
  105. //! Should be set to true if the device should run in fullscreen.
  106. /** Otherwise the device runs in windowed mode. Default: false. */
  107. bool Fullscreen;
  108. //! Should a non-fullscreen window be resizable.
  109. /** Might not be supported by all devices. Ignored when Fullscreen is true.
  110. Values: 0 = not resizable, 1 = resizable, 2 = system decides default itself
  111. Default: 2*/
  112. u8 WindowResizable;
  113. //! Specifies if the stencil buffer should be enabled.
  114. /** Set this to true, if you want the engine be able to draw
  115. stencil buffer shadows. Note that not all drivers are able to
  116. use the stencil buffer, hence it can be ignored during device
  117. creation. Without the stencil buffer no shadows will be drawn.
  118. Default: true. */
  119. bool Stencilbuffer;
  120. //! Specifies vertical synchronization.
  121. /** If set to true, the driver will wait for the vertical
  122. retrace period, otherwise not. May be silently ignored.
  123. Default: false */
  124. bool Vsync;
  125. //! Specifies if the device should use fullscreen anti aliasing
  126. /** Makes sharp/pixelated edges softer, but requires more
  127. performance. Also, 2D elements might look blurred with this
  128. switched on. The resulting rendering quality also depends on
  129. the hardware and driver you are using, your program might look
  130. different on different hardware with this. So if you are
  131. writing a game/application with AntiAlias switched on, it would
  132. be a good idea to make it possible to switch this option off
  133. again by the user.
  134. The value is the maximal antialiasing factor requested for
  135. the device. The creation method will automatically try smaller
  136. values if no window can be created with the given value.
  137. Value one is usually the same as 0 (disabled), but might be a
  138. special value on some platforms. On D3D devices it maps to
  139. NONMASKABLE.
  140. Default value: 0 - disabled */
  141. u8 AntiAlias;
  142. //! Flag to enable proper sRGB and linear color handling
  143. /** In most situations, it is desirable to have the color handling in
  144. non-linear sRGB color space, and only do the intermediate color
  145. calculations in linear RGB space. If this flag is enabled, the device and
  146. driver try to assure that all color input and output are color corrected
  147. and only the internal color representation is linear. This means, that
  148. the color output is properly gamma-adjusted to provide the brighter
  149. colors for monitor display. And that blending and lighting give a more
  150. natural look, due to proper conversion from non-linear colors into linear
  151. color space for blend operations. If this flag is enabled, all texture colors
  152. (which are usually in sRGB space) are correctly displayed. However vertex colors
  153. and other explicitly set values have to be manually encoded in linear color space.
  154. Default value: false. */
  155. bool HandleSRGB;
  156. //! Whether the main framebuffer uses an alpha channel.
  157. /** In some situations it might be desirable to get a color
  158. buffer with an alpha channel, e.g. when rendering into a
  159. transparent window or overlay. If this flag is set the device
  160. tries to create a framebuffer with alpha channel.
  161. If this flag is set, only color buffers with alpha channel
  162. are considered. Otherwise, it depends on the actual hardware
  163. if the colorbuffer has an alpha channel or not.
  164. Default value: false */
  165. bool WithAlphaChannel;
  166. //! Whether the main framebuffer uses doublebuffering.
  167. /** This should be usually enabled, in order to avoid render
  168. artifacts on the visible framebuffer. However, it might be
  169. useful to use only one buffer on very small devices. If no
  170. doublebuffering is available, the drivers will fall back to
  171. single buffers. Default value: true */
  172. bool Doublebuffer;
  173. //! Specifies if the device should ignore input events
  174. /** This is only relevant when using external I/O handlers.
  175. External windows need to take care of this themselves.
  176. Currently only supported by X11.
  177. Default value: false */
  178. bool IgnoreInput;
  179. //! Specifies if the device should use stereo buffers
  180. /** Some high-end gfx cards support two framebuffers for direct
  181. support of stereoscopic output devices. If this flag is set the
  182. device tries to create a stereo context.
  183. Currently only supported by OpenGL.
  184. Default value: false */
  185. bool Stereobuffer;
  186. //! Specifies if the device should use high precision FPU setting
  187. /** This is only relevant for DirectX Devices, which switch to
  188. low FPU precision by default for performance reasons. However,
  189. this may lead to problems with the other computations of the
  190. application. In this case setting this flag to true should help
  191. - on the expense of performance loss, though.
  192. Default value: false */
  193. bool HighPrecisionFPU;
  194. //! A user created event receiver.
  195. IEventReceiver* EventReceiver;
  196. //! Window Id.
  197. /** If this is set to a value other than 0, the Irrlicht Engine
  198. will be created in an already existing window. For windows, set
  199. this to the HWND of the window you want. The windowSize and
  200. FullScreen options will be ignored when using the WindowId
  201. parameter. Default this is set to 0.
  202. To make Irrlicht run inside the custom window, you still will
  203. have to draw Irrlicht on your own. You can use this loop, as
  204. usual:
  205. \code
  206. while (device->run())
  207. {
  208. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
  209. smgr->drawAll();
  210. driver->endScene();
  211. }
  212. \endcode
  213. Instead of this, you can also simply use your own message loop
  214. using GetMessage, DispatchMessage and whatever. Calling
  215. IrrlichtDevice::run() will cause Irrlicht to dispatch messages
  216. internally too. You need not call Device->run() if you want to
  217. do your own message dispatching loop, but Irrlicht will not be
  218. able to fetch user input then and you have to do it on your own
  219. using the window messages, DirectInput, or whatever. Also,
  220. you'll have to increment the Irrlicht timer.
  221. An alternative, own message dispatching loop without
  222. device->run() would look like this:
  223. \code
  224. MSG msg;
  225. while (true)
  226. {
  227. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  228. {
  229. TranslateMessage(&msg);
  230. DispatchMessage(&msg);
  231. if (msg.message == WM_QUIT)
  232. break;
  233. }
  234. // increase virtual timer time
  235. device->getTimer()->tick();
  236. // draw engine picture
  237. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
  238. smgr->drawAll();
  239. driver->endScene();
  240. }
  241. \endcode
  242. However, there is no need to draw the picture this often. Just
  243. do it how you like. */
  244. void* WindowId;
  245. //! Specifies the logging level used in the logging interface.
  246. /** The default value is ELL_INFORMATION. You can access the ILogger interface
  247. later on from the IrrlichtDevice with getLogger() and set another level.
  248. But if you need more or less logging information already from device creation,
  249. then you have to change it here.
  250. */
  251. ELOG_LEVEL LoggingLevel;
  252. //! Allows to select which graphic card is used for rendering when more than one card is in the system.
  253. /** So far only supported on D3D */
  254. u32 DisplayAdapter;
  255. //! Create the driver multithreaded.
  256. /** Default is false. Enabling this can slow down your application.
  257. Note that this does _not_ make Irrlicht threadsafe, but only the underlying driver-API for the graphiccard.
  258. So far only supported on D3D. */
  259. bool DriverMultithreaded;
  260. //! Enables use of high performance timers on Windows platform.
  261. /** When performance timers are not used, standard GetTickCount()
  262. is used instead which usually has worse resolution, but also less
  263. problems with speed stepping and other techniques.
  264. */
  265. bool UsePerformanceTimer;
  266. //! Don't use or change this parameter.
  267. /** Always set it to IRRLICHT_SDK_VERSION, which is done by default.
  268. This is needed for sdk version checks. */
  269. const c8* const SDK_version_do_not_use;
  270. };
  271. } // end namespace irr
  272. #endif