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