How to use SDL within a firefox plugin?

Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable to SDL as to which window to send the output.

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
InstanceData instanceData = (InstanceData)(instance->pdata);
XEvent nativeEvent = (XEvent)event;

if (nativeEvent->type != GraphicsExpose)
return 0;

XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in advance.

Best regards
Unga

You need some way to get a reference to the Firefox window of the type that SDL_CreateWindowFrom is expecting (a HWND handle on Windows, not sure for other platforms) and pass that to SDL_CreateWindowFrom.? That will initialize the window for SDL to render to.

Note: I’m speaking from 1.3 experience.? It might be different if you’re using 1.2.________________________________
From: unga888@yahoo.com (Unga)
Subject: [SDL] How to use SDL within a firefox plugin?

Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable to SDL as to which window to send the output.

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
? InstanceData instanceData = (InstanceData)(instance->pdata);
? XEvent nativeEvent = (XEvent)event;

? if (nativeEvent->type != GraphicsExpose)
? ? return 0;

? XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
? instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in advance.

Best regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL in your browser? Wow, could this work for games too? Let me know how it
goes!

William

You need some way to get a reference to the Firefox window of the type
that SDL_CreateWindowFrom is expecting (a HWND handle on Windows, not sure
for other platforms) and pass that to SDL_CreateWindowFrom. That will
initialize the window for SDL to render to.

Note: I’m speaking from 1.3 experience. It might be different if you’re
using 1.2.


Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable
to SDL as to which window to send the output.On 9 Aug 2011 04:59, “Mason Wheeler” wrote:
From: Unga
Subject: [SDL] How to use SDL within a firefox plugin?

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
InstanceData instanceData = (InstanceData)(instance->pdata);
XEvent nativeEvent = (XEvent)event;

if (nativeEvent->type != GraphicsExpose)
return 0;

XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in advance.

Best regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Let me just start out by saying I have experience with embedding a game in an NPAPI plugin (I did the OSX and Linux porting work on QuakeLive back in 2009).

I could go on a long explanation of the troubles with QuakeLive and how it approached things (child window parented to the embed window, handling its own events and redrawing in a separate thread
using OpenGL, some very strange event passing going on as well), but I will leave the dirty details out of this discussion unless people want to hear it, and just advise NOT to do it that way.

NPAPI is supported by WebKit (Safari, Chrome, Konqueror, others), Gecko (Firefox / IceWeasel, Epiphany, several others), Opera, and a host of others.

NPAPI is not supported by Internet Explorer.

Embedded approach (like Flash, etc):
Request the childless mode (I don’t remember the API for this but you’ll find it), a child window is deprecated on Windows and X11 because it does not composite properly with CSS blended overlays and
such, and on OSX there has never been a child window feature, so you have to implement this code path for OSX even if you use a child window on the others.

On OSX request the CoreGraphics API, do not use the QuickDraw API (it is likely to be unavailable at this point anyway), it’s not worth supporting both code paths, newer browsers likely do not provide
the QuickDraw API and so you may end up getting a CoreGraphics API context without asking for it but it is best to be sure.

Your ‘main loop’ consists of NPP_HandleEvent receiving various events, this includes paint events and mouse and keyboard events, as well as animation events (I don’t recall the event name for this,
but you get up to 1000 of them per second, this is how flash animates, but is deprecated), recommended behavior is to send yourself a timer event and then respond to that by sending yourself a paint
event. (I also don’t remember what the timer event is called, look over the event enums for yourself)

You should be able to get OpenGL graphics going in the paint event but I have no experience with this approach (as mentioned above, my prior work did not do this).

Be aware that the game will not show up as a separate app on the dock, and may be running in the same process as the browser - if it crashes, it may bring down the browser with it.

Personally I don’t see how SDL can be involved in this, NPAPI (and in particular the NPRuntime with its own threading library) are pretty much their own ecosystem, and if you call the low level
functions like pthreads you have to be extremely careful not to make any NPAPI calls from these threads or else it will automatically register them with the NPRuntime and it can be extremely hard to
clean them up properly on exit.

I am also uncertain how to gather input from joysticks or do anything more clever.

Separate process approach:
You can launch the game as a separate process and let it use SDL that way, then you don’t need to implement much of NPAPI, you’ll probably want to use libcurl or similar for downloading the content
rather than pulling it down through the NPAPI functions but that is your call.

Helper application approach:
You can install the game as a regular app and then associate it with a certain kind of mime type on the web page and the user will then launch it as a helper application when they click the relevant
link (or JavaScript directs them to a “page” of that type).

P.S. trust me, do not attempt to open your own window (or spawn your own threads) in an NPAPI plugin, it is a path of pain and suffering, and prone to breakage on different browser versions, if you do
pursue this approach I can explain a fair number of observed bad behaviors you’ll have to deal with, but it’s best to just not go there.–
LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier

Hi Mason

Thanks for the reply.

I’ll try SDL_CreateWindowFrom. But the issue is I’m currently on SDL 1.2, I tried to compile and install the SDL 1.3 but develop compilation errors. This I’ll post as a separate mail.

Unga— On Tue, 8/9/11, Mason Wheeler wrote:

From: masonwheeler@yahoo.com (Mason Wheeler)
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Tuesday, August 9, 2011, 2:52 AM

You need some way to get a reference to the Firefox window of the type that SDL_CreateWindowFrom is expecting (a HWND handle on Windows, not sure for other platforms) and pass that to SDL_CreateWindowFrom.? That will initialize the window for SDL to render to.
Note: I’m speaking from 1.3 experience.? It might be different if you’re using 1.2.

From: @Unga (Unga)
Subject: [SDL] How to use SDL within a firefox plugin?

Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable to SDL as to which window to send the output.

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
? InstanceData instanceData = (InstanceData)(instance->pdata);
? XEvent nativeEvent = (XEvent)event;

? if (nativeEvent->type != GraphicsExpose)
? ? return 0;

? XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
? instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in
advance.

Best regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You can try firebreath project (firebreath.org) for developing plugins. Currently, i’m using it with SDL libraries for video player plugin.

SDL is useless for drawing on mac os x because plugins on mac are windowless.
If you want to use OpenGL on mac os x: you should to create CAOpenGLLayer and add it as a sublayer to the layer that you’re given by browser.
If you want to use OpenGL + SDL on windows, you should to create child window from that is given you by browser and then call SDL_CreateWindowFrom. Remember to create child window, because you haven’t all access to the main window. Same technique (but i didn’t test if it work yet) can be used on linux, because you have access to gtk_window.

If you will using firebreath, you can develop for NPAPI and ActiveX at one time. Also there are examples of OpenGL usage in their wiki.

You can try firebreath project (firebreath.org) for
developing plugins. Currently, i’m using it with SDL
libraries for video player plugin.

SDL is useless for drawing on mac os x because plugins on
mac are windowless.
If you want to use OpenGL on mac os x: you should to create
CAOpenGLLayer and add it as a sublayer to the layer that
you’re given by browser.
If you want to use OpenGL + SDL on windows, you should to
create child window from that is given you by browser and
then call SDL_CreateWindowFrom. Remember to create child
window, because you haven’t all access to the main window.
Same technique? (but i didn’t test if it work yet) can
be used on linux, because you have access to gtk_window.

If you will using firebreath, you can develop for NPAPI and
ActiveX at one time. Also there are examples of OpenGL usage
in their wiki.

Hi Oleg

Thanks for the reply.

I still prefer writing from scratch type. One advantage is I can learn the whole process.

Once I learn how to use SDL (1.3) to my requirement, probably I can replace the presentation part with OpenGL, then I hope it can be make work under Mac OSX too.

I’m using SDL under FreeBSD, my current problem is the SDL 1.3 cannot get to compile under FreeBSD to give it a try.

Unga— On Tue, 8/9/11, Oleg wrote:

From: Oleg
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Tuesday, August 9, 2011, 6:08 PM

Hi

I have tried SDL_CreateWindowFrom. But it fails due to incorrect data supplied.

SDL_Window* SDL_CreateWindowFrom(const void* data)
data = a pointer to driver-dependent window creation data

What is the type or structure of this “data”?

Kind regards
Unga— On Tue, 8/9/11, Unga <@Unga> wrote:

From: @Unga (Unga)
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List” , “Mason Wheeler”
Date: Tuesday, August 9, 2011, 3:41 PM

Hi Mason

Thanks for the reply.

I’ll try SDL_CreateWindowFrom. But the issue is I’m currently on SDL 1.2, I tried to compile and install the SDL 1.3 but develop compilation errors. This I’ll post as a separate mail.

