Transparent Desktop Window Background Confusion

I’m a beginner in Haxe and OpenFL in general but I wanted to see if it’s possible to create a borderless window (can do this) which contains a png image but a transparent background (stage) without having this rectangle window area appearing, yet no matter how much I look up online I can’t find an answer to this specific thing.

Expected (Something like this which I’ve seen done in Flash):


.hx file:


import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.display.Sprite;
import openfl.Assets;
import openfl.Lib;

class Main extends Sprite {
	public function new () {
		super ();
		var bitmap = new Bitmap (Assets.getBitmapData ("assets/openfl.png"));

		bitmap.x = (stage.stageWidth - bitmap.width) / 2;
		bitmap.y = (stage.stageHeight - bitmap.height) / 2;
		//stage.alpha=0; //making it 0 will make everything disappear
		addChild (bitmap);


.xml file:

<?xml version="1.0" encoding="utf-8"?>
	<meta title="Displaying a Bitmap" package="org.openfl.samples.displayingabitmap" version="1.0.0" company="OpenFL" />
	<app main="Main" path="Export" file="DisplayingABitmap" />
	<window borderless="true"/>

	<source path="Source"/>
	<haxelib name="openfl"/>
	<assets path="Assets" rename="assets" />

Thank you so much for your time :heart_eyes:

Maybe try <window background="null" />?

Tried it before but didn’t do anything :frowning:

We do have code within OpenFL that supports a null stage color. stage.color = null might also do it. However, I believe I tried to do what you are trying to do, and I think I had trouble with the SDL2 window context working with a transparent background. It might have been that I wasn’t testing borderless, though, or it might not have been supported on all desktops

So far nothing significant has changed even without borderless, isn’t there any workaround this issue? Maybe a method here and there in Lime? Or maybe instead of extending Sprite, I extend Application and try to do some sort of a Custom Rendering?

The first question is if we can get a transparent context from SDL2. I think the last I looked (at least one or or two platforms) it was hard-coded to not allow alpha in the OpenGL context. That I think would be the trickiest part if it is not supported. Otherwise, we can certainly sort out our end – we do support transparent GL contexts in our HTML5 target for sure

Is there any update on this? The OpenFL and Lime release notes include mentions of this but it still doesnt seem to be working

1 Like