Creating NPAPI plugin in Delphi and accessing expo

2019-07-19 04:48发布

I have found a useful billards physics library in Borland delphi for my hobby project. The code is object oriented(in Object pascal). I want to visualize it using webGL (javascript) in chrome browser.

The idea is, I should have one call to make from the javascript which will access the interface from delphi lib and give me the new position, rotation and scale values in respective array.

For this I want to develop an NPAPI lib Scriptable plugin in Delphi(Meaning NO UI only lib of APIs).

1)I want to export those necessary physics APIs from the Delphi via this NPAPI plugin and access them in my html page using JavaScript. I am targeting chrome. 2) Any simple "hello world" tutorial or article related to this will be highly helpful.

3)Any help on using Firebreath to achieve the same is most preferable. How to use Delphi with Firebreath?

2条回答
Anthone
2楼-- · 2019-07-19 05:14
  • use a good HTML / JavaScript editor (for example the NetBeans IDE) create a basic HTML page which contains the "hard-coded" JavaScript to display the initial scene, and a HTML form to accept user input

  • use Indy or Synapse to create a HTTP server (in Delphi), wich serves this HTML page and when the user submits form input, parse the form parameters and pass them to the billiard simulation, which should emit a list of graphic commands as a result - and convert these to WebGL (this is the hard part) statements

  • from the HTTP server, send a response (HTML document) back to the client, with the JavaScript / WebGL statements embedded, so that the client will see the animation and the new playfield state

  • repeat until end of game

查看更多
太酷不给撩
3楼-- · 2019-07-19 05:15

Create a COM DLL and install it on the client's machine. Then Javascript can use its ActiveXObject class to access the COM object (or, under IE, you can use the <object> HTML tag). Make sure your COM object implements the IDispatch interface, as Javascript needs to use late binding since it is an interpretted environment and not compiled.

查看更多
登录 后发表回答