According to the game maker documentation for dll manipulation:


Returns the address of a GameMaker function. This can be passed to DLL's so the can call directly into GameMaker.

This feature is unsuported, so care must be taken when using this function.

Please Note: These functions use Delphi 2010 PASCAL calling convention and string formats.

Let's assume one writes a C++ dll and wants to use those function pointers to make game maker function calls within the dll code.

What does one cast the function pointer to? I am familiar with passing a C function pointer to a C++ dll (it is blatantly obvious what you cast the pointer to; the same thing as what you would within the C code). However, I do not know what I would cast functions to coming from game maker. I imagine it is a relatively "simple" thing to do once you know the magic dance. It just doesn't say anywhere what to do.

I think the page might be trying to tell me that this is equivalent to passing a pascal function pointer to a C++ dll. I don't really know. I can't be the only guy with this problem.


1 Answer 1


This answer can either be incredibly simple or incredibly complicated. First let’s get something out of the way. That document is for game maker 8.1 not 8.0. This in turn means you cannot use that function as it doesn’t exist for 8.0.

However this does not mean you cannot call game maker functions within the dll. Consider the example function game_maker_function_a(x,y,z). It takes in three values and does stuff. For the purposes of this explanation the behavior of the function is irrelevant. It has a return value. We will get to that.

Every game maker function has at most 14 arguments. They either take in a double or a char*. Therefore any function can can be represented via a structure. We can do this in C++ easily. Then using any method one sees fit one can make a list to hold function call representations. Then in game maker one would access this list and get the data contained in that function call.

The only minor annoyance in calling game_maker_function_a in this manner is to call function pointers in game maker. This can be done with a script ID and execute_script. This requires one to make a wrapper script for the game maker function.

Finally the function call struct can hold a pointer to the location of the variable that will hold the return value.

Pros: You can call game maker functions in a dll.

Cons: Technically you are only queueing up function calls which will have to be executed upon exiting the function.

This design should be future compatible with studio and beyond.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .