Hello,
The past couple days I've been trying to make an effort to create gauges for Prepar3D V3 using Dai Griffith's latest sd2gau38 documentation and samples but I've been reluctant to post a help thread.
After a couple attempts, I got the gauge project to compile, with identical Visual Studio settings as the examples within the pdf that are provided; however the gauges will not load into P3D and I cannot find a reasonable explanation, or any good ways to go about debugging.
For my first gauge, I kept it simple. One master gauge class and a singular subgauge just for testing purposes.
The goal was to create a simple fuel gauge and work my way from there, but that task has proven itself more confusing than expected.
simgauges.cpp (master)
simgauges.h
fuelgauge.c
resources.rc
That's it for the gauge project code. Here's the section in my panel.cfg that includes the gauge:
I've titled all of the exported files accordingly for the panel configuration as well
-TestGauges.dll, TestGauges.exp, TestGauges.lib
These three files are located in the Prepar3d V3/gauges/ folder.
If there's something I might have missed or completely looked over, please feel free to let me know. I'm happy to provide as much additional information as needed.
The past couple days I've been trying to make an effort to create gauges for Prepar3D V3 using Dai Griffith's latest sd2gau38 documentation and samples but I've been reluctant to post a help thread.
After a couple attempts, I got the gauge project to compile, with identical Visual Studio settings as the examples within the pdf that are provided; however the gauges will not load into P3D and I cannot find a reasonable explanation, or any good ways to go about debugging.
For my first gauge, I kept it simple. One master gauge class and a singular subgauge just for testing purposes.
The goal was to create a simple fuel gauge and work my way from there, but that task has proven itself more confusing than expected.
simgauges.cpp (master)
C++:
#include "fsxgauges_sp2.h"
#include "simgauges.h"
#define GAUGE_NAME "fuelgauge\0"
#define GAUGEHDR_VAR_NAME fuelgaugehdr
#define GAUGE_W 200
#include "fuelgauge.c"
GAUGE_TABLE_BEGIN()
GAUGE_TABLE_ENTRY(&fuelgaugehdr)
GAUGE_TABLE_END()
simgauges.h
C++:
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_BUILD 0
#define lita(arg) #arg
#define xlita(arg) lita(arg)
#define cat3(w,x,z) w##.##x##.##z##\000
#define xcat3(w,x,z) cat3(w,x,z)
#define VERSION_STRING xlita(xcat3(VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD))
#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 0x0001
#endif
#define BMP_BACKGROUND 0x1000
#define BMP_NEEDLE 0x1003
fuelgauge.c
C:
char fuelgauge_name[] = GAUGE_NAME;
extern PELEMENT_HEADER fuel_list;
extern MOUSERECT fuel_mouse_rect[];
GAUGE_HEADER_FS700(GAUGE_W, fuelgauge_name, &fuel_list,
fuel_mouse_rect, 0, 0, 0, 0);
#define GAUGE_MIN 0
#define GAUGE_MAX 26
NONLINEARITY fuel_nonlinearity[] =
{
{ { 96, 621 }, 0, 0 },
{ { 45, 513 }, 2, 0 },
{ { 29, 410 }, 4, 0 },
{ { 38, 315 }, 6, 0 },
{ { 73, 220 }, 8, 0 },
{ { 129, 145 }, 10, 0 },
{ { 219, 75 }, 12, 0 },
{ { 342, 33 }, 14, 0 },
{ { 457, 31 }, 16, 0 },
{ { 594, 74 }, 18, 0 },
{ { 682, 150 }, 20, 0 },
{ { 741, 226 }, 22, 0 },
{ { 775, 326 }, 24, 0 },
{ { 781, 417 }, 26, 0 },
};
FAILURE_RECORD fuel_fail[] = {
{ FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO },
{ FAIL_GAUGE_FUEL_INDICATORS, FAIL_ACTION_FREEZE },
{ FAIL_NONE, FAIL_ACTION_NONE }
};
MODULE_VAR fuelLev = { FUEL_TANK_RIGHT_MAIN_LEVEL };
FLOAT64 FSAPI fuel_needle_cb(PELEMENT_NEEDLE pelement)
{
FLOAT64 val = pelement->source_var.var_value.n;
if (val > GAUGE_MAX)
val = GAUGE_MAX;
else if (val < GAUGE_MIN)
val = GAUGE_MIN;
return val;
}
MAKE_NEEDLE
(
fuel_needle,
BMP_NEEDLE,
NULL,
fuel_fail,
IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE | IMAGE_BILINEAR_COLOR,
0,
150, 150,
6, 12,
TOTAL_FUEL_QUANTITY_GALLONS, fuel_needle_cb,
fuel_nonlinearity,
6
)
PELEMENT_HEADER fuel_needle_list[] =
{
(PELEMENT_HEADER)&fuel_needle,
NULL
};
MAKE_STATIC
(
fuel_background,
BMP_BACKGROUND,
&fuel_needle_list,
fuel_fail,
IMAGE_USE_TRANSPARENCY,
0,
9, 0
)
PELEMENT_HEADER fuel_list = &fuel_background.header;
MOUSE_BEGIN(fuel_mouse_rect, HELPID_GAUGE_FUEL, 0, 0)
MOUSE_END
#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W
resources.rc
Code:
#include "simgauges.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x10004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Company name\0"
VALUE "FileDescription", "Prepar3d Gauges\0"
VALUE "FileVersion", VERSION_STRING
VALUE "LegalCopyright", "Copyright info\0"
VALUE "ProductName", "TestGauges\0"
VALUE "ProductVersion", VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
BMP_BACKGROUND BITMAP DISCARDABLE "images\\background.bmp"
BMP_NEEDLE BITMAP DISCARDABLE "images\\needle.bmp"
That's it for the gauge project code. Here's the section in my panel.cfg that includes the gauge:
Code:
[Window Titles]
Window07=Gauges Window
[Window07]
size_mm=400,400
gauge00=TestGauges!fuelgauge, 0, 0, 100, 100
I've titled all of the exported files accordingly for the panel configuration as well
-TestGauges.dll, TestGauges.exp, TestGauges.lib
These three files are located in the Prepar3d V3/gauges/ folder.
If there's something I might have missed or completely looked over, please feel free to let me know. I'm happy to provide as much additional information as needed.
Last edited:

