Get HWND (or Window Handle) from Electron for DirectX/OpenGL


#1

Hey everyone.

Someone knows how to grab the HWND (or the Native Window Handle) which Electron creates, i need it because i’m using Ogre3D, and would like to grab the handle to embed it into my Electron application, in a cross platform way to gather it would be more desirable, i looked the entire forum without luck.

(I don’t take suggestions of using WebGL provided by Electron/Renderer instead, pretty tired to get those answers).


#2

Electron is built on top of Chromium and Node.js to provide a web-based, i.e. non-native, application platform. I suspect that what you’re attempting to do is somewhere between very hard to nearly impossible, most likely because the native window handle is buried somewhere deep inside the Chromium part of the stack where nobody has to care about it.


#3

God, but i heard also about to write an Pepper API plugin to solve this ( i guess) Imnsoniac Games uses an simple generic Pepper plugin in Chrome to attach their engine’s renderer inside ( i don’t remember well where it’s mentioned, i think in Twitter i guess).


#4

Do they make this plugin available to the general public? Perhaps you should start there?


#5

Unfortunately not, just i find an OpenGL ES Skeleton Pepper plugin from one of the devs. Also i wanted to know is people successfully embedded Ogre3D in Node.js: http://techny.tumblr.com/post/39310615517/node-js-ogre3d-fmod-demo-1 but he doesn’t released any code, and i have to say it’s very frustrating for myself.


#6

I guess the approach taken there was:

  1. Create a wrapper in C++ from OpenGL to Node
  2. Create wrapper to some window creation facility (like glew or whatitis)
  3. Call those from javascript

None of these involves a single line of chromium. I would guess interoperability to be painful. A lot, I mean…


#7

Well, for nothing i wanted to use Electron to get nicer UI, together with the rendering view for editing levels and geometry, i think i gonna to modify Chromium to expose it.


#8

Hey, If you find a solution I would be very interested to hear about it. I think an optimal way would be to utilize https://github.com/google/angle/blob/master/extensions/EGL_ANGLE_surface_d3d_texture_2d_share_handle.txt in some way. I’m not sure if it’s possible to call that function from an PPAPI plugin. Hopefully it would be possible…


#9

I remember (from 10 years ago) that there are WIN32 API calls that let you find a Window based on its “classname” and title. Using this it should be trivial to get the HWND without even looking into Chromium.


#10

Did you ever modify chromium to do what you needed? I’ve been looking at doing it myself but still havent found a way the feels ok. It’s a mess of handmade/autogenerated proxy classes and ipc communication :F


#11

I gave up Electron a long time ago for my tools, i’m using now Qt 5 and meets all my needs. if i was you i go with Chromium Embedded Framework, there’s an API to embed and expose window handles.