Unga

— On Tue, 8/9/11, Mason Wheeler wrote:

From: masonwheeler@yahoo.com (Mason Wheeler)
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Tuesday, August 9, 2011, 2:52 AM

You need some way to get a reference to the
Firefox window of the type that SDL_CreateWindowFrom is expecting (a HWND handle on Windows, not sure for other platforms) and pass that to SDL_CreateWindowFrom.? That will initialize the window for SDL to render to.
Note: I’m speaking from 1.3 experience.? It might be different if you’re using 1.2.

From: @Unga (Unga)
Subject: [SDL] How to use SDL within a firefox plugin?

Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable to SDL as to which window to send the output.

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
? InstanceData instanceData = (InstanceData)(instance->pdata);
? XEvent nativeEvent = (XEvent)event;

? if (nativeEvent->type != GraphicsExpose)
? ? return 0;

? XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
? instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in
advance.

Best regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This depends on the platform. For example, on Win32, it is the HWND type.

PatrickOn Thu, Aug 11, 2011 at 2:09 PM, Unga wrote:

Hi

I have tried SDL_CreateWindowFrom. But it fails due to incorrect data
supplied.

SDL_Window* SDL_CreateWindowFrom(const void* data)

*data = *a pointer to driver-dependent window creation data

What is the type or structure of this “data”?

Kind regards
Unga

— On Tue, 8/9/11, Unga wrote:

From: Unga

Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List” , “Mason Wheeler” <
masonwheeler at yahoo.com>
Date: Tuesday, August 9, 2011, 3:41 PM

Hi Mason

Thanks for the reply.

I’ll try SDL_CreateWindowFrom. But the issue is I’m currently on SDL 1.2,
I tried to compile and install the SDL 1.3 but develop compilation errors.
This I’ll post as a separate mail.

Unga

— On Tue, 8/9/11, Mason Wheeler wrote:

From: Mason Wheeler

Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Tuesday, August 9, 2011, 2:52 AM

You need some way to get a reference to the Firefox window of the type that
SDL_CreateWindowFrom is expecting (a HWND handle on Windows, not sure for
other platforms) and pass that to SDL_CreateWindowFrom. That will
initialize the window for SDL to render to.

Note: I’m speaking from 1.3 experience. It might be different if you’re
using 1.2.


From: Unga
**Subject: [SDL] How to use SDL within a firefox plugin?

Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable to
SDL as to which window to send the output.

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
InstanceData instanceData = (InstanceData)(instance->pdata);
XEvent nativeEvent = (XEvent)event;

if (nativeEvent->type != GraphicsExpose)
return 0;

XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in advance.

Best regards

Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org <http://mc/compose?to=SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi

I’m on Unix (FreeBSD), so what should be the type for data?

Since now the type for MS Windows is known, I would also like to know the type for Mac OSX.

Unga— On Fri, 8/12/11, Patrick Baggett <baggett.patrick at gmail.com> wrote:

From: baggett.patrick@gmail.com (Patrick Baggett)
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Friday, August 12, 2011, 3:41 AM

This depends on the platform. For example, on Win32, it is the HWND type.
Patrick

On Thu, Aug 11, 2011 at 2:09 PM, Unga <@Unga> wrote:

Hi

I have tried SDL_CreateWindowFrom. But it fails due to incorrect data supplied.

SDL_Window* SDL_CreateWindowFrom(const void* data)
data = a pointer to driver-dependent window creation data

What is the type or structure of this “data”?

Kind regards
Unga

— On Tue, 8/9/11, Unga <@Unga> wrote:

From: @Unga (Unga)
Subject: Re: [SDL] How to use SDL within a firefox plugin?

To: “SDL Development List” , “Mason Wheeler”

Date: Tuesday, August 9, 2011, 3:41 PM

Hi Mason

Thanks for the reply.

I’ll try SDL_CreateWindowFrom. But the issue is I’m currently on SDL 1.2, I tried to compile and install the SDL 1.3 but develop compilation errors. This I’ll
post as a separate mail.

Unga

— On Tue, 8/9/11, Mason Wheeler wrote:

From: masonwheeler@yahoo.com (Mason Wheeler)
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”

Date: Tuesday, August 9, 2011, 2:52 AM

You need some way to get a reference to the
Firefox window of the type that SDL_CreateWindowFrom is expecting (a HWND handle on Windows, not sure for other platforms) and pass that to SDL_CreateWindowFrom.? That will initialize the window for SDL to render to.

