Elvas Tower: Open Rails MonoGame on Linux - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Open Rails MonoGame on Linux Rate Topic: -----

#1 User is offline   dajones 

  • Open Rails Developer
  • Group: Status: Contributing Member
  • Posts: 413
  • Joined: 27-February 08
  • Gender:Male
  • Location:Durango, CO
  • Country:

Posted 29 May 2021 - 06:45 PM

I've recently been working on running the MonoGame version of OR on Linux (Ubuntu 20.04). I compiled a DesktopGL version on Linux using Microsoft's dotnet sdk, MonoGame 3.8 and .net core 3.1. I originally started with perpetualKid's ORTS-MG github version, since it already uses MonoGame 3.8, .net core 3.1 and compiled shaders. Later I converted the official test version to DesktopGL. The result mostly works, but there are a number of issues.

To build a DesktopGL version on Linux I had to remove all references to Windows Forms and Fonts. I also had to disable everything that uses Windows DLLs. So, I was only able to build RunActivity and only with some debugging forms removed. I had to add a sprite font and change all the text displays to use it. I also added some code to read user settings from a json file and a hard coded table to map virtual keys to scan codes. Currently, I can only run RunActivity from the command line. Most features work, but shadows, smoke and precipitation currently don't and I'm not sure why.

But the biggest problem is that the OR threading model doesn't work well with OpenGL MonoGame. MonoGame forces some OpenGL calls to be run by the render thread. Some just throw exceptions if the thread is wrong and others (like VertexBuffer.SetData) get queued and the thread blocks until the render thread gets to it. This causes loading to be very slow and can cause things to hang if threads wait for each other. I had to rework the code so the render thread does most of the initial loading. Once the sim. starts the regular loading thread is used. The result is okay unless you run high speed trains.

Given all these issues, I decided try using wine to run the Windows MG version. After creating a wine prefix with the appropriate dependencies, the test version would run but it immediately throws an exception when trying to compile a shader. I also tried the test version using the wine prefix that I use for compiling shaders using mgfxc, but that didn't work either. The Ultimate1.3.1-144 version throws a similar exception, but the Ultimate-1.3.1-572 version (which uses precompiled shaders) works. I tried adding the window's version of .net core 3.1 to my wine prefix, but I couldn't get any of the Ultimate versions that use it to run. I suspect that the test version would work under wine if it used precompiled shaders, but I can't build the windows version so I can't test that.

Doug

#2 User is offline   perpetualKid 

  • Fireman
  • Group: Status: Active Member
  • Posts: 190
  • Joined: 10-June 18
  • Gender:Male
  • Simulator:OR
  • Country:

Posted 29 May 2021 - 09:43 PM

 dajones, on 29 May 2021 - 06:45 PM, said:

I've recently been working on running the MonoGame version of OR on Linux (Ubuntu 20.04). I compiled a DesktopGL version on Linux using Microsoft's dotnet sdk, MonoGame 3.8 and .net core 3.1. I originally started with perpetualKid's ORTS-MG github version, since it already uses MonoGame 3.8, .net core 3.1 and compiled shaders. Later I converted the official test version to DesktopGL. The result mostly works, but there are a number of issues.

...

Given all these issues, I decided try using wine to run the Windows MG version. After creating a wine prefix with the appropriate dependencies, the test version would run but it immediately throws an exception when trying to compile a shader. I also tried the test version using the wine prefix that I use for compiling shaders using mgfxc, but that didn't work either. The Ultimate1.3.1-144 version throws a similar exception, but the Ultimate-1.3.1-572 version (which uses precompiled shaders) works. I tried adding the window's version of .net core 3.1 to my wine prefix, but I couldn't get any of the Ultimate versions that use it to run. I suspect that the test version would work under wine if it used precompiled shaders, but I can't build the windows version so I can't test that.

Doug



there are some folks using the Ultimate version successfully under Linux using Wine for a while already, and there is some documentation here Linux Wine · perpetualKid/ORTS-MG Wiki (github.com) . There was some error with .NET Core and WIne related to Wine prefix, see here .NET Core versions · Discussion #85 · perpetualKid/ORTS-MG (github.com). More generally I'd also recommend upgrading to a more recent version than 1.3.1-*

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users