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
33 WindowResizable(false),
\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
135 bool WindowResizable;
\r
137 //! Specifies if the stencil buffer should be enabled.
\r
138 /** Set this to true, if you want the engine be able to draw
\r
139 stencil buffer shadows. Note that not all drivers are able to
\r
140 use the stencil buffer, hence it can be ignored during device
\r
141 creation. Without the stencil buffer no shadows will be drawn.
\r
143 bool Stencilbuffer;
\r
145 //! Specifies vertical synchronization.
\r
146 /** If set to true, the driver will wait for the vertical
\r
147 retrace period, otherwise not. May be silently ignored.
\r
151 //! Specifies if the device should use fullscreen anti aliasing
\r
152 /** Makes sharp/pixelated edges softer, but requires more
\r
153 performance. Also, 2D elements might look blurred with this
\r
154 switched on. The resulting rendering quality also depends on
\r
155 the hardware and driver you are using, your program might look
\r
156 different on different hardware with this. So if you are
\r
157 writing a game/application with AntiAlias switched on, it would
\r
158 be a good idea to make it possible to switch this option off
\r
160 The value is the maximal antialiasing factor requested for
\r
161 the device. The creation method will automatically try smaller
\r
162 values if no window can be created with the given value.
\r
163 Value one is usually the same as 0 (disabled), but might be a
\r
164 special value on some platforms. On D3D devices it maps to
\r
166 Default value: 0 - disabled */
\r
169 //! Flag to enable proper sRGB and linear color handling
\r
170 /** In most situations, it is desirable to have the color handling in
\r
171 non-linear sRGB color space, and only do the intermediate color
\r
172 calculations in linear RGB space. If this flag is enabled, the device and
\r
173 driver try to assure that all color input and output are color corrected
\r
174 and only the internal color representation is linear. This means, that
\r
175 the color output is properly gamma-adjusted to provide the brighter
\r
176 colors for monitor display. And that blending and lighting give a more
\r
177 natural look, due to proper conversion from non-linear colors into linear
\r
178 color space for blend operations. If this flag is enabled, all texture colors
\r
179 (which are usually in sRGB space) are correctly displayed. However vertex colors
\r
180 and other explicitly set values have to be manually encoded in linear color space.
\r
181 Default value: false. */
\r
184 //! Whether the main framebuffer uses an alpha channel.
\r
185 /** In some situations it might be desirable to get a color
\r
186 buffer with an alpha channel, e.g. when rendering into a
\r
187 transparent window or overlay. If this flag is set the device
\r
188 tries to create a framebuffer with alpha channel.
\r
189 If this flag is set, only color buffers with alpha channel
\r
190 are considered. Otherwise, it depends on the actual hardware
\r
191 if the colorbuffer has an alpha channel or not.
\r
192 Default value: false */
\r
193 bool WithAlphaChannel;
\r
195 //! Whether the main framebuffer uses doublebuffering.
\r
196 /** This should be usually enabled, in order to avoid render
\r
197 artifacts on the visible framebuffer. However, it might be
\r
198 useful to use only one buffer on very small devices. If no
\r
199 doublebuffering is available, the drivers will fall back to
\r
200 single buffers. Default value: true */
\r
203 //! Specifies if the device should ignore input events
\r
204 /** This is only relevant when using external I/O handlers.
\r
205 External windows need to take care of this themselves.
\r
206 Currently only supported by X11.
\r
207 Default value: false */
\r
210 //! Specifies if the device should use stereo buffers
\r
211 /** Some high-end gfx cards support two framebuffers for direct
\r
212 support of stereoscopic output devices. If this flag is set the
\r
213 device tries to create a stereo context.
\r
214 Currently only supported by OpenGL.
\r
215 Default value: false */
\r
218 //! Specifies if the device should use high precision FPU setting
\r
219 /** This is only relevant for DirectX Devices, which switch to
\r
220 low FPU precision by default for performance reasons. However,
\r
221 this may lead to problems with the other computations of the
\r
222 application. In this case setting this flag to true should help
\r
223 - on the expense of performance loss, though.
\r
224 Default value: false */
\r
225 bool HighPrecisionFPU;
\r
227 //! A user created event receiver.
\r
228 IEventReceiver* EventReceiver;
\r
231 /** If this is set to a value other than 0, the Irrlicht Engine
\r
232 will be created in an already existing window.
\r
233 For Windows, set this to the HWND of the window you want.
\r
234 For iOS, assign UIView to this variable.
\r
235 The windowSize and FullScreen options will be ignored when using
\r
236 the WindowId parameter. Default this is set to 0.
\r
237 To make Irrlicht run inside the custom window, you still will
\r
238 have to draw Irrlicht on your own. You can use this loop, as
\r
241 while (device->run())
\r
243 driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
\r
245 driver->endScene();
\r
248 Instead of this, you can also simply use your own message loop
\r
249 using GetMessage, DispatchMessage and whatever. Calling
\r
250 IrrlichtDevice::run() will cause Irrlicht to dispatch messages
\r
251 internally too. You need not call Device->run() if you want to
\r
252 do your own message dispatching loop, but Irrlicht will not be
\r
253 able to fetch user input then and you have to do it on your own
\r
254 using the window messages, DirectInput, or whatever. Also,
\r
255 you'll have to increment the Irrlicht timer.
\r
256 An alternative, own message dispatching loop without
\r
257 device->run() would look like this:
\r
262 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
264 TranslateMessage(&msg);
\r
265 DispatchMessage(&msg);
\r
267 if (msg.message == WM_QUIT)
\r
271 // increase virtual timer time
\r
272 device->getTimer()->tick();
\r
274 // draw engine picture
\r
275 driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0);
\r
277 driver->endScene();
\r
280 However, there is no need to draw the picture this often. Just
\r
281 do it how you like. */
\r
284 //! Specifies the logging level used in the logging interface.
\r
285 /** The default value is ELL_INFORMATION. You can access the ILogger interface
\r
286 later on from the IrrlichtDevice with getLogger() and set another level.
\r
287 But if you need more or less logging information already from device creation,
\r
288 then you have to change it here.
\r
290 ELOG_LEVEL LoggingLevel;
\r
292 //! Allows to select which graphic card is used for rendering when more than one card is in the system.
\r
293 /** So far only supported on D3D */
\r
294 u32 DisplayAdapter;
\r
296 //! Create the driver multithreaded.
\r
297 /** Default is false. Enabling this can slow down your application.
\r
298 Note that this does _not_ make Irrlicht threadsafe, but only the underlying driver-API for the graphiccard.
\r
299 So far only supported on D3D. */
\r
300 bool DriverMultithreaded;
\r
302 //! Enables use of high performance timers on Windows platform.
\r
303 /** When performance timers are not used, standard GetTickCount()
\r
304 is used instead which usually has worse resolution, but also less
\r
305 problems with speed stepping and other techniques.
\r
307 bool UsePerformanceTimer;
\r
309 //! Don't use or change this parameter.
\r
310 /** Always set it to IRRLICHT_SDK_VERSION, which is done by default.
\r
311 This is needed for sdk version checks. */
\r
312 const c8* const SDK_version_do_not_use;
\r
314 //! Define some private data storage.
\r
315 /** Used when platform devices need access to OS specific data structures etc.
\r
316 This is only used for Android at th emoment in order to access the native
\r
320 //! Set the path where default-shaders to simulate the fixed-function pipeline can be found.
\r
321 /** This is about the shaders which can be found in media/Shaders by default. It's only necessary
\r
322 to set when using OGL-ES 2.0 */
\r
323 irr::io::path OGLES2ShaderPath;
\r
327 } // end namespace irr
\r