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 __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__
  5. #define __I_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(false),
  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. Default: false */
  111. bool WindowResizable;
  112. //! Specifies if the stencil buffer should be enabled.
  113. /** Set this to true, if you want the engine be able to draw
  114. stencil buffer shadows. Note that not all drivers are able to
  115. use the stencil buffer, hence it can be ignored during device
  116. creation. Without the stencil buffer no shadows will be drawn.
  117. Default: true. */
  118. bool Stencilbuffer;
  119. //! Specifies vertical synchronization.
  120. /** If set to true, the driver will wait for the vertical
  121. retrace period, otherwise not. May be silently ignored.
  122. Default: false */
  123. bool Vsync;
  124. //! Specifies if the device should use fullscreen anti aliasing
  125. /** Makes sharp/pixelated edges softer, but requires more
  126. performance. Also, 2D elements might look blurred with this
  127. switched on. The resulting rendering quality also depends on
  128. the hardware and driver you are using, your program might look
  129. different on different hardware with this. So if you are
  130. writing a game/application with AntiAlias switched on, it would
  131. be a good idea to make it possible to switch this option off
  132. again by the user.
  133. The value is the maximal antialiasing factor requested for
  134. the device. The creation method will automatically try smaller
  135. values if no window can be created with the given value.
  136. Value one is usually the same as 0 (disabled), but might be a
  137. special value on some platforms. On D3D devices it maps to
  138. NONMASKABLE.
  139. Default value: 0 - disabled */
  140. u8 AntiAlias;
  141. //! Flag to enable proper sRGB and linear color handling
  142. /** In most situations, it is desirable to have the color handling in
  143. non-linear sRGB color space, and only do the intermediate color
  144. calculations in linear RGB space. If this flag is enabled, the device and
  145. driver try to assure that all color input and output are color corrected
  146. and only the internal color representation is linear. This means, that
  147. the color output is properly gamma-adjusted to provide the brighter
  148. colors for monitor display. And that blending and lighting give a more
  149. natural look, due to proper conversion from non-linear colors into linear
  150. color space for blend operations. If this flag is enabled, all texture colors
  151. (which are usually in sRGB space) are correctly displayed. However vertex colors
  152. and other explicitly set values have to be manually encoded in linear color space.
  153. Default value: false. */
  154. bool HandleSRGB;
  155. //! Whether the main framebuffer uses an alpha channel.
  156. /** In some situations it might be desirable to get a color
  157. buffer with an alpha channel, e.g. when rendering into a
  158. transparent window or overlay. If this flag is set the device
  159. tries to create a framebuffer with alpha channel.
  160. If this flag is set, only color buffers with alpha channel
  161. are considered. Otherwise, it depends on the actual hardware
  162. if the colorbuffer has an alpha channel or not.
  163. Default value: false */
  164. bool WithAlphaChannel;
  165. //! Whether the main framebuffer uses doublebuffering.
  166. /** This should be usually enabled, in order to avoid render
  167. artifacts on the visible framebuffer. However, it might be
  168. useful to use only one buffer on very small devices. If no
  169. doublebuffering is available, the drivers will fall back to
  170. single buffers. Default value: true */
  171. bool Doublebuffer;
  172. //! Specifies if the device should ignore input events
  173. /** This is only relevant when using external I/O handlers.
  174. External windows need to take care of this themselves.
  175. Currently only supported by X11.
  176. Default value: false */
  177. bool IgnoreInput;
  178. //! Specifies if the device should use stereo buffers
  179. /** Some high-end gfx cards support two framebuffers for direct
  180. support of stereoscopic output devices. If this flag is set the
  181. device tries to create a stereo context.
  182. Currently only supported by OpenGL.
  183. Default value: false */
  184. bool Stereobuffer;
  185. //! Specifies if the device should use high precision FPU setting
  186. /** This is only relevant for DirectX Devices, which switch to
  187. low FPU precision by default for performance reasons. However,
  188. this may lead to problems with the other computations of the
  189. application. In this case setting this flag to true should help
  190. - on the expense of performance loss, though.
  191. Default value: false */
  192. bool HighPrecisionFPU;
  193. //! A user created event receiver.
  194. IEventReceiver* EventReceiver;
  195. //! Window Id.
  196. /** If this is set to a value other than 0, the Irrlicht Engine
  197. will be created in an already existing window. For windows, set
  198. this to the HWND of the window you want. The windowSize and
  199. FullScreen options will be ignored when using the WindowId
  200. parameter. Default this is set to 0.
  201. To make Irrlicht run inside the custom window, you still will
  202. have to draw Irrlicht on your own. You can use this loop, as
  203. usual:
  204. \code
  205. while (device->run())
  206. {
  207. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
  208. smgr->drawAll();
  209. driver->endScene();
  210. }
  211. \endcode
  212. Instead of this, you can also simply use your own message loop
  213. using GetMessage, DispatchMessage and whatever. Calling
  214. IrrlichtDevice::run() will cause Irrlicht to dispatch messages
  215. internally too. You need not call Device->run() if you want to
  216. do your own message dispatching loop, but Irrlicht will not be
  217. able to fetch user input then and you have to do it on your own
  218. using the window messages, DirectInput, or whatever. Also,
  219. you'll have to increment the Irrlicht timer.
  220. An alternative, own message dispatching loop without
  221. device->run() would look like this:
  222. \code
  223. MSG msg;
  224. while (true)
  225. {
  226. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  227. {
  228. TranslateMessage(&msg);
  229. DispatchMessage(&msg);
  230. if (msg.message == WM_QUIT)
  231. break;
  232. }
  233. // increase virtual timer time
  234. device->getTimer()->tick();
  235. // draw engine picture
  236. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
  237. smgr->drawAll();
  238. driver->endScene();
  239. }
  240. \endcode
  241. However, there is no need to draw the picture this often. Just
  242. do it how you like. */
  243. void* WindowId;
  244. //! Specifies the logging level used in the logging interface.
  245. /** The default value is ELL_INFORMATION. You can access the ILogger interface
  246. later on from the IrrlichtDevice with getLogger() and set another level.
  247. But if you need more or less logging information already from device creation,
  248. then you have to change it here.
  249. */
  250. ELOG_LEVEL LoggingLevel;
  251. //! Allows to select which graphic card is used for rendering when more than one card is in the system.
  252. /** So far only supported on D3D */
  253. u32 DisplayAdapter;
  254. //! Create the driver multithreaded.
  255. /** Default is false. Enabling this can slow down your application.
  256. Note that this does _not_ make Irrlicht threadsafe, but only the underlying driver-API for the graphiccard.
  257. So far only supported on D3D. */
  258. bool DriverMultithreaded;
  259. //! Enables use of high performance timers on Windows platform.
  260. /** When performance timers are not used, standard GetTickCount()
  261. is used instead which usually has worse resolution, but also less
  262. problems with speed stepping and other techniques.
  263. */
  264. bool UsePerformanceTimer;
  265. //! Don't use or change this parameter.
  266. /** Always set it to IRRLICHT_SDK_VERSION, which is done by default.
  267. This is needed for sdk version checks. */
  268. const c8* const SDK_version_do_not_use;
  269. };
  270. } // end namespace irr
  271. #endif