问题
I need to write a web browser plugin that supports IE 7+, Firefox 3+, Chrome.
This plugin has to be able to place a DirectX object in a web page.
I have no experience with plugins.
I did some investigating and decided to do it with FireBreath.
I couldn't understand the way to place an image inside the plugin area. Can someone provide example?
How do I place a DirectX object there? Any example?
How do I trigger automatic installation?
Thanks!
Sara
回答1:
Well, there are two problems you have to solve. Understanding of plugins is really the easier one at this point, since have FireBreath to help you. Gosh, whoever wrote that must have been brilliant! (okay, it was me, so I had to say it)
The first thing to understand is that you don't "place" a "DirectX object" anywhere. You don't "place" an image inside the plugin. Rather, you draw the image to a window just like in any other windows application.
You may want to pull up my answer to another similar question: Directx control in browser plugin
In a normal plugin instance on windows (a "windowed" plugin) you will be given an HWND that you can draw to. You need to set up a DirectX context in that window and draw to it -- either at framerate that your application needs or just when a RefreshEvent comes. If you follow the link about you'll see a link to a post on colonelpanic.net on drawing in windows; that should help you understand better how you get the HWND.
Images are basically the same deal; if you have image data, you can draw it to the HWND using normal windows drawing APIs.
Finally, if you need additional help I highly recommend you pop into the FireBreath IRC chat room. I'm usually around during daylight hours (GMT-0600) on weekdays and there are others who can sometimes help as well.
来源:https://stackoverflow.com/questions/6030417/how-to-write-a-web-browser-plugin-for-ie-firefox-and-chrome