godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Add ability to load DLL modules without using GDNative/GDExtension #1917

Open RevoluPowered opened 4 years ago

RevoluPowered commented 4 years ago

Describe the project you are working on

A game I want to publish on steam

Describe the problem or limitation you are having in your project

We can't integrate the SteamSDK with a little amount of tool setup.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Why:

Directory structure:

Packaging:

Loading modules

Implement DLL API for standard SDK files like SourceSDK.dll

https://docs.google.com/document/d/1-bxJ0CZb6_Ceuv-SmGCO4YV-lse8NjmRQWvGFlDvL6Y/

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

var module = load_module("SteamAPI")
func authentication_response(user_data : UserStruct, status : String):
    print(“User has authenticated “ + user_data.name)

)
var authenticate = module.bind(“authenticate_steam”, authentication_response)

Please see this document for the below points: https://docs.google.com/document/d/1-bxJ0CZb6_Ceuv-SmGCO4YV-lse8NjmRQWvGFlDvL6Y

If this enhancement will not be used often, can it be worked around with a few lines of script?

no

Is there a reason why this should be core and not an add-on in the asset library?

it is core

YuriSizov commented 4 years ago

First questions that pops to my mind: how should GDScript handle native types without any translation layer that is created manually when you wrap 3rd party libraries into modules/gdnative classes?

RevoluPowered commented 4 years ago

We'd most likely use something like this as a good template for the implementation:

handles all the potential cases for binding c structs correctly, which at first would be good enough to me.

There is the pinvoke method too from csharp but we probably wouldn't use it as a template, the ctypes system is so similar to gdscript it could be used as a template, and we could make further simplifications, if we don't need all the bells and whistles it has.

RevoluPowered commented 4 years ago

Another option is using an FFI (this has less performance issues with JIT compilation, should GDScript add it later) https://luajit.org/ext_ffi.html

They're always faster than using c functions from a jit compiled language. (since standard c calls to c functions are always slower when you have JIT compilation, as it interrupts the jit compilation. which was a constant source of frustration with garrysmod for example because the jit compilation would die every time you called back into the C++ code the FFI prevents this slowdown if memory serves me correctly.

Ideally we start small though, with something very simple and work from there.

Xrayez commented 3 years ago

Related to #830.

CsloudX commented 2 years ago

I'm often make NO-GAME app, so many 3rd party provide such DLL, if GDScript can implement this feature, I don't need Visual Studio or GCC anymore.

CsloudX commented 2 years ago

I prefer can write codes like this:

var dll = load_dll("res://dll/a.dll") # any valid path
var rs = dll.call("add", 10, 20) # in DLL, method was  int add(int a, int b)
CsloudX commented 2 years ago

I also wish Godot can find dll in system path so I can call win32 api:

var dll = dll_load("user32.dll")
var hwnd = dll.call("FindWindowEx",null,null,null,"notepad")
dll.call("SendMessage",hwnd, 12054,0,0)
Code-Horror commented 1 year ago

I'm often make NO-GAME app, so many 3rd party provide such DLL, if GDScript can implement this feature, I don't need Visual Studio or GCC anymore.

Same! Being able to load DLL's in this way will open a lot of creative possibilities that are not limited to standard game experiences.

Calinou commented 1 year ago

@Code-Horror Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

Code-Horror commented 1 year ago

No. I will use Github how I wish. Don't try to tell people how to use the Internet.

Zireael07 commented 1 year ago

@Code-Horror this sort of behavior is directly against the code of conduct in this repo (As well as common courtesy)

Code-Horror commented 1 year ago

As I repeat, I will use Github how I wish. My comment broke no rules of Github, you're just being power hungry.

AThousandShips commented 1 year ago

Likewise, any spamming, trolling, flaming, baiting, or other attention-stealing behavior is not welcome and will result in exclusion from the community.

For certainty, any conduct which could reasonably be considered inappropriate in a professional setting is not acceptable.

You may use it as you wish, but you must be ready to be banned for violating the rules, just behave reasonably and maturely, it's not a high bar, this kind of "you're not the boss of me" behaviour is ridiculous, you were kindly asked to behave properly, and your response is inappropriate


Then have fun being banned 👋🏻

You have to follow our rules as well as those of GitHub

I'm leaving to not fire any more notifications

Code-Horror commented 1 year ago

Likewise, any spamming, trolling, flaming, baiting, or other attention-stealing behavior is not welcome and will result in exclusion from the community.

For certainty, any conduct which could reasonably be considered inappropriate in a professional setting is not acceptable.

You may use it as you wish, but you must be ready to be banned for violating the rules, just behave reasonably and maturely, it's not a high bar, this kind of "you're not the boss of me" behaviour is ridiculous

I broke no rules here on Github. My comment was perfectly valid and legitimate. And I will repeat for the 3rd time, I will continue to use Github in alignment with their policies as I have done.

Code-Horror commented 1 year ago

Then have fun being banned 👋🏻

Could you tell me which one of GitHub's policies I have broken when I made my original comment?

Same! Being able to load DLL's in this way will open a lot of creative possibilities that are not limited to standard game experiences.

It brought light to issue. I have dedicated some of my own time to working on solving this issue as it would be a helpful feature for myself and others.

Now please leave me in peace.

akien-mga commented 1 year ago

@Code-Horror You've been asked politely to follow a policy of the Godot project. Godot is a project hosted on GitHub, and while you have to follow GitHub's policies, you also have to follow Godot's when interacting with @godotengine repositories, notably the Code of Conduct.

If you believe that you're entitled to behave in any way as long as you don't breach the GitHub Terms of Service, then you might indeed be shown the door of the @godotengine organization.