Note: I’m speaking from 1.3 experience.? It might be different if you’re using 1.2.

From: @Unga (Unga)

Subject: [SDL] How to use SDL within a firefox plugin?

Hi all

I have a video player written in C using SDL. Its working well standalone.

I want to bring this video
playing functionality into a firefox plugin.

What I don’t understand is how to specify the firefox window or drawable to SDL as to which window to send the output.

The firefox calls NPP_HandleEvent() defined within the plugin as follows:

NPP_HandleEvent(NPP instance, void* event) {
? InstanceData instanceData = (InstanceData)(instance->pdata);
? XEvent nativeEvent = (XEvent)event;

? if (nativeEvent->type != GraphicsExpose)
? ? return 0;

? XGraphicsExposeEvent expose = &nativeEvent->xgraphicsexpose;
? instanceData->window.window = (void
)(expose->drawable);

}

Appreciate your help in this regard.

Many thanks in
advance.

Best regards
Unga


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list

SDL at lists.libsdl.org

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-----Inline Attachment Follows-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m on Unix (FreeBSD), so what should be the type for data?

“Window”, as in the typedef you get from Xlib.h.

Since now the type for MS Windows is known, I would also like to know
the type for Mac OSX.

"NSWindow " (which is a toplevel window with a frame, not a subwindow,
which would be NSView
), but I’m pretty sure you won’t get a window
handle from Firefox on the Mac (or, at least, you won’t own the whole
window).

I had to do this for IMVU last year…the main menu is an embedded Gecko
window, and the avatar on that menu is an NPAPI plugin that just wants
to pass the window handle to some other part of the process to draw on.
Like this…

http://icculus.org/~icculus/dotplan/nphwndproxy-mac.png

…and it was awful. If you notice that the avatar isn’t centered, it’s
because you don’t get a window handle; you get the handle to the whole
browser window and what region you can draw into. Since we hadn’t
debugged this when I took that screenshot, we were pretty much just
scribbling over whatever in the window.

We had double trouble, in that the avatar could be rendered with OpenGL,
or the software renderer Pixomatic, so we might have to set up a GL
context or a CoreGraphics context, depending.

We weren’t using SDL for this, and if we could have upgraded to a newer
Gecko with the CoreAnimation plugin drawing model, it would have been
way easier (since it gets its own CALayer, nice and contained and OpenGL
friendly).

https://wiki.mozilla.org/NPAPI:CoreAnimationDrawingModel

On Windows, the same approach is taken, but since you get a HWND there
by default, it worked pretty nicely.

But you really might be out of luck if you want to use SDL with NPAPI on
the Mac. I’m not sure I’d attempt this on Windows, either, to be honest.

–ryan.

HWND for windows, gtk_window for linux and NSWindow for mac. As said before on mac you aren’t able to access plugin’s NSWindow (because it doesn’t even exist). Again i would recommend you to use firebreath for plugin development, because there is realized all drawing\events models for each platform (i.e. CA or CG on mac) and a lot of work is done for you. Also you may wait for 2.0 release where will be offscreen blitting drawing, so you will be able to access NSWindow, NSView or whatever you want and use it with SDL. And remember to create child hwnd on windows…

I’m on Unix (FreeBSD), so what should be the type for
data?

“Window”, as in the typedef you get from Xlib.h.

Hi guys

Thanks for the replies in this regard.

Now we know SDL_CreateWindowFrom() expects a Window value, which is a number, not a structure.

I have checked the window value supplied to the NPP_SetWindow by the firefox browser:

NPError
NPP_SetWindow(NPP instance, NPWindow* window)
{
char buf[100]; // Debug

sprintf(buf, “window.window: %d\n”, window->window);
writeToLog(buf, instanceData->logfp);

}

The NPWindow structure is defined as follows:
typedef struct _NPWindow
{
void* window; /* Platform-specific handle /
uint32 x; /
Position of top-left corner /
uint32 y; /
relative to a Netscape page /
uint32 width; /
Maximum window size /
uint32 height;
NPRect clipRect; /
Clipping rectangle in port coordinates */

#ifdef XP_UNIX
void * ws_info; /* Platform-dependent additional data /
#endif /
XP_UNIX */

NPWindowType type; /* Whether this is a window or a drawable */
} NPWindow;

