Advertisement

Ported Nehe tutorials 2-10 to Firefox [multiple plugins per page issue]

Started by March 13, 2005 12:20 AM
41 comments, last by shadowwz 19 years, 8 months ago
Quote: Original post by shadowwz
also don't forget to move the "delete sd;" too with "HANDLE hTemp = sd->hThread;"


That did the trick. Here is the [updated source] and a posted [test page].
*News tagenigma.com is my new domain.
Hey Shadowwz,

I [ported Nehe tutorials 2-10] to the mozilla plugin style.

I'm running into window focus issues, where the plugin isn't accepting keyboard input. I did a hack by setting the focus in the draw section. This gives the OpenGL focus and somehow keeps the Firefox title still blue. But if you switch to another program, the taskbar flickers like crazy. Can you take a look?

Any performance benefits you can find would be great too!

Thanks,
~Tim

[Edited by - tgraupmann on March 17, 2005 11:00:41 PM]
*News tagenigma.com is my new domain.
Advertisement
Quote: Original post by tgraupmann
Hey Shadowwz,

I [ported Nehe tutorials 2-10] to the mozilla plugin style.

I'm running into window focus issues, where the plugin isn't accepting keyboard input. I did a hack by setting the focus in the draw section. This gives the OpenGL focus and somehow keeps the Firefox title still blue. But if you switch to another program, the taskbar flickers like crazy. Can you take a look?

Any performance benefits you can find would be great too!

Thanks,
~Tim

Hi Tim,

as for a focus it's not good to set it in DrawGLScene,thats why you get the flickering - it's better to add it on mouse down message ,like this :

case WM_LBUTTONDOWN:
SetForegroundWindow(hGL_Wnd);
SetFocus(hGL_Wnd);
break;

otherwise you can't type url in address bar &).
* you also can skip drawing if window is not visible or active.

Also, I can't embed multiple plugins on the same page. How should the code handle that?
*News tagenigma.com is my new domain.
Quote: Original post by tgraupmann
Also, I can't embed multiple plugins on the same page. How should the code handle that?


maybe if you call wglMakeCurrent(hGL_DC,hGL_RC) each time before you call DrawGLScen,but i'm not shure if it will work.

if GL contex is created in gl_draw_thread then it should be independent,but then KillGLWindow(); should be called in this thread and the ::PostMessage(hGL_Wnd,WM_GL_MESSAGE,0,0); need to be replaced to :
if(wglMakeCurrent(hGL_DC,hGL_RC)){
DrawGLScene();
SwapBuffers(hGL_DC);
}

Quote: Original post by shadowwz
maybe if you call wglMakeCurrent(hGL_DC,hGL_RC) each time before you call DrawGLScen,but i'm not shure if it will work.


The result of this was not what I expected. By putting wglMakeCurrent above DrawScene, it allowed the OpenGL plugin to work on my second monitor. I have a matrox dual display. So that's a positive that I'm keeping.

I still need the setfocus statements, because wglMakeCurrent didn't automagickally allow the WM_KEYPRESS messages to be intercepted.

Let's get a specific example working. How about Lesson 10? Here is [the source code].

There are two tests in the C:\GeckoPluginSDK-samples\Win32SDK\sdk\samples\lesson10 folder.

#1 test.html
#2 multtest.html

And we have to problems.

#1 Taskbar flickering
#2 Need to share the OpenGL plugin for multiple embed statements.
*News tagenigma.com is my new domain.
Advertisement
Quote: Original post by shadowwz
as for a focus it's not good to set it in DrawGLScene,thats why you get the flickering - it's better to add it on mouse down message ,like this :

case WM_LBUTTONDOWN:
SetForegroundWindow(hGL_Wnd);
SetFocus(hGL_Wnd);
break;

otherwise you can't type url in address bar &).
* you also can skip drawing if window is not visible or active.


Ok this makes it so you actually have to click the embedded 3d plugin to give it focus. It should probably have focus to begin with. I can do something about that by setting the focus in Init.

The only thing now is if there is a KeyPress event and then you change the focus. The KeyUp event is missed. Which is as simple as:
		case WM_KILLFOCUS:			for(int i=0; i<256; i++)				keys = FALSE;		break;


Unfortunately this also kills the focus that was set on init. But you can still left click to get the focus again. hm... So I'll nix the focus that was set on init.

Okay, updated [the source code].


There has to be a way to set focus other than the left click. Because Firefox goes haywire if you try to set a bookmark with the plugin running...

[Edited by - tgraupmann on March 18, 2005 3:40:43 PM]
*News tagenigma.com is my new domain.
focus - you can set focus after some delay ,at a first time - something like 1 sec

multiple embeded - the problem is global variable in plugin ,and to fix this all plugin code need to be changed to work with not global variables.(if you comment "if(!hGL_Wnd){..}" in init() function maybe it will work,but both windows will display same data and react in same way)
Quote: Original post by shadowwz
focus - you can set focus after some delay ,at a first time - something like 1 sec

multiple embeded - the problem is global variable in plugin ,and to fix this all plugin code need to be changed to work with not global variables.(if you comment "if(!hGL_Wnd){..}" in init() function maybe it will work,but both windows will display same data and react in same way)


I'll try moving the globals into the nsPluginInstance. Ahhh. WNDPROC and CREATE thread have to be static. I found a good article on [the problem], which I'll use the ATL method.

[Edited by - tgraupmann on March 19, 2005 2:03:25 PM]
*News tagenigma.com is my new domain.
In the [atl example code]:
RECT r = { 200, 200, 600, 400 };w.Create(0, r, 0, WS_OVERLAPPEDWINDOW);


They use a RECT to create the window. That's perfect, because that's what the plugin SDK gives you... I'll have to check this out later..
*News tagenigma.com is my new domain.

This topic is closed to new replies.

Advertisement