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_WINCE is only available on Windows mobile devices,
\r
102 EIDT_COCOA is only available on Mac OSX,
\r
103 EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
\r
104 EIDT_SDL is available on most systems if compiled in,
\r
105 EIDT_CONSOLE is usually available but can only render to text,
\r
106 EIDT_BEST will select the best available device for your operating system.
\r
107 Default: EIDT_BEST. */
\r
108 E_DEVICE_TYPE DeviceType;
\r
110 //! Type of video driver used to render graphics.
\r
111 /** This can currently be video::EDT_NULL, video::EDT_SOFTWARE,
\r
112 video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D9, and video::EDT_OPENGL.
\r
113 Default: EDT_BURNINGSVIDEO. */
\r
114 video::E_DRIVER_TYPE DriverType;
\r
116 //! Size of the window or the video mode in fullscreen mode. Default: 800x600
\r
117 core::dimension2d<u32> WindowSize;
\r
119 //! Position of the window on-screen. Default: (-1, -1) or centered.
\r
120 core::position2di WindowPosition;
\r
122 //! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 32.
\r
125 //! Minimum Bits per pixel of the depth buffer. Default: 24.
\r
128 //! Should be set to true if the device should run in fullscreen.
\r
129 /** Otherwise the device runs in windowed mode. Default: false. */
\r
132 //! Should a non-fullscreen window be resizable.
\r
133 /** Might not be supported by all devices. Ignored when Fullscreen is true.
\r
134 Values: 0 = not resizable, 1 = resizable, 2 = system decides default itself
\r
136 u8 WindowResizable;
\r
138 //! Specifies if the stencil buffer should be enabled.
\r
139 /** Set this to true, if you want the engine be able to draw
\r
140 stencil buffer shadows. Note that not all drivers are able to
\r
141 use the stencil buffer, hence it can be ignored during device
\r
142 creation. Without the stencil buffer no shadows will be drawn.
\r
144 bool Stencilbuffer;
\r
146 //! Specifies vertical synchronization.
\r
147 /** If set to true, the driver will wait for the vertical
\r
148 retrace period, otherwise not. May be silently ignored.
\r
152 //! Specifies if the device should use fullscreen anti aliasing
\r
153 /** Makes sharp/pixelated edges softer, but requires more
\r
154 performance. Also, 2D elements might look blurred with this
\r
155 switched on. The resulting rendering quality also depends on
\r
156 the hardware and driver you are using, your program might look
\r
157 different on different hardware with this. So if you are
\r
158 writing a game/application with AntiAlias switched on, it would
\r
159 be a good idea to make it possible to switch this option off
\r
161 The value is the maximal antialiasing factor requested for
\r
162 the device. The creation method will automatically try smaller
\r
163 values if no window can be created with the given value.
\r
164 Value one is usually the same as 0 (disabled), but might be a
\r
165 special value on some platforms. On D3D devices it maps to
\r
167 Default value: 0 - disabled */
\r
170 //! Flag to enable proper sRGB and linear color handling
\r
171 /** In most situations, it is desirable to have the color handling in
\r
172 non-linear sRGB color space, and only do the intermediate color
\r
173 calculations in linear RGB space. If this flag is enabled, the device and
\r
174 driver try to assure that all color input and output are color corrected
\r
175 and only the internal color representation is linear. This means, that
\r
176 the color output is properly gamma-adjusted to provide the brighter
\r
177 colors for monitor display. And that blending and lighting give a more
\r
178 natural look, due to proper conversion from non-linear colors into linear
\r
179 color space for blend operations. If this flag is enabled, all texture colors
\r
180 (which are usually in sRGB space) are correctly displayed. However vertex colors
\r
181 and other explicitly set values have to be manually encoded in linear color space.
\r
182 Default value: false. */
\r
185 //! Whether the main framebuffer uses an alpha channel.
\r
186 /** In some situations it might be desirable to get a color
\r
187 buffer with an alpha channel, e.g. when rendering into a
\r
188 transparent window or overlay. If this flag is set the device
\r
189 tries to create a framebuffer with alpha channel.
\r
190 If this flag is set, only color buffers with alpha channel
\r
191 are considered. Otherwise, it depends on the actual hardware
\r
192 if the colorbuffer has an alpha channel or not.
\r
193 Default value: false */
\r
194 bool WithAlphaChannel;
\r
196 //! Whether the main framebuffer uses doublebuffering.
\r
197 /** This should be usually enabled, in order to avoid render
\r
198 artifacts on the visible framebuffer. However, it might be
\r
199 useful to use only one buffer on very small devices. If no
\r
200 doublebuffering is available, the drivers will fall back to
\r
201 single buffers. Default value: true */
\r
204 //! Specifies if the device should ignore input events
\r
205 /** This is only relevant when using external I/O handlers.
\r
206 External windows need to take care of this themselves.
\r
207 Currently only supported by X11.
\r
208 Default value: false */
\r
211 //! Specifies if the device should use stereo buffers
\r
212 /** Some high-end gfx cards support two framebuffers for direct
\r
213 support of stereoscopic output devices. If this flag is set the
\r
214 device tries to create a stereo context.
\r
215 Currently only supported by OpenGL.
\r
216 Default value: false */
\r
219 //! Specifies if the device should use high precision FPU setting
\r
220 /** This is only relevant for DirectX Devices, which switch to
\r
221 low FPU precision by default for performance reasons. However,
\r
222 this may lead to problems with the other computations of the
\r
223 application. In this case setting this flag to true should help
\r
224 - on the expense of performance loss, though.
\r
225 Default value: false */
\r
226 bool HighPrecisionFPU;
\r
228 //! A user created event receiver.
\r
229 IEventReceiver* EventReceiver;
\r
232 /** If this is set to a value other than 0, the Irrlicht Engine
\r
233 will be created in an already existing window.
\r
234 For Windows, set this to the HWND of the window you want.
\r
235 For iOS, assign UIView to this variable.
\r
236 The windowSize and FullScreen options will be ignored when using
\r
237 the WindowId parameter. Default this is set to 0.
\r
238 To make Irrlicht run inside the custom window, you still will
\r
239 have to draw Irrlicht on your own. You can use this loop, as
\r
242 while (device->run())
\r
244 driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
\r
246 driver->endScene();
\r
249 Instead of this, you can also simply use your own message loop
\r
250 using GetMessage, DispatchMessage and whatever. Calling
\r
251 IrrlichtDevice::run() will cause Irrlicht to dispatch messages
\r
252 internally too. You need not call Device->run() if you want to
\r
253 do your own message dispatching loop, but Irrlicht will not be
\r
254 able to fetch user input then and you have to do it on your own
\r
255 using the window messages, DirectInput, or whatever. Also,
\r
256 you'll have to increment the Irrlicht timer.
\r
257 An alternative, own message dispatching loop without
\r
258 device->run() would look like this:
\r
263 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
265 TranslateMessage(&msg);
\r
266 DispatchMessage(&msg);
\r
268 if (msg.message == WM_QUIT)
\r
272 // increase virtual timer time
\r
273 device->getTimer()->tick();
\r
275 // draw engine picture
\r
276 driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
\r
278 driver->endScene();
\r
281 However, there is no need to draw the picture this often. Just
\r
282 do it how you like. */
\r
285 //! Specifies the logging level used in the logging interface.
\r
286 /** The default value is ELL_INFORMATION. You can access the ILogger interface
\r
287 later on from the IrrlichtDevice with getLogger() and set another level.
\r
288 But if you need more or less logging information already from device creation,
\r
289 then you have to change it here.
\r
291 ELOG_LEVEL LoggingLevel;
\r
293 //! Allows to select which graphic card is used for rendering when more than one card is in the system.
\r
294 /** So far only supported on D3D */
\r
295 u32 DisplayAdapter;
\r
297 //! Create the driver multithreaded.
\r
298 /** Default is false. Enabling this can slow down your application.
\r
299 Note that this does _not_ make Irrlicht threadsafe, but only the underlying driver-API for the graphiccard.
\r
300 So far only supported on D3D. */
\r
301 bool DriverMultithreaded;
\r
303 //! Enables use of high performance timers on Windows platform.
\r
304 /** When performance timers are not used, standard GetTickCount()
\r
305 is used instead which usually has worse resolution, but also less
\r
306 problems with speed stepping and other techniques.
\r
308 bool UsePerformanceTimer;
\r
310 //! Don't use or change this parameter.
\r
311 /** Always set it to IRRLICHT_SDK_VERSION, which is done by default.
\r
312 This is needed for sdk version checks. */
\r
313 const c8* const SDK_version_do_not_use;
\r
315 //! Define some private data storage.
\r
316 /** Used when platform devices need access to OS specific data structures etc.
\r
317 This is only used for Android at th emoment in order to access the native
\r
321 //! Set the path where default-shaders to simulate the fixed-function pipeline can be found.
\r
322 /** This is about the shaders which can be found in media/Shaders by default. It's only necessary
\r
323 to set when using OGL-ES 2.0 */
\r
324 irr::io::path OGLES2ShaderPath;
\r
328 } // end namespace irr
\r