From 9bbfd40f8be352e6b603a5f2cac30863fb7a409c Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 6 Aug 2018 14:47:07 -0700 Subject: [PATCH] Force enable WebGL on Electron/Linux --- templates/electron/haxe/ElectronSetup.hx | 30 ++++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/templates/electron/haxe/ElectronSetup.hx b/templates/electron/haxe/ElectronSetup.hx index f6779a8fa..5b1caa793 100644 --- a/templates/electron/haxe/ElectronSetup.hx +++ b/templates/electron/haxe/ElectronSetup.hx @@ -2,11 +2,13 @@ import electron.main.App; import electron.main.BrowserWindow; class ElectronSetup { - + public static var window:BrowserWindow; - + static function main() { + electron.main.App.commandLine.appendSwitch('ignore-gpu-blacklist', 'true'); + var windows:Array = [ ::foreach windows:: { @@ -34,8 +36,8 @@ class ElectronSetup { y: ::y:: },::end:: ]; - - for (i in 0...windows.length) + + for (i in 0...windows.length) { var window:OpenFLWindow = windows[i]; var width:Int = window.width; @@ -43,22 +45,24 @@ class ElectronSetup { if (width < 1200) width = 1200; if (height < 800) height = 800; var frame:Bool = window.borderless == false; - + electron.main.App.on( 'ready', function(e) { - ElectronSetup.window = new BrowserWindow( { - fullscreen: window.fullscreen, - frame:frame, + var config:Dynamic = { + fullscreen: window.fullscreen, + frame:frame, resizable: window.resizable, alwaysOnTop: window.alwaysOnTop, - width:width, - height:height - } ); - + width:width, + height:height, + webgl:window.hardware + }; + ElectronSetup.window = new BrowserWindow(config); + ElectronSetup.window.on( closed, function() { if( js.Node.process.platform != 'darwin' ) electron.main.App.quit(); }); - + ElectronSetup.window.loadURL( 'file://' + js.Node.__dirname + '/index.html' ); #if debug ElectronSetup.window.webContents.openDevTools();