Yeah, I was sparing with hints. Let me be more specific about what I have in mind with my pragmatic approach: I want to use just a few Steam features in my game (Steam achievements for example) without translating the whole API. I don't want to install a C environment (Visual Studio e.g.) for this limited purpose. And I want to avoid an additional custom DLL (which requires maintenance).
Thanks for linking the steam_api_flat.h! Nice transition
So, these are the first 10 lines (of nearly 700) of function declarations in steam_api_flat.h:
Code:
S_API HSteamPipe SteamAPI_ISteamClient_CreateSteamPipe(intptr_t instancePtr);
S_API bool SteamAPI_ISteamClient_BReleaseSteamPipe(intptr_t instancePtr, HSteamPipe hSteamPipe);
S_API HSteamUser SteamAPI_ISteamClient_ConnectToGlobalUser(intptr_t instancePtr, HSteamPipe hSteamPipe);
S_API HSteamUser SteamAPI_ISteamClient_CreateLocalUser(intptr_t instancePtr, HSteamPipe * phSteamPipe, EAccountType eAccountType);
S_API void SteamAPI_ISteamClient_ReleaseUser(intptr_t instancePtr, HSteamPipe hSteamPipe, HSteamUser hUser);
S_API class ISteamUser * SteamAPI_ISteamClient_GetISteamUser(intptr_t instancePtr, HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char * pchVersion);
S_API class ISteamGameServer * SteamAPI_ISteamClient_GetISteamGameServer(intptr_t instancePtr, HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char * pchVersion);
S_API void SteamAPI_ISteamClient_SetLocalIPBinding(intptr_t instancePtr, uint32 unIP, uint16 usPort);
S_API class ISteamFriends * SteamAPI_ISteamClient_GetISteamFriends(intptr_t instancePtr, HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char * pchVersion);
S_API class ISteamUtils * SteamAPI_ISteamClient_GetISteamUtils(intptr_t instancePtr, HSteamPipe hSteamPipe, const char * pchVersion);
...
"Flat" C-style means to me that some C++ classes reveal their public methods.
The first function is SteamAPI_ISteamClient_CreateSteamPipe. I take this as: within the SteamAPI there is a Steam class ISteamClient which has a method CreateSteamPipe().
In C++ one would call it like this: ISteamClient->CreateSteamPipe(). Or in Object Pascal: ISteamClient.CreateSteamPipe().
The return value HSteamPipe seems to be a handle. That's longint to me.
That instancePtr is puzzling for now. Just pointer.
According to my code above I would declare:
Code:
var
steamapi_isteamclient_createsteampipe: function(instanceptr: pointer): longint; cdecl = nil;
steampipe_handle: longint;
And in the above function steam_init I would add:
Code:
pointer(steamapi_isteamclient_createsteampipe) := getprocedureaddress(steamlib_handle, pchar('SteamAPI_ISteamClient_CreateSteamPipe'));
Now if you call it like that ...
Code:
steampipe_handle := steamapi_isteamclient_createsteampipe(nil);
... you get Access Violation, which comes as no surprise.
Let me reveal for now, that Nil has to be replaced by a meaningful value, namely a pointer to ISteamClient, which is the Interface of the Steam Client.
To be continued.
Bookmarks