2
0

SIrrCreationParameters.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. #pragma once
  5. #include "EDriverTypes.h"
  6. #include "EDeviceTypes.h"
  7. #include "dimension2d.h"
  8. #include "ILogger.h"
  9. #include "position2d.h"
  10. #include "path.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_OPENGL),
  22. WindowSize(core::dimension2d<u32>(800, 600)),
  23. WindowPosition(core::position2di(-1, -1)),
  24. Bits(32),
  25. ZBufferBits(24),
  26. Fullscreen(false),
  27. WindowMaximized(false),
  28. WindowResizable(2),
  29. Stencilbuffer(true),
  30. Vsync(false),
  31. AntiAlias(0),
  32. WithAlphaChannel(false),
  33. Doublebuffer(true),
  34. Stereobuffer(false),
  35. EventReceiver(0),
  36. WindowId(0),
  37. #ifdef _DEBUG
  38. LoggingLevel(ELL_DEBUG),
  39. #else
  40. LoggingLevel(ELL_INFORMATION),
  41. #endif
  42. PrivateData(0),
  43. #ifdef IRR_MOBILE_PATHS
  44. OGLES2ShaderPath("media/Shaders/"),
  45. #else
  46. OGLES2ShaderPath("../../media/Shaders/"),
  47. #endif
  48. DriverDebug(false)
  49. {
  50. }
  51. //! Type of the device.
  52. /** This setting decides the windowing system used by the device, most device types are native
  53. to a specific operating system and so may not be available.
  54. EIDT_WIN32 is only available on Windows desktops,
  55. EIDT_COCOA is only available on Mac OSX,
  56. EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
  57. EIDT_SDL is available on most systems if compiled in,
  58. EIDT_BEST will select the best available device for your operating system.
  59. Default: EIDT_BEST. */
  60. E_DEVICE_TYPE DeviceType;
  61. //! Type of video driver used to render graphics.
  62. video::E_DRIVER_TYPE DriverType;
  63. //! Size of the window or the video mode in fullscreen mode. Default: 800x600
  64. core::dimension2d<u32> WindowSize;
  65. //! Position of the window on-screen. Default: (-1, -1) or centered.
  66. core::position2di WindowPosition;
  67. //! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 32.
  68. u8 Bits;
  69. //! Minimum Bits per pixel of the depth buffer. Default: 24.
  70. u8 ZBufferBits;
  71. //! Should be set to true if the device should run in fullscreen.
  72. /** Otherwise the device runs in windowed mode. Default: false. */
  73. bool Fullscreen;
  74. //! Maximised window. (Only supported on SDL.) Default: false
  75. bool WindowMaximized;
  76. //! Should a non-fullscreen window be resizable.
  77. /** Might not be supported by all devices. Ignored when Fullscreen is true.
  78. Values: 0 = not resizable, 1 = resizable, 2 = system decides default itself
  79. Default: 2*/
  80. u8 WindowResizable;
  81. //! Specifies if the stencil buffer should be enabled.
  82. /** Set this to true, if you want the engine be able to draw
  83. stencil buffer shadows. Note that not all drivers are able to
  84. use the stencil buffer, hence it can be ignored during device
  85. creation. Without the stencil buffer no shadows will be drawn.
  86. Default: true. */
  87. bool Stencilbuffer;
  88. //! Specifies vertical synchronization.
  89. /** If set to true, the driver will wait for the vertical
  90. retrace period, otherwise not. May be silently ignored.
  91. Default: false */
  92. bool Vsync;
  93. //! Specifies if the device should use fullscreen anti aliasing
  94. /** Makes sharp/pixelated edges softer, but requires more
  95. performance. Also, 2D elements might look blurred with this
  96. switched on. The resulting rendering quality also depends on
  97. the hardware and driver you are using, your program might look
  98. different on different hardware with this. So if you are
  99. writing a game/application with AntiAlias switched on, it would
  100. be a good idea to make it possible to switch this option off
  101. again by the user.
  102. The value is the maximal antialiasing factor requested for
  103. the device. The creation method will automatically try smaller
  104. values if no window can be created with the given value.
  105. Value one is usually the same as 0 (disabled), but might be a
  106. special value on some platforms. On D3D devices it maps to
  107. NONMASKABLE.
  108. Default value: 0 - disabled */
  109. u8 AntiAlias;
  110. //! Whether the main framebuffer uses an alpha channel.
  111. /** In some situations it might be desirable to get a color
  112. buffer with an alpha channel, e.g. when rendering into a
  113. transparent window or overlay. If this flag is set the device
  114. tries to create a framebuffer with alpha channel.
  115. If this flag is set, only color buffers with alpha channel
  116. are considered. Otherwise, it depends on the actual hardware
  117. if the colorbuffer has an alpha channel or not.
  118. Default value: false */
  119. bool WithAlphaChannel;
  120. //! Whether the main framebuffer uses doublebuffering.
  121. /** This should be usually enabled, in order to avoid render
  122. artifacts on the visible framebuffer. However, it might be
  123. useful to use only one buffer on very small devices. If no
  124. doublebuffering is available, the drivers will fall back to
  125. single buffers. Default value: true */
  126. bool Doublebuffer;
  127. //! Specifies if the device should use stereo buffers
  128. /** Some high-end gfx cards support two framebuffers for direct
  129. support of stereoscopic output devices. If this flag is set the
  130. device tries to create a stereo context.
  131. Currently only supported by OpenGL.
  132. Default value: false */
  133. bool Stereobuffer;
  134. //! A user created event receiver.
  135. IEventReceiver *EventReceiver;
  136. //! Window Id.
  137. /** If this is set to a value other than 0, the Irrlicht Engine
  138. will be created in an already existing window.
  139. For Windows, set this to the HWND of the window you want.
  140. The windowSize and FullScreen options will be ignored when using
  141. the WindowId parameter. Default this is set to 0.
  142. To make Irrlicht run inside the custom window, you still will
  143. have to draw Irrlicht on your own. You can use this loop, as
  144. usual:
  145. \code
  146. while (device->run())
  147. {
  148. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
  149. smgr->drawAll();
  150. driver->endScene();
  151. }
  152. \endcode
  153. Instead of this, you can also simply use your own message loop
  154. using GetMessage, DispatchMessage and whatever. Calling
  155. IrrlichtDevice::run() will cause Irrlicht to dispatch messages
  156. internally too. You need not call Device->run() if you want to
  157. do your own message dispatching loop, but Irrlicht will not be
  158. able to fetch user input then and you have to do it on your own
  159. using the window messages, DirectInput, or whatever. Also,
  160. you'll have to increment the Irrlicht timer.
  161. An alternative, own message dispatching loop without
  162. device->run() would look like this:
  163. \code
  164. MSG msg;
  165. while (true)
  166. {
  167. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  168. {
  169. TranslateMessage(&msg);
  170. DispatchMessage(&msg);
  171. if (msg.message == WM_QUIT)
  172. break;
  173. }
  174. // increase virtual timer time
  175. device->getTimer()->tick();
  176. // draw engine picture
  177. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
  178. smgr->drawAll();
  179. driver->endScene();
  180. }
  181. \endcode
  182. However, there is no need to draw the picture this often. Just
  183. do it how you like. */
  184. void *WindowId;
  185. //! Specifies the logging level used in the logging interface.
  186. /** The default value is ELL_INFORMATION. You can access the ILogger interface
  187. later on from the IrrlichtDevice with getLogger() and set another level.
  188. But if you need more or less logging information already from device creation,
  189. then you have to change it here.
  190. */
  191. ELOG_LEVEL LoggingLevel;
  192. //! Define some private data storage.
  193. /** Used when platform devices need access to OS specific data structures etc.
  194. This is only used for Android at the moment in order to access the native
  195. Java RE. */
  196. void *PrivateData;
  197. //! Set the path where default-shaders to simulate the fixed-function pipeline can be found.
  198. /** This is about the shaders which can be found in media/Shaders by default. It's only necessary
  199. to set when using OGL-ES 2.0 */
  200. irr::io::path OGLES2ShaderPath;
  201. //! Enable debug and error checks in video driver.
  202. bool DriverDebug;
  203. };
  204. } // end namespace irr