<p dir="auto">I've developed an OpenGL-based C++ animation engine. I'm wrapping it into a Node.js module using <a href="https://github.com/swig/swig">SWIG</a> and would like to hook it into an Electron app.</p>
<p dir="auto">The engine has a very encompassing test suite -- Between that and the simplest node scripts, I can see all basic functionality working as expected outside an Electron app. The test suite and scripts also work when running Electron as Node via <code class="notranslate">ELECTRON_RUN_AS_NODE</code>.</p>
<p dir="auto">Mysteriously, I can't perform any rendering <em>inside</em> an Electron app in neither the browser nor render process.</p>
<p dir="auto">More accurately, any calls to <code class="notranslate">glGenX</code> return 0. Querying <code class="notranslate">glGetString(GL_VERSION)</code> returns null, afterward <code class="notranslate">glGetError</code> reports no error. I've made a <a href="https://stackoverflow.com/questions/44512019/mysteriously-invalid-opengl-context-in-electron" rel="nofollow">StackOverflow question</a> that describes how I check context creation; I don't think I'm missing anything, but contexts still appear to be dysfunctional.</p>
<p dir="auto">Is this perhaps known behavior? Is there a caveat I'm missing?</p>
<ul dir="auto">
<li>I'm running Debian Stretch and Electron 1.5.1, unable to upgrade to a newer version without module version mismatches.</li>
<li>In case Chromium is interfering with my OpenGL contexts somehow, I've tried disabling hardware acceleration, ensuring it is disabled before the app is ready. I've also tried passing <code class="notranslate">--disable-gpu</code>.</li>
<li>All OpenGL actions are 100% definitely occurring in the same thread.</li>
<li>Architecture of electron and the module are both <code class="notranslate">x64</code>.</li>
</ul>
<ul dir="auto">
<li>Electron version: 1.6.1</li>
<li>Operating system: Linux</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">I have created a nodejs addon that works inside electron as well. When running against nodejs I can<br>
create a GLFW window with a GLES2 context and use it as expected. When running against electron, a GLFW window is created, the context briefly exists, then as soon as I call a GL function, it behaves as if the context is gone. glGetString(GL_VERSION) returns null immediately after creating the window, and after explicitly making the context current. glGetError also returns 0.</p>
<p dir="auto">This worked previously just fine in v1.4.15.</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">This requires that GLFW3, Electron, and node-gyp are installed on the system.</p>
<p dir="auto">The build script is also hard coded to build for electron 1.6.1.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/MyUPlay/MyEngine
cd MyEngine
make -j8
electron test/core/BasicExample-electron.js"><pre class="notranslate"><code class="notranslate">git clone https://github.com/MyUPlay/MyEngine
cd MyEngine
make -j8
electron test/core/BasicExample-electron.js
</code></pre></div>
<p dir="auto">To prove the code works otherwise (from inside the repo):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="NODEBUILD=1 make -j8
node test/core/BasicExample.js"><pre class="notranslate"><code class="notranslate">NODEBUILD=1 make -j8
node test/core/BasicExample.js
</code></pre></div>
<p dir="auto">The js has to be different, obviously, so that it doesn't call electron to do the UI, which should be the only difference.</p>