My plugin prints the value for window->window as follows:
window.window: 54525953

This is FreeBSD 8.1 and firefox 4.X.

Now the question is does the Firefox send me a Window value in window->window?

If it is, then SDL_CreateWindowFrom() is buggy, which I can check.

Could somebody confirm to me does the Firefox 4.X returns a Window value in window->window in NPP_SetWindow() in Unix.

Thanks

Unga— On Fri, 8/12/11, Ryan C. Gordon wrote:

From: Ryan C. Gordon
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Friday, August 12, 2011, 2:39 PM

Now the question is does the Firefox send me a Window value in
window->window?

If it is, then SDL_CreateWindowFrom() is buggy, which I can check.

Could somebody confirm to me does the Firefox 4.X returns a Window value in
window->window in NPP_SetWindow() in Unix.

That’s very specific…if you don’t get any good responses here, you might
try the Mozilla mailing list.

Patrick

Now the question is does the Firefox send me a Window value in window->window?

–ryan.

Now the question is does the Firefox send me a Window
value in window->window?

https://developer.mozilla.org/en/NPWindow

–ryan.

Ryan, thanks for the info.

So the “window” field is a “X Window ID” on Unix.

Does the SDL_CreateWindowFrom() expect a “X Window ID” on Unix?

Unga— On Sat, 8/13/11, Ryan C. Gordon wrote:

From: Ryan C. Gordon
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Saturday, August 13, 2011, 1:42 AM

Now the question is does the Firefox send me a Window
value in window->window?

https://developer.mozilla.org/en/NPWindow

–ryan.

The value of NPWindow->window is similar to other Window values in FreeBSD. Therefore, can safely assume it must be a Window ID.

I have noted another serious issue in my plugin that I have not called SDL_Init()!

This mistake in fact coming from the example given in http://wiki.libsdl.org/moin.cgi/SDL_CreateRenderer?highlight=(\bCategoryAPI\b)|(SDLFunctionTemplate).

I called SDL_Init(SDL_INIT_VIDEO) from my draw function within the firefox plugin.

Now the control does not return from SDL_Init() and firefox crashes.

My standalone SDL 1.3 test programs works well.

Any idea why the SDL_Init() does not return?

Unga— On Sat, 8/13/11, Ryan C. Gordon wrote:

From: Ryan C. Gordon
Subject: Re: [SDL] How to use SDL within a firefox plugin?
To: “SDL Development List”
Date: Saturday, August 13, 2011, 1:42 AM

The value of NPWindow->window is similar to other Window
values in FreeBSD. Therefore, can safely assume it must be a
Window ID.

I have noted another serious issue in my plugin that I have
not called SDL_Init()!

This mistake in fact coming from the example given in http://wiki.libsdl.org/moin.cgi/SDL_CreateRenderer?highlight=(\bCategoryAPI\b)|(SDLFunctionTemplate).

I called SDL_Init(SDL_INIT_VIDEO) from my draw function
within the firefox plugin.

Now the control does not return from SDL_Init() and firefox
crashes.

My standalone SDL 1.3 test programs works well.

Any idea why the SDL_Init() does not return?

Unga

Hi all

Sorry for my misunderstanding, the control returns from SDL_Init().

Its the SDL_CreateWindowFrom(npwindow.window) does not return control and crashes the firefox.

I’m going to investigate this in a short while.

Kind regards
Unga— On Sat, 8/13/11, Unga <@Unga> wrote:

Hi all

Sorry for my misunderstanding, the control returns from
SDL_Init().

Its the SDL_CreateWindowFrom(npwindow.window) does not
return control and crashes the firefox.

I’m going to investigate this in a short while.

Kind regards
Unga

Hi all

Ok, found the problem that why SDL_CreateWindowFrom() crashes.

Its at X11_CreateWindowFrom() defined on src/video/x11/SDL_x11window.c.

Following statement develops signal 11 and crashes:
window->title = X11_GetWindowTitle(_this, w);

I just commented this statement, now the firefox plugin runs without recording any error.

I’m trying to display an image on the firefox window, it doesn’t display anything.

It doesn’t stop after SDL_RenderPresent() even though I put SDL_Delay(5000). I have tried sleep(5). It still loop.

Any ideas?

Unga— On Sat, 8/13/11, Unga <@Unga> wrote:

Create child window and work only with it…