How to detect hardware acceleration on openfl legacy?

  • I'm using flixel 4.1.1, openfl 3.6.1, lime 2.9.1 and found these lines of the texture atlas demo interesting:

    		// Remove atlas bitmaps from memory (useful for targets with hardware acceleration: cpp only atm).

    Sounds great! If everything's loaded up into graphics memory, dump it from regular memory.

    But what if I've compiled for systems without hardware acceleration, like my 32-bit linux box 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 ([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.

  • @IBwWG Maybe the whole thing is moot though--can anyone confirm whether the line above is safe and sensible to do also on a non-hardware-accelerated system (cpp in either case)? Like if you run that code in that case, is it merely useless, or is it actually destructive? If it's merely useless then that's fine, I'll just put it in. If it's destructive, I need to find a way to detect hardware acceleration...

  • I can confirm that it's definitely not safe to call dumpCache() on cpp, if you intend to use pixel perfect collision checks! It results in your collisions never colliding because they get checked against an auto-generated transparent image.

    I can also confirm it is safe to call dumpCache() on flash, even with collision checks, because, IIRC, it doesn't do anything anyway on that platform.

Log in to reply