GdiplusAircraft
The GdiplusAircraft
aircraft is a module of the WASMAircraft modular aircraft, illustrates how to create C++ gauges for a plane in Microsoft Flight Simulator 2024 using the GDI+ static library. It provides an alternative implementation to the gauges present in the GaugeAircraft module, using the advanced functionality of GDI+. Once the WASM Aircraft package has been built, this module will be available for flying from the aircraft selection screen:
The GdiPlusWasmModule.sln
file will allow you to compile the code with Microsoft Visual Studio (2019 or 2022) in order to create the GdiPlusWasmModule.wasm
WebAssembly module which will then be loaded by the game. Once compiled, the module will automatically be copied into the following folder
..\PackageSources\SimObjects\Airplanes\MyCompany_Wasm_Aircraft\presets\mycompany\GdiPlusAircraft\panel
In order for the aircraft to use the gauges defined in the module, they have to be declared in the panel.cfg
file found in the same folder:
[VCockpit01]
size_mm=1024,768
pixel_size=1024,768
texture=$SCREEN_1
background_color=0,0,255
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=GdiPlusWasmModule.wasm&wasm_gauge=Compass, 0,0,1024,768
[VCockpit02]
size_mm=1024,768
pixel_size=1024,768
texture=$SCREEN_2
background_color=0,255,0
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=GdiPlusWasmModule.wasm&wasm_gauge=Attitude, 0,0,1024,768
[Vcockpit03]
size_mm=1024,768
pixel_size=1024,768
texture=$SCREEN_3
background_color=255,0,0
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=GdiPlusWasmModule.wasm&wasm_gauge=Bitmap, 0,0,1024,768
As can be seen above, the gauges are referenced using the following URI scheme:
htmlgaugeNN=WasmInstrument/WasmInstrument.html?wasm_module=[MODULE].wasm&wasm_gauge=[GAUGE_NAME],[X],[Y],[WIDTH],[HEIGHT]
Note that if you make changes to the C++ code and recompile the GDI+ module, you will have to build your package again. This can be done while the plane is used within the simulation.
Gauge Files
The following files are used for the gauges in this example:
Attitude.cpp
: provides a re-implementation ofGaugeAircraft
Attitude gauge, using polygons.
Compass.cpp
: provides a re-implementation ofGaugeAircraft
Compass gauge, using using Path clipping.
Bitmap.cpp
: provides a sample of how to load, create and display images.