1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__
\r
6 #define __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__
\r
8 #include "EDriverTypes.h"
\r
9 #include "EDeviceTypes.h"
\r
10 #include "dimension2d.h"
\r
11 #include "ILogger.h"
\r
12 #include "position2d.h"
\r
14 #include "IrrCompileConfig.h"
\r
18 class IEventReceiver;
\r
20 //! Structure for holding Irrlicht Device creation parameters.
\r
21 /** This structure is used in the createDeviceEx() function. */
\r
22 struct SIrrlichtCreationParameters
\r
24 //! Constructs a SIrrlichtCreationParameters structure with default values.
\r
25 SIrrlichtCreationParameters() :
\r
26 DeviceType(EIDT_BEST),
\r
27 DriverType(video::EDT_BURNINGSVIDEO),
\r
28 WindowSize(core::dimension2d<u32>(800, 600)),
\r
29 WindowPosition(core::position2di(-1,-1)),
\r
34 Stencilbuffer(true),
\r
38 WithAlphaChannel(false),
\r
41 Stereobuffer(false),
\r
42 HighPrecisionFPU(false),
\r
46 LoggingLevel(ELL_DEBUG),
\r
48 LoggingLevel(ELL_INFORMATION),
\r
51 DriverMultithreaded(false),
\r
52 UsePerformanceTimer(true),
\r
53 SDK_version_do_not_use(IRRLICHT_SDK_VERSION),
\r
55 #if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) || defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_EMSCRIPTEN_PLATFORM_)
\r
56 OGLES2ShaderPath("media/Shaders/")
\r
58 OGLES2ShaderPath("../../media/Shaders/")
\r
63 SIrrlichtCreationParameters(const SIrrlichtCreationParameters& other) :
\r
64 SDK_version_do_not_use(IRRLICHT_SDK_VERSION)
\r
67 SIrrlichtCreationParameters& operator=(const SIrrlichtCreationParameters& other)
\r
69 DeviceType = other.DeviceType;
\r
70 DriverType = other.DriverType;
\r
71 WindowSize = other.WindowSize;
\r
72 WindowPosition = other.WindowPosition;
\r
74 ZBufferBits = other.ZBufferBits;
\r
75 Fullscreen = other.Fullscreen;
\r
76 WindowResizable = other.WindowResizable;
\r
77 Stencilbuffer = other.Stencilbuffer;
\r
78 Vsync = other.Vsync;
\r
79 AntiAlias = other.AntiAlias;
\r
80 HandleSRGB = other.HandleSRGB;
\r
81 WithAlphaChannel = other.WithAlphaChannel;
\r
82 Doublebuffer = other.Doublebuffer;
\r
83 IgnoreInput = other.IgnoreInput;
\r
84 Stereobuffer = other.Stereobuffer;
\r
85 HighPrecisionFPU = other.HighPrecisionFPU;
\r
86 EventReceiver = other.EventReceiver;
\r
87 WindowId = other.WindowId;
\r
88 LoggingLevel = other.LoggingLevel;
\r
89 DisplayAdapter = other.DisplayAdapter;
\r
90 DriverMultithreaded = other.DriverMultithreaded;
\r
91 UsePerformanceTimer = other.UsePerformanceTimer;
\r
92 PrivateData = other.PrivateData;
\r
93 OGLES2ShaderPath = other.OGLES2ShaderPath;
\r
97 //! Type of the device.
\r
98 /** This setting decides the windowing system used by the device, most device types are native
\r
99 to a specific operating system and so may not be available.
\r
100 EIDT_WIN32 is only available on Windows desktops,
\r
101 EIDT_COCOA is only available on Mac OSX,
\r
102 EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
\r
103 EIDT_SDL is available on most systems if compiled in,
\r
104 EIDT_BEST will select the best available device for your operating system.
\r
105 Default: EIDT_BEST. */
\r
106 E_DEVICE_TYPE DeviceType;
\r
108 //! Type of video driver used to render graphics.
\r
109 /** This can currently be video::EDT_NULL, video::EDT_SOFTWARE,
\r
110 video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D9, and video::EDT_OPENGL.
\r
111 Default: EDT_BURNINGSVIDEO. */
\r
112 video::E_DRIVER_TYPE DriverType;
\r
114 //! Size of the window or the video mode in fullscreen mode. Default: 800x600
\r
115 core::dimension2d<u32> WindowSize;
\r
117 //! Position of the window on-screen. Default: (-1, -1) or centered.
\r
118 core::position2di WindowPosition;
\r
120 //! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 32.
\r
123 //! Minimum Bits per pixel of the depth buffer. Default: 24.
\r
126 //! Should be set to true if the device should run in fullscreen.
\r
127 /** Otherwise the device runs in windowed mode. Default: false. */
\r
130 //! Should a non-fullscreen window be resizable.
\r
131 /** Might not be supported by all devices. Ignored when Fullscreen is true.
\r
132 Values: 0 = not resizable, 1 = resizable, 2 = system decides default itself
\r
134 u8 WindowResizable;
\r
136 //! Specifies if the stencil buffer should be enabled.
\r
137 /** Set this to true, if you want the engine be able to draw
\r
138 stencil buffer shadows. Note that not all drivers are able to
\r
139 use the stencil buffer, hence it can be ignored during device
\r
140 creation. Without the stencil buffer no shadows will be drawn.
\r
142 bool Stencilbuffer;
\r
144 //! Specifies vertical synchronization.
\r
145 /** If set to true, the driver will wait for the vertical
\r
146 retrace period, otherwise not. May be silently ignored.
\r
150 //! Specifies if the device should use fullscreen anti aliasing
\r
151 /** Makes sharp/pixelated edges softer, but requires more
\r
152 performance. Also, 2D elements might look blurred with this
\r
153 switched on. The resulting rendering quality also depends on
\r
154 the hardware and driver you are using, your program might look
\r
155 different on different hardware with this. So if you are
\r
156 writing a game/application with AntiAlias switched on, it would
\r
157 be a good idea to make it possible to switch this option off
\r
159 The value is the maximal antialiasing factor requested for
\r
160 the device. The creation method will automatically try smaller
\r
161 values if no window can be created with the given value.
\r
162 Value one is usually the same as 0 (disabled), but might be a
\r
163 special value on some platforms. On D3D devices it maps to
\r
165 Default value: 0 - disabled */
\r
168 //! Flag to enable proper sRGB and linear color handling
\r
169 /** In most situations, it is desirable to have the color handling in
\r
170 non-linear sRGB color space, and only do the intermediate color
\r
171 calculations in linear RGB space. If this flag is enabled, the device and
\r
172 driver try to assure that all color input and output are color corrected
\r
173 and only the internal color representation is linear. This means, that
\r
174 the color output is properly gamma-adjusted to provide the brighter
\r
175 colors for monitor display. And that blending and lighting give a more
\r
176 natural look, due to proper conversion from non-linear colors into linear
\r
177 color space for blend operations. If this flag is enabled, all texture colors
\r
178 (which are usually in sRGB space) are correctly displayed. However vertex colors
\r
179 and other explicitly set values have to be manually encoded in linear color space.
\r
180 Default value: false. */
\r
183 //! Whether the main framebuffer uses an alpha channel.
\r
184 /** In some situations it might be desirable to get a color
\r
185 buffer with an alpha channel, e.g. when rendering into a
\r
186 transparent window or overlay. If this flag is set the device
\r
187 tries to create a framebuffer with alpha channel.
\r
188 If this flag is set, only color buffers with alpha channel
\r
189 are considered. Otherwise, it depends on the actual hardware
\r
190 if the colorbuffer has an alpha channel or not.
\r
191 Default value: false */
\r
192 bool WithAlphaChannel;
\r
194 //! Whether the main framebuffer uses doublebuffering.
\r
195 /** This should be usually enabled, in order to avoid render
\r
196 artifacts on the visible framebuffer. However, it might be
\r
197 useful to use only one buffer on very small devices. If no
\r
198 doublebuffering is available, the drivers will fall back to
\r
199 single buffers. Default value: true */
\r
202 //! Specifies if the device should ignore input events
\r
203 /** This is only relevant when using external I/O handlers.
\r
204 External windows need to take care of this themselves.
\r
205 Currently only supported by X11.
\r
206 Default value: false */
\r
209 //! Specifies if the device should use stereo buffers
\r
210 /** Some high-end gfx cards support two framebuffers for direct
\r
211 support of stereoscopic output devices. If this flag is set the
\r
212 device tries to create a stereo context.
\r
213 Currently only supported by OpenGL.
\r
214 Default value: false */
\r
217 //! Specifies if the device should use high precision FPU setting
\r
218 /** This is only relevant for DirectX Devices, which switch to
\r
219 low FPU precision by default for performance reasons. However,
\r
220 this may lead to problems with the other computations of the
\r
221 application. In this case setting this flag to true should help
\r
222 - on the expense of performance loss, though.
\r
223 Default value: false */
\r
224 bool HighPrecisionFPU;
\r
226 //! A user created event receiver.
\r
227 IEventReceiver* EventReceiver;
\r
230 /** If this is set to a value other than 0, the Irrlicht Engine
\r
231 will be created in an already existing window.
\r
232 For Windows, set this to the HWND of the window you want.
\r
233 For iOS, assign UIView to this variable.
\r
234 The windowSize and FullScreen options will be ignored when using
\r
235 the WindowId parameter. Default this is set to 0.
\r
236 To make Irrlicht run inside the custom window, you still will
\r
237 have to draw Irrlicht on your own. You can use this loop, as
\r
240 while (device->run())
\r
242 driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
\r
244 driver->endScene();
\r
247 Instead of this, you can also simply use your own message loop
\r
248 using GetMessage, DispatchMessage and whatever. Calling
\r
249 IrrlichtDevice::run() will cause Irrlicht to dispatch messages
\r
250 internally too. You need not call Device->run() if you want to
\r
251 do your own message dispatching loop, but Irrlicht will not be
\r
252 able to fetch user input then and you have to do it on your own
\r
253 using the window messages, DirectInput, or whatever. Also,
\r
254 you'll have to increment the Irrlicht timer.
\r
255 An alternative, own message dispatching loop without
\r
256 device->run() would look like this:
\r
261 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
263 TranslateMessage(&msg);
\r
264 DispatchMessage(&msg);
\r
266 if (msg.message == WM_QUIT)
\r
270 // increase virtual timer time
\r
271 device->getTimer()->tick();
\r
273 // draw engine picture
\r
274 driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
\r
276 driver->endScene();
\r
279 However, there is no need to draw the picture this often. Just
\r
280 do it how you like. */
\r
283 //! Specifies the logging level used in the logging interface.
\r
284 /** The default value is ELL_INFORMATION. You can access the ILogger interface
\r
285 later on from the IrrlichtDevice with getLogger() and set another level.
\r
286 But if you need more or less logging information already from device creation,
\r
287 then you have to change it here.
\r
289 ELOG_LEVEL LoggingLevel;
\r
291 //! Allows to select which graphic card is used for rendering when more than one card is in the system.
\r
292 /** So far only supported on D3D */
\r
293 u32 DisplayAdapter;
\r
295 //! Create the driver multithreaded.
\r
296 /** Default is false. Enabling this can slow down your application.
\r
297 Note that this does _not_ make Irrlicht threadsafe, but only the underlying driver-API for the graphiccard.
\r
298 So far only supported on D3D. */
\r
299 bool DriverMultithreaded;
\r
301 //! Enables use of high performance timers on Windows platform.
\r
302 /** When performance timers are not used, standard GetTickCount()
\r
303 is used instead which usually has worse resolution, but also less
\r
304 problems with speed stepping and other techniques.
\r
306 bool UsePerformanceTimer;
\r
308 //! Don't use or change this parameter.
\r
309 /** Always set it to IRRLICHT_SDK_VERSION, which is done by default.
\r
310 This is needed for sdk version checks. */
\r
311 const c8* const SDK_version_do_not_use;
\r
313 //! Define some private data storage.
\r
314 /** Used when platform devices need access to OS specific data structures etc.
\r
315 This is only used for Android at th emoment in order to access the native
\r
319 //! Set the path where default-shaders to simulate the fixed-function pipeline can be found.
\r
320 /** This is about the shaders which can be found in media/Shaders by default. It's only necessary
\r
321 to set when using OGL-ES 2.0 */
\r
322 irr::io::path OGLES2ShaderPath;
\r
326 } // end namespace irr
\r