Creating an NPAPI plugin in Delphi and accessing exported APIs using javascript

I found a useful billiards library in Borland delphi for my hobby project. The code is object oriented (in Object pascal). I want to render it using webGL (javascript) in a Chrome browser.

The idea is that I would have to make one call to make from javascript, which will access the interface from delphi lib and give me a new position, rotation and scale values โ€‹โ€‹in the corresponding array.

For this, I want to develop the NPAPI lib Scriptable plugin in Delphi (assuming the lack of a UI is only a lib API).

1) I want to export the necessary physics APIs from Delphi through this NPAPI plugin and access them on my html page using JavaScript. I am aiming for chrome. 2) Any simple "hello world" tutorial or article related to this will be very helpful.

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

+2
source share
2 answers
  • use a good HTML / JavaScript editor (such as NetBeans IDE), create a basic HTML page containing โ€œhard-codedโ€ JavaScript to display the initial scene, and an HTML form to accept user input

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

  • from the HTTP server, send the response (HTML document) back to the client with JavaScript / WebGL instructions enabled so that the client sees the animation and the new state of the playing field.

  • repeated until the end of the game

+1
source

Create a COM library and install it on the client machine. Javascript can then use its ActiveXObject class to access the COM object (or, in IE, you can use the HTML <object> tag). Make sure your COM object implements the IDispatch interface, because Javascript must use the latest binding, as it is an interpreted environment and not compiled.

0
source

Source: https://habr.com/ru/post/911791/


All Articles