Creating NPAPI plugin in Delphi and accessing exported APIs using javascript

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?

Answer1:

    <li>

    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

    </li> <li>

    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

    </li> <li>

    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

    </li> <li>

    repeat until end of game

    </li> </ul>

    Answer2:

    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.

    人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Creating NPAPI plugin in Delphi and accessing exported APIs using javascript