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