VMWare: Virtual machine with Linux

From The DarkMod Wiki
Revision as of 15:17, 28 January 2019 by Stgatilov (talk | contribs) (Initial version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This guide is originally written for TDM 2.07.

Intro

It is very convenient for a Windows-centric developer to have a Linux virtual machine in his arcenal.

You can read how to set up VirtualBox VM in the article VirtualBox: Virtual machine with Linux for TDM. This article is about setting up a VMware VM, which has some benefits over VirtualBox: better performance and OpenGL support.

Install VMware

While Oracle's VirtualBox is open-source, the VMware product is proprietary in its full sense. As of year 2019, there is VMware Workstation Player, which is free for non-commercial use. You can download it on this page (choose Windows version).

Installation is trivial. Most likely, you do not need the "Enhanced Keyboard Driver".

Create VM

Start VMware Workstation, click on "Create a New Virtual Machine".

Point "Installer disc image file" to the ISO image of the Linux distro which you want to install (by default it would be Ubuntu LTS). Click Next.

Choose a name like "Ubuntu XX.YY x64", set user and password, click Next. Don't forget to set Location: a typical VM takes 5-10 GB. Leave Disk Capacity settings in defaults: do not use monolithic disk, because it would make some configuring much harder!

As long as you choose reasonable settings and ISO, you should be eligible for "Easy Install", which means that you'll get Ubuntu installed for you automatically, along with open-vm-tools. Make sure you have internet access through the whole process, otherwise your installation will be incomplete.

Client Tools

In order to use shared directories and shared clipboard, you need to install some sort of client tools. Unfortunately, this topic is quite messy in VMware world. First of all, there are two such tools available: VMware Tools is distributed with VMware Player, and open-vm-tools is intended to be distributed by Linux package manager. Second, default installations of the tools are often buggy and don't work.

In my case, open-vm-tools 2:10.2.0-3~ubuntu0.16.04.1 was installed automatically by VMware Player 15.0.2 during Easy Install procedure and it did not work well. It mounted the shared folder properly when I added it, but after a full reboot the shared folder was absent. Installing the patches from this answer helped. Of course, you need to do "sudo apt-get install git" first.

In order to create shared folder, open "Virtual Machine Settings" (in "Player" -> "Manage"). Go to "Options" -> "Shared Folders", and set it to "Always enabled". Now "Add" your TDM root directory to make it accessible from within VM. Check that it is available at /mnt/hgfs/[name_of_share]. If it is not there, then I wish you good luck!

Configure VM

When your VM is not running, right-click on VM and go to "Settings".

Choose "Memory", and increase the amount of Memory available to 4096 MB.

Choose "Processors", and increase "Number of processor cores" to make TDM build faster. I advise setting it to the number of physical cores you have (6 for me).

Choose "Display", increase "Graphics memory" to 2 GB.

Click OK to apply changes.

Clean backup

I prefer having the clean VM backed up so that I could restart with a fresh and configured VM at any moment. VMware Player does not support cloning and snapshots, but you can find the directory with your VM data and simply copy the whole directory.

Build and run TDM

Open terminal, change dir to the root source code directory in the shared folder, e.g.:

cd /mnt/hgfs/thedarkmod/darkmod_src

From here you can build TDM in the usual way, as described in the The Dark Mod - Compilation Guide#Linux. Of course, you have to install some packages before first build.

In order to run TDM, go to assets root directory, e.g.:

cd /mnt/hgfs/thedarkmod/darkmod

Run TDM from there:

./thedarkmod.x64

For TDM 2.07, you also have to do "sudo apt-get install libopenal1" beforehand.

Currently VMware seems to support OpenGL 3.0 in general and OpenGL 3.3 Core profile only.

Mouse look

VMware breaks mouse cursor warping in the same way as VirtualBox does. Warping is critical for mouse-look in FPS games, including TDM. Without it, you won't be able even to navigate through menus.

There are two ways to fix it in case of VMware Player:

VMware-side solution. Make sure the VM is shutdown, open the .vmx-file of your VM and add the following magic lines to it:

usb.generic.allowHID = "TRUE"
mouse.vusb.useBasicMouse = "FALSE"
mouse.vusb.enable = "TRUE"

Strangely, this is already enough to fix the problem. If your mouse is crazy in TDM, press Ctrl+Alt and click back to VM, and mouse look should return to normal.

Also with these lines, you can passthrough your mouse and keyboard exclusively to VM. In order to do that, click "Player" -> "Removable Devices", find your mouse/keyboard there and click "Connect". Make sure that you have spare USB mouse or keyboard connected to computer so that at least some control is left on the host side.

TDM-side hack. Open game console and set "in_nowarp 1" there. After that you have a limited mouse-look. You cannot really play with it, but it is enough for clicking through menu and a bit of in-game testing. Use "turn left/right" keys as additional workaround.