浏览器插件中的Directx控件 [英] Directx control in browser plugin
问题描述
我必须将DirectX控件插入到用于浏览器的firebreath插件中. 任何人都可以张贴样品该怎么做?我对插件一无所知...
I have to insert a directx control to a firebreath plug in for a browser. Can anyone post a sample how to do it? I have no knowledge in plugins...
10倍
推荐答案
我没有一个可以给您的示例,但是我可以大致告诉您您需要做什么.
I don't have an example that I can give you, but I can tell you roughly what you need to do.
首先,请阅读以下内容: http://colonelpanic.net/2010/11/firebreath-tips-drawing-on-windows/
First, read this: http://colonelpanic.net/2010/11/firebreath-tips-drawing-on-windows/
这将为您提供有关FireBreath中绘图工作方式的概述.
That will give you an overview of how drawing works in FireBreath.
首先,您在处理AttachedEvent时进行了所有设置.
First, you set everything up when handling AttachedEvent.
- 创建一个新线程来处理图形(您的DirectX绘图不能在主线程上)
- 从PluginWindowWin对象获取HWND(将FB :: PluginWindow *广播到FB :: PluginWindowWin并调用
- Create a new thread to handle drawing (your DirectX drawing must not be on the main thread)
- Get the HWND from the PluginWindowWin object (cast the FB::PluginWindow* to FB::PluginWindowWin and call getHWND())
- Initialize DirectX on the secondary thread with the provided HWND. Set up some form of render loop and make sure you can send it commands from the main thread.
- Handle the RefreshEvent (comes from WM_PAINT) by posting a message somehow to your render thread so it redraws when that event is fired.
- Make sure that on DetachedEvent you shut down your thread.
您需要在同一线程上完成DirectX东西的所有初始化,绘制和关闭.这一切都需要在不仅是主线程的线程上发生(不要仅仅使用计时器),因为否则,它将使某些版本的Firefox混乱浏览器渲染上下文-不知道为什么.
You need to do all initialization, drawing, and shutdown of the DirectX stuff on the same thread. This needs to all happen on a thread that is not just the main thread (don't just use timers) because otherwise it'll mess up the browser rendering context on some versions of Firefox -- not sure why.
无论如何,希望这会有所帮助.
Anyway, hope this helps.
编辑:要将参数传递给boost :: thread的开头,如果该参数是您决定使用的线程抽象,则只需将其作为参数传递即可.
Edit: To pass parameters into the start of a boost::thread, should that be the threading abstraction you decide to use, simply pass it in as a parameter.
boost::thread t(&MyClass::someFunction, this, theHWND);
这将启动线程.实际上,您可能希望使线程成为类变量或其他东西,以便以后可以访问它-请记住,您希望线程在处理DetachedEvent时已停止.对于消息,我可能会使用FB :: SafeQueue,这是FireBreath的一部分,是线程安全队列.查看如何使用它的来源;这非常简单(我认为是从代码项目文章中偷来的.)
That will start the thread. In actuality, you probably want to make the thread a class variable or something so that you can access it later -- remember that you'll want the thread to have stopped during the handling of DetachedEvent. For messages I'd probably use FB::SafeQueue, which is a threadsafe queue that is part of FireBreath. Look at the sources for how to use it; it's pretty straightforward (stolen from a codeproject article, I think).
// Inside MyClass
void someFunction(HWND theHWND) {
...
}
这篇关于浏览器插件中的Directx控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!