Detecting "window-hardware" flag

I’m using openfl 3.6.1, lime 2.9.1 but with flixel so in legacy or hybrid, whatever it is it’s not next. I need to detect whether hardware acceleration is on or not, like my 32-bit linux box I build with openfl build linux --window-hardware=false. (If I didn’t compile this way, the game simply wouldn’t run.)

I tried at runtime with if (Lib.application.config.windows[0].hardware) but it won’t compile because Class<openfl._legacy.Lib> has no field application. How can I detect whether I’ve passed that window-hardware flag instead then?

I tried searching for “window-hardware” in both the lime and openfl repos, but I see nothing there.

I cannot think of a way, does it need to be programmatic, or could it be a visual test?

Really? Dang…yeah, it has to be programmatic. Isn’t there a way to tell whether there’s hardware acceleration in use, even if not specifically via checking for “window-hardware”?

If we can’t find out if that flag was set maybe we can go around the problem.

You could do openfl build linux --window-hardware=false -DnoHardware and

#if noHarware
var hardware = false;
#else
var hardware = true;
#end

as long as you always add the flag with the --window-hardware=false it’ll work.

1 Like

Good call, thanks for the suggestion. :slight_smile:

Oh, BTW for OpenFL 4, this is the correct code:

if (stage.window.renderer.type == OPENGL) {
    
    trace ("Using OpenGL hardware");
    
}

If you create a build with support for hardware acceleration, it may fallback still to Cairo and Canvas on native or HTML5 builds

1 Like

Very good, that’ll be useful going forward. Thanks!