Kode / Kinc

Modern low level game library and hardware abstraction.
http://kinc.tech
zlib License
511 stars 121 forks source link

Rendertarget defaults to magenta in Metal (but is transparent on HTML5) #832

Closed oxue closed 9 months ago

oxue commented 9 months ago

Rendertarget defaults to magenta in MacOS Metal (but is transparent on HTML5)

Steps to reproduce the behavior:

var i:Image = Image.createRenderTarget(100, 100, null, NoDepthAndStencil, 1);
frame.g2.begin(true, Color.Black);
frame.g2.drawImage(i, 0, 0);
frame.g2.end();

Expected behavior Both to be same

Screenshots

image

Execution Environment:

RobDangerous commented 9 months ago

Looks like there is no good way to clear a render-target when it is created in Metal. I hereby define the contents of new render-targets to be undefined (which is also the case in Metal actually according to the docs so it's not necessarily always magenta).

RblSb commented 9 months ago

Is backbuffer.g2.clear() fixes it?

RobDangerous commented 9 months ago

Well, that's one of many options to write the render-target-data and thereby get it into a defined state.