Off-screen targets cannot be cleared with C2D_TargetClear
Posted: Thu May 28, 2020 11:24 am
Hello!
I made a game with citro2d that uses off screen targets/drawing to textures to be more efficient and easier to scale and tint, but there is a bug when clearing them with C2D_TargetClear.
I didn't encounter it before release because I got lazy and only tested with Citra, where it doesn't occur (where the expected behaviour of clearing does happen instead).
I tried a simple test case (see attachment) which displays the same issue.
If you don't want to have to download and compile this, here's a step by step explanation:
On console, this will "not work" and the previous squares will remain, no matter what clear color you used.
That's about it, I hope this will get fixed or there is a workaround!
Thanks for the work, I love your libraries!
I made a game with citro2d that uses off screen targets/drawing to textures to be more efficient and easier to scale and tint, but there is a bug when clearing them with C2D_TargetClear.
I didn't encounter it before release because I got lazy and only tested with Citra, where it doesn't occur (where the expected behaviour of clearing does happen instead).
I tried a simple test case (see attachment) which displays the same issue.
If you don't want to have to download and compile this, here's a step by step explanation:
- regular citro2d initialisation boilerplate
- initialise a C3D_Tex with C3D_TexInit
- in the main loop, if a target was created last frame, delete it with C3D_RenderTargetDelete
- delete the C3D_Tex with C3D_TexDelete
- regular citro2d exit
- in the main loop, on an action:
- initialize a C3D_RenderTarget* with C3D_RenderTargetCreateFromTex
- clear the newly created target with C2D_TargetClear then begin rendering to it with C2D_SceneBegin, just like in the gpusprites example
- draw a colored rectangle to it at the desired position
- in the main loop, after checking input:
- begin drawing with C3D_FrameBegin
- clear the screen target with C2D_TargetClear then begin rendering to it with C2D_SceneBegin
- create a C2D_Image that uses the C3D_Tex and draw it with C2D_DrawImageAt
- after the main loop:
- delete the C3D_Tex with C3D_TexDelete
- regular citro2d exit
On console, this will "not work" and the previous squares will remain, no matter what clear color you used.
That's about it, I hope this will get fixed or there is a workaround!
Thanks for the work, I love your libraries!