nbcfrosty
Well-known member
Hey all. I created a C wrapper for a substantial portion of the Orbiter API. Currently all the oapi calls and the VESSEL calls are covered. Included is an
All this so we can build with mingw32 like this:
some example code:
Orbiter loads the
I am a C/C++ noob, so looking for feedback if this is even a good idea. I'd imagine now that Orbiter is open source one can probably recompile the orbitersdk libs for mingw, but that seems like a much harder thing to do.
edit:
I am using mingw32 downloaded from here:
winlibs-i686-posix-dwarf-gcc-14.1.0-llvm-18.1.5-mingw-w64ucrt-11.0.1-r1.7z
oapi.dll that wraps the Orbiter API, and a header-only oapi_mingw.h library that does the dynamic linking.All this so we can build with mingw32 like this:
Code:
g++ -shared -o mingw-plugin.dll main.cpp -I"..\..\..\include"
some example code:
Code:
#define STRICT
#define ORBITER_MODULE
#include "../oapi_mingw.h"
bool init = false;
OrbiterAPIWrapper* orbiterAPI = nullptr;
DLLCLBK void opcPreStep(double simt, double simdt, double mjd)
{
if (!init)
{
init = true;
orbiterAPI = new OrbiterAPIWrapper();
}
if (orbiterAPI->ready)
{
auto v = orbiterAPI->oapiGetFocusInterface();
sprintf(orbiterAPI->oapiDebugString(), "hello from mingwwwwww %.2f!!! %d %s", simt, orbiterAPI->oapiGetVesselCount(), orbiterAPI->GetName(v));
if (simt > 5) {
orbiterAPI->SetThrusterGroupLevel_type(v, THGROUP_MAIN, 1);
}
}
}
DLLCLBK void ExitModule(HINSTANCE hDLL)
{
if (orbiterAPI)
{
delete orbiterAPI;
orbiterAPI = nullptr;
}
init = false;
}
Orbiter loads the
g++ produced dlls perfectly fine.I am a C/C++ noob, so looking for feedback if this is even a good idea. I'd imagine now that Orbiter is open source one can probably recompile the orbitersdk libs for mingw, but that seems like a much harder thing to do.
edit:
I am using mingw32 downloaded from here:
WinLibs - GCC+MinGW-w64 compiler for Windows
WinLibs - MinGW-w64 personal build = GCC for Windows 32-bit and 64-bit - Coming soon: the largest collection of open source libraries ported to Windows using MinGW-w64 and MSYS2.
winlibs.com
winlibs-i686-posix-dwarf-gcc-14.1.0-llvm-18.1.5-mingw-w64ucrt-11.0.1-r1.7z
Attachments
Last edited: