- Joined
- Feb 2, 2012
- Messages
- 1,667
- Reaction score
- 104
- Points
- 78
Hi guys,
I'm facing a difficult issue that I can't find a way to solve.
In the Orbiter APIs there are some defined function pointers as clbks that can be used. The first one I'm using is the LoadMeshClbkFunc used by oapiLoadMeshGlobal which is defined like this in OrbiterAPI.h
if I then define a GLOBAL function like
and then I call it when I load the mesh with
it works... BUT
That is a GLOBAL function that means that I cannot pass vessel specific parameters to it. for example I can't get it to do different things if D3D9 is active or not because it does not get the class variables that defines it.
Now, I'm finding some workarounds but they are not very clean, and I will face this issue some other times during development. I would need to make oapiLoadMeshGlobal to accept MyLoadMeshClbk as a class function and not a global function, but if I define it in my class the oapiLoadMeshGlobal throws an error and does not compile because types are different etc etc
If I use a global pointer to my vessel it then means that if I have multiple vessel instances in the scenario things gets messed up quickly.
So, does anyone know how to make the global clbk function somehow accepted even if it's a local class one?
Or to pass the right pointer to the clbk so i will have the right results, it doesn't make much difference
I hope I was clear enogh, thanks in advance!
I'm facing a difficult issue that I can't find a way to solve.
In the Orbiter APIs there are some defined function pointers as clbks that can be used. The first one I'm using is the LoadMeshClbkFunc used by oapiLoadMeshGlobal which is defined like this in OrbiterAPI.h
Code:
typedef void (*LoadMeshClbkFunc)(MESHHANDLE hMesh, bool firstload);
if I then define a GLOBAL function like
Code:
void MyLoadMeshClbk(MESHHANDLE hMesh,bool firstload){
//do something
return;
and then I call it when I load the mesh with
Code:
oapiLoadMeshGlobal("meshname",MyLoadMeshClbk);
it works... BUT
That is a GLOBAL function that means that I cannot pass vessel specific parameters to it. for example I can't get it to do different things if D3D9 is active or not because it does not get the class variables that defines it.
Now, I'm finding some workarounds but they are not very clean, and I will face this issue some other times during development. I would need to make oapiLoadMeshGlobal to accept MyLoadMeshClbk as a class function and not a global function, but if I define it in my class the oapiLoadMeshGlobal throws an error and does not compile because types are different etc etc
If I use a global pointer to my vessel it then means that if I have multiple vessel instances in the scenario things gets messed up quickly.
So, does anyone know how to make the global clbk function somehow accepted even if it's a local class one?
Or to pass the right pointer to the clbk so i will have the right results, it doesn't make much difference
I hope I was clear enogh, thanks in advance!
Last edited: