ee8662ed697c0a1ea2f3fad2bee7e72fa5d8a87f
[oweals/minetest.git] / src / client / clientlauncher.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "mainmenumanager.h"
21 #include "debug.h"
22 #include "clouds.h"
23 #include "server.h"
24 #include "filesys.h"
25 #include "guiMainMenu.h"
26 #include "game.h"
27 #include "chat.h"
28 #include "gettext.h"
29 #include "profiler.h"
30 #include "log.h"
31 #include "serverlist.h"
32 #include "guiEngine.h"
33 #include "player.h"
34 #include "fontengine.h"
35 #include "joystick_controller.h"
36 #include "clientlauncher.h"
37
38 /* mainmenumanager.h
39  */
40 gui::IGUIEnvironment *guienv = NULL;
41 gui::IGUIStaticText *guiroot = NULL;
42 MainMenuManager g_menumgr;
43
44 bool noMenuActive()
45 {
46         return g_menumgr.menuCount() == 0;
47 }
48
49 // Passed to menus to allow disconnecting and exiting
50 MainGameCallback *g_gamecallback = NULL;
51
52
53 // Instance of the time getter
54 static TimeGetter *g_timegetter = NULL;
55
56 u32 getTimeMs()
57 {
58         if (g_timegetter == NULL)
59                 return 0;
60         return g_timegetter->getTime(PRECISION_MILLI);
61 }
62
63 u32 getTime(TimePrecision prec) {
64         if (g_timegetter == NULL)
65                 return 0;
66         return g_timegetter->getTime(prec);
67 }
68
69 ClientLauncher::~ClientLauncher()
70 {
71         if (receiver)
72                 delete receiver;
73
74         if (input)
75                 delete input;
76
77         if (g_fontengine)
78                 delete g_fontengine;
79
80         if (device)
81                 device->drop();
82 }
83
84
85 bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
86 {
87         init_args(game_params, cmd_args);
88
89         // List video modes if requested
90         if (list_video_modes)
91                 return print_video_modes();
92
93         if (!init_engine()) {
94                 errorstream << "Could not initialize game engine." << std::endl;
95                 return false;
96         }
97
98         // Create time getter
99         g_timegetter = new IrrlichtTimeGetter(device);
100
101         // Speed tests (done after irrlicht is loaded to get timer)
102         if (cmd_args.getFlag("speedtests")) {
103                 dstream << "Running speed tests" << std::endl;
104                 speed_tests();
105                 return true;
106         }
107
108         video::IVideoDriver *video_driver = device->getVideoDriver();
109         if (video_driver == NULL) {
110                 errorstream << "Could not initialize video driver." << std::endl;
111                 return false;
112         }
113
114         porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C);
115
116         /*
117                 This changes the minimum allowed number of vertices in a VBO.
118                 Default is 500.
119         */
120         //driver->setMinHardwareBufferVertexCount(50);
121
122         // Create game callback for menus
123         g_gamecallback = new MainGameCallback(device);
124
125         device->setResizable(true);
126
127         if (random_input)
128                 input = new RandomInputHandler();
129         else
130                 input = new RealInputHandler(device, receiver);
131
132         smgr = device->getSceneManager();
133         smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
134
135         guienv = device->getGUIEnvironment();
136         skin = guienv->getSkin();
137         skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
138         skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0));
139         skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30));
140         skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));
141         skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 120, 50));
142         skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255));
143
144         g_fontengine = new FontEngine(g_settings, guienv);
145         FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed.");
146
147 #if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
148         // Irrlicht 1.8 input colours
149         skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128));
150         skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255, 96, 134, 49));
151 #endif
152
153         // Create the menu clouds
154         if (!g_menucloudsmgr)
155                 g_menucloudsmgr = smgr->createNewSceneManager();
156         if (!g_menuclouds)
157                 g_menuclouds = new Clouds(g_menucloudsmgr->getRootSceneNode(),
158                                 g_menucloudsmgr, -1, rand(), 100);
159         g_menuclouds->update(v2f(0, 0), video::SColor(255, 200, 200, 255));
160         scene::ICameraSceneNode* camera;
161         camera = g_menucloudsmgr->addCameraSceneNode(0,
162                                 v3f(0, 0, 0), v3f(0, 60, 100));
163         camera->setFarValue(10000);
164
165         /*
166                 GUI stuff
167         */
168
169         ChatBackend chat_backend;
170
171         // If an error occurs, this is set to something by menu().
172         // It is then displayed before the menu shows on the next call to menu()
173         std::string error_message;
174         bool reconnect_requested = false;
175
176         bool first_loop = true;
177
178         /*
179                 Menu-game loop
180         */
181         bool retval = true;
182         bool *kill = porting::signal_handler_killstatus();
183
184         while (device->run() && !*kill && !g_gamecallback->shutdown_requested)
185         {
186                 // Set the window caption
187                 const wchar_t *text = wgettext("Main Menu");
188                 device->setWindowCaption((utf8_to_wide(PROJECT_NAME_C) + L" [" + text + L"]").c_str());
189                 delete[] text;
190
191                 try {   // This is used for catching disconnects
192
193                         guienv->clear();
194
195                         /*
196                                 We need some kind of a root node to be able to add
197                                 custom gui elements directly on the screen.
198                                 Otherwise they won't be automatically drawn.
199                         */
200                         guiroot = guienv->addStaticText(L"", core::rect<s32>(0, 0, 10000, 10000));
201
202                         bool game_has_run = launch_game(error_message, reconnect_requested,
203                                 game_params, cmd_args);
204
205                         // Reset the reconnect_requested flag
206                         reconnect_requested = false;
207
208                         // If skip_main_menu, we only want to startup once
209                         if (skip_main_menu && !first_loop)
210                                 break;
211
212                         first_loop = false;
213
214                         if (!game_has_run) {
215                                 if (skip_main_menu)
216                                         break;
217                                 else
218                                         continue;
219                         }
220
221                         // Break out of menu-game loop to shut down cleanly
222                         if (!device->run() || *kill) {
223                                 if (g_settings_path != "")
224                                         g_settings->updateConfigFile(g_settings_path.c_str());
225                                 break;
226                         }
227
228                         if (current_playername.length() > PLAYERNAME_SIZE-1) {
229                                 error_message = gettext("Player name too long.");
230                                 playername = current_playername.substr(0, PLAYERNAME_SIZE-1);
231                                 g_settings->set("name", playername);
232                                 continue;
233                         }
234
235                         device->getVideoDriver()->setTextureCreationFlag(
236                                         video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
237
238 #ifdef HAVE_TOUCHSCREENGUI
239                         receiver->m_touchscreengui = new TouchScreenGUI(device, receiver);
240                         g_touchscreengui = receiver->m_touchscreengui;
241 #endif
242
243                         the_game(
244                                 kill,
245                                 random_input,
246                                 input,
247                                 device,
248                                 worldspec.path,
249                                 current_playername,
250                                 current_password,
251                                 current_address,
252                                 current_port,
253                                 error_message,
254                                 chat_backend,
255                                 &reconnect_requested,
256                                 gamespec,
257                                 simple_singleplayer_mode
258                         );
259                         smgr->clear();
260
261 #ifdef HAVE_TOUCHSCREENGUI
262                         delete g_touchscreengui;
263                         g_touchscreengui = NULL;
264                         receiver->m_touchscreengui = NULL;
265 #endif
266
267                 } //try
268                 catch (con::PeerNotFoundException &e) {
269                         error_message = gettext("Connection error (timed out?)");
270                         errorstream << error_message << std::endl;
271                 }
272
273 #ifdef NDEBUG
274                 catch (std::exception &e) {
275                         std::string error_message = "Some exception: \"";
276                         error_message += e.what();
277                         error_message += "\"";
278                         errorstream << error_message << std::endl;
279                 }
280 #endif
281
282                 // If no main menu, show error and exit
283                 if (skip_main_menu) {
284                         if (!error_message.empty()) {
285                                 verbosestream << "error_message = "
286                                               << error_message << std::endl;
287                                 retval = false;
288                         }
289                         break;
290                 }
291         } // Menu-game loop
292
293         g_menuclouds->drop();
294         g_menucloudsmgr->drop();
295
296         return retval;
297 }
298
299 void ClientLauncher::init_args(GameParams &game_params, const Settings &cmd_args)
300 {
301
302         skip_main_menu = cmd_args.getFlag("go");
303
304         // FIXME: This is confusing (but correct)
305
306         /* If world_path is set then override it unless skipping the main menu using
307          * the --go command line param. Else, give preference to the address
308          * supplied on the command line
309          */
310         address = g_settings->get("address");
311         if (game_params.world_path != "" && !skip_main_menu)
312                 address = "";
313         else if (cmd_args.exists("address"))
314                 address = cmd_args.get("address");
315
316         playername = g_settings->get("name");
317         if (cmd_args.exists("name"))
318                 playername = cmd_args.get("name");
319
320         list_video_modes = cmd_args.getFlag("videomodes");
321
322         use_freetype = g_settings->getBool("freetype");
323
324         random_input = g_settings->getBool("random_input")
325                         || cmd_args.getFlag("random-input");
326 }
327
328 bool ClientLauncher::init_engine()
329 {
330         receiver = new MyEventReceiver();
331         create_engine_device();
332         return device != NULL;
333 }
334
335 bool ClientLauncher::launch_game(std::string &error_message,
336                 bool reconnect_requested, GameParams &game_params,
337                 const Settings &cmd_args)
338 {
339         // Initialize menu data
340         MainMenuData menudata;
341         menudata.address                         = address;
342         menudata.name                            = playername;
343         menudata.password                        = password;
344         menudata.port                            = itos(game_params.socket_port);
345         menudata.script_data.errormessage        = error_message;
346         menudata.script_data.reconnect_requested = reconnect_requested;
347
348         error_message.clear();
349
350         if (cmd_args.exists("password"))
351                 menudata.password = cmd_args.get("password");
352
353         menudata.enable_public = g_settings->getBool("server_announce");
354
355         // If a world was commanded, append and select it
356         if (game_params.world_path != "") {
357                 worldspec.gameid = getWorldGameId(game_params.world_path, true);
358                 worldspec.name = _("[--world parameter]");
359
360                 if (worldspec.gameid == "") {   // Create new
361                         worldspec.gameid = g_settings->get("default_game");
362                         worldspec.name += " [new]";
363                 }
364                 worldspec.path = game_params.world_path;
365         }
366
367         /* Show the GUI menu
368          */
369         if (!skip_main_menu) {
370                 main_menu(&menudata);
371
372                 // Skip further loading if there was an exit signal.
373                 if (*porting::signal_handler_killstatus())
374                         return false;
375
376                 address = menudata.address;
377                 int newport = stoi(menudata.port);
378                 if (newport != 0)
379                         game_params.socket_port = newport;
380
381                 simple_singleplayer_mode = menudata.simple_singleplayer_mode;
382
383                 std::vector<WorldSpec> worldspecs = getAvailableWorlds();
384
385                 if (menudata.selected_world >= 0
386                                 && menudata.selected_world < (int)worldspecs.size()) {
387                         g_settings->set("selected_world_path",
388                                         worldspecs[menudata.selected_world].path);
389                         worldspec = worldspecs[menudata.selected_world];
390                 }
391         }
392
393         if (!menudata.script_data.errormessage.empty()) {
394                 /* The calling function will pass this back into this function upon the
395                  * next iteration (if any) causing it to be displayed by the GUI
396                  */
397                 error_message = menudata.script_data.errormessage;
398                 return false;
399         }
400
401         if (menudata.name == "")
402                 menudata.name = std::string("Guest") + itos(myrand_range(1000, 9999));
403         else
404                 playername = menudata.name;
405
406         password = menudata.password;
407
408         g_settings->set("name", playername);
409
410         current_playername = playername;
411         current_password   = password;
412         current_address    = address;
413         current_port       = game_params.socket_port;
414
415         // If using simple singleplayer mode, override
416         if (simple_singleplayer_mode) {
417                 assert(skip_main_menu == false);
418                 current_playername = "singleplayer";
419                 current_password = "";
420                 current_address = "";
421                 current_port = myrand_range(49152, 65535);
422         } else if (address != "") {
423                 ServerListSpec server;
424                 server["name"] = menudata.servername;
425                 server["address"] = menudata.address;
426                 server["port"] = menudata.port;
427                 server["description"] = menudata.serverdescription;
428                 ServerList::insert(server);
429         }
430
431         infostream << "Selected world: " << worldspec.name
432                    << " [" << worldspec.path << "]" << std::endl;
433
434         if (current_address == "") { // If local game
435                 if (worldspec.path == "") {
436                         error_message = gettext("No world selected and no address "
437                                         "provided. Nothing to do.");
438                         errorstream << error_message << std::endl;
439                         return false;
440                 }
441
442                 if (!fs::PathExists(worldspec.path)) {
443                         error_message = gettext("Provided world path doesn't exist: ")
444                                         + worldspec.path;
445                         errorstream << error_message << std::endl;
446                         return false;
447                 }
448
449                 // Load gamespec for required game
450                 gamespec = findWorldSubgame(worldspec.path);
451                 if (!gamespec.isValid() && !game_params.game_spec.isValid()) {
452                         error_message = gettext("Could not find or load game \"")
453                                         + worldspec.gameid + "\"";
454                         errorstream << error_message << std::endl;
455                         return false;
456                 }
457
458                 if (porting::signal_handler_killstatus())
459                         return true;
460
461                 if (game_params.game_spec.isValid() &&
462                                 game_params.game_spec.id != worldspec.gameid) {
463                         warningstream << "Overriding gamespec from \""
464                                     << worldspec.gameid << "\" to \""
465                                     << game_params.game_spec.id << "\"" << std::endl;
466                         gamespec = game_params.game_spec;
467                 }
468
469                 if (!gamespec.isValid()) {
470                         error_message = gettext("Invalid gamespec.");
471                         error_message += " (world.gameid=" + worldspec.gameid + ")";
472                         errorstream << error_message << std::endl;
473                         return false;
474                 }
475         }
476
477         return true;
478 }
479
480 void ClientLauncher::main_menu(MainMenuData *menudata)
481 {
482         bool *kill = porting::signal_handler_killstatus();
483         video::IVideoDriver *driver = device->getVideoDriver();
484
485         infostream << "Waiting for other menus" << std::endl;
486         while (device->run() && *kill == false) {
487                 if (noMenuActive())
488                         break;
489                 driver->beginScene(true, true, video::SColor(255, 128, 128, 128));
490                 guienv->drawAll();
491                 driver->endScene();
492                 // On some computers framerate doesn't seem to be automatically limited
493                 sleep_ms(25);
494         }
495         infostream << "Waited for other menus" << std::endl;
496
497         // Cursor can be non-visible when coming from the game
498 #ifndef ANDROID
499         device->getCursorControl()->setVisible(true);
500 #endif
501
502         /* show main menu */
503         GUIEngine mymenu(device, &input->joystick, guiroot,
504                 &g_menumgr, smgr, menudata, *kill);
505
506         smgr->clear();  /* leave scene manager in a clean state */
507 }
508
509 bool ClientLauncher::create_engine_device()
510 {
511         // Resolution selection
512         bool fullscreen = g_settings->getBool("fullscreen");
513         u16 screenW = g_settings->getU16("screenW");
514         u16 screenH = g_settings->getU16("screenH");
515
516         // bpp, fsaa, vsync
517         bool vsync = g_settings->getBool("vsync");
518         u16 bits = g_settings->getU16("fullscreen_bpp");
519         u16 fsaa = g_settings->getU16("fsaa");
520
521         // stereo buffer required for pageflip stereo
522         bool stereo_buffer = g_settings->get("3d_mode") == "pageflip";
523
524         // Determine driver
525         video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
526         std::string driverstring = g_settings->get("video_driver");
527         std::vector<video::E_DRIVER_TYPE> drivers
528                 = porting::getSupportedVideoDrivers();
529         u32 i;
530         for (i = 0; i != drivers.size(); i++) {
531                 if (!strcasecmp(driverstring.c_str(),
532                         porting::getVideoDriverName(drivers[i]))) {
533                         driverType = drivers[i];
534                         break;
535                 }
536         }
537         if (i == drivers.size()) {
538                 errorstream << "Invalid video_driver specified; "
539                         "defaulting to opengl" << std::endl;
540         }
541
542         SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
543         params.DriverType    = driverType;
544         params.WindowSize    = core::dimension2d<u32>(screenW, screenH);
545         params.Bits          = bits;
546         params.AntiAlias     = fsaa;
547         params.Fullscreen    = fullscreen;
548         params.Stencilbuffer = false;
549         params.Stereobuffer  = stereo_buffer;
550         params.Vsync         = vsync;
551         params.EventReceiver = receiver;
552         params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
553         params.ZBufferBits   = 24;
554 #ifdef __ANDROID__
555         params.PrivateData = porting::app_global;
556         params.OGLES2ShaderPath = std::string(porting::path_user + DIR_DELIM +
557                         "media" + DIR_DELIM + "Shaders" + DIR_DELIM).c_str();
558 #endif
559
560         device = createDeviceEx(params);
561
562         if (device) {
563                 if (g_settings->getBool("enable_joysticks")) {
564                         irr::core::array<irr::SJoystickInfo> infos;
565                         std::vector<irr::SJoystickInfo> joystick_infos;
566                         // Make sure this is called maximum once per
567                         // irrlicht device, otherwise it will give you
568                         // multiple events for the same joystick.
569                         if (device->activateJoysticks(infos)) {
570                                 infostream << "Joystick support enabled" << std::endl;
571                                 joystick_infos.reserve(infos.size());
572                                 for (u32 i = 0; i < infos.size(); i++) {
573                                         joystick_infos.push_back(infos[i]);
574                                 }
575                         } else {
576                                 errorstream << "Could not activate joystick support." << std::endl;
577                         }
578                 }
579                 porting::initIrrlicht(device);
580         }
581
582         return device != NULL;
583 }
584
585 void ClientLauncher::speed_tests()
586 {
587         // volatile to avoid some potential compiler optimisations
588         volatile static s16 temp16;
589         volatile static f32 tempf;
590         static v3f tempv3f1;
591         static v3f tempv3f2;
592         static std::string tempstring;
593         static std::string tempstring2;
594
595         tempv3f1 = v3f();
596         tempv3f2 = v3f();
597         tempstring = std::string();
598         tempstring2 = std::string();
599
600         {
601                 infostream << "The following test should take around 20ms." << std::endl;
602                 TimeTaker timer("Testing std::string speed");
603                 const u32 jj = 10000;
604                 for (u32 j = 0; j < jj; j++) {
605                         tempstring = "";
606                         tempstring2 = "";
607                         const u32 ii = 10;
608                         for (u32 i = 0; i < ii; i++) {
609                                 tempstring2 += "asd";
610                         }
611                         for (u32 i = 0; i < ii+1; i++) {
612                                 tempstring += "asd";
613                                 if (tempstring == tempstring2)
614                                         break;
615                         }
616                 }
617         }
618
619         infostream << "All of the following tests should take around 100ms each."
620                    << std::endl;
621
622         {
623                 TimeTaker timer("Testing floating-point conversion speed");
624                 tempf = 0.001;
625                 for (u32 i = 0; i < 4000000; i++) {
626                         temp16 += tempf;
627                         tempf += 0.001;
628                 }
629         }
630
631         {
632                 TimeTaker timer("Testing floating-point vector speed");
633
634                 tempv3f1 = v3f(1, 2, 3);
635                 tempv3f2 = v3f(4, 5, 6);
636                 for (u32 i = 0; i < 10000000; i++) {
637                         tempf += tempv3f1.dotProduct(tempv3f2);
638                         tempv3f2 += v3f(7, 8, 9);
639                 }
640         }
641
642         {
643                 TimeTaker timer("Testing std::map speed");
644
645                 std::map<v2s16, f32> map1;
646                 tempf = -324;
647                 const s16 ii = 300;
648                 for (s16 y = 0; y < ii; y++) {
649                         for (s16 x = 0; x < ii; x++) {
650                                 map1[v2s16(x, y)] =  tempf;
651                                 tempf += 1;
652                         }
653                 }
654                 for (s16 y = ii - 1; y >= 0; y--) {
655                         for (s16 x = 0; x < ii; x++) {
656                                 tempf = map1[v2s16(x, y)];
657                         }
658                 }
659         }
660
661         {
662                 infostream << "Around 5000/ms should do well here." << std::endl;
663                 TimeTaker timer("Testing mutex speed");
664
665                 Mutex m;
666                 u32 n = 0;
667                 u32 i = 0;
668                 do {
669                         n += 10000;
670                         for (; i < n; i++) {
671                                 m.lock();
672                                 m.unlock();
673                         }
674                 }
675                 // Do at least 10ms
676                 while(timer.getTimerTime() < 10);
677
678                 u32 dtime = timer.stop();
679                 u32 per_ms = n / dtime;
680                 infostream << "Done. " << dtime << "ms, " << per_ms << "/ms" << std::endl;
681         }
682 }
683
684 bool ClientLauncher::print_video_modes()
685 {
686         IrrlichtDevice *nulldevice;
687
688         bool vsync = g_settings->getBool("vsync");
689         u16 fsaa = g_settings->getU16("fsaa");
690         MyEventReceiver* receiver = new MyEventReceiver();
691
692         SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
693         params.DriverType    = video::EDT_NULL;
694         params.WindowSize    = core::dimension2d<u32>(640, 480);
695         params.Bits          = 24;
696         params.AntiAlias     = fsaa;
697         params.Fullscreen    = false;
698         params.Stencilbuffer = false;
699         params.Vsync         = vsync;
700         params.EventReceiver = receiver;
701         params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
702
703         nulldevice = createDeviceEx(params);
704
705         if (nulldevice == NULL) {
706                 delete receiver;
707                 return false;
708         }
709
710         std::cout << _("Available video modes (WxHxD):") << std::endl;
711
712         video::IVideoModeList *videomode_list = nulldevice->getVideoModeList();
713
714         if (videomode_list != NULL) {
715                 s32 videomode_count = videomode_list->getVideoModeCount();
716                 core::dimension2d<u32> videomode_res;
717                 s32 videomode_depth;
718                 for (s32 i = 0; i < videomode_count; ++i) {
719                         videomode_res = videomode_list->getVideoModeResolution(i);
720                         videomode_depth = videomode_list->getVideoModeDepth(i);
721                         std::cout << videomode_res.Width << "x" << videomode_res.Height
722                                 << "x" << videomode_depth << std::endl;
723                 }
724
725                 std::cout << _("Active video mode (WxHxD):") << std::endl;
726                 videomode_res = videomode_list->getDesktopResolution();
727                 videomode_depth = videomode_list->getDesktopDepth();
728                 std::cout << videomode_res.Width << "x" << videomode_res.Height
729                         << "x" << videomode_depth << std::endl;
730
731         }
732
733         nulldevice->drop();
734         delete receiver;
735
736         return videomode_list != NULL;
737 }