grimfang4 / sdl-gpu

A library for high-performance, modern 2D graphics with SDL written in C.
MIT License
1.19k stars 123 forks source link

out-of-order blits between image and its own target #135

Open AltairPL opened 6 years ago

AltairPL commented 6 years ago

Not sure if this is a bug or not, but since it was working in SDL_gpu some months ago, I'm posting this just in case. My usage case is probably borderline, because I need to retain compatibility with old engine (non SDL/SDL_gpu), but I think it could happen in more common uses as well. Anyway, I need to draw something on an image (first gauge line on example images) and then immediately blit it to other parts of the image (remaining gauge lines on example images). It works as intended in both old engine and older version of SDL_gpu, but in current SDL_gpu version, some blits are performed before the draw that should be first, which results in parts of the image retaining previous state.

Example images: should be: should_be is (or rather was, since I only get next one now): is_1 is: is_2

The only working workaround is to use separate image to draw the first line and then blit it to desired target image.

Please, let me know if you need any more info.

dhiahassen commented 6 years ago

try GPU_FlushBlitBuffer() after each single SDL_gpu call

AltairPL commented 6 years ago

Tried both GPU_FlushBlitBuffer() and GPU_Flip(target) and it didn't solve the problem. It's possible that the image in the middle was a result of either of them, but I can't check it out at the moment.

dhiahassen commented 6 years ago

It is really hard to guess without a code simple

AltairPL commented 6 years ago

Heh, my code is all but simple, since I'm a noob at C and since functions I use are representation of Ruby methods. In a nutshell:

Using second image for GPU_TriangleBatch() and then blitting from it to the desired target works. Hope my explanations are good enough... I know I suck at explaining things in English. Anyway, will try to make a simple project that can reproduce this behavior, but I'm kinda tied up at the moment.

AltairPL commented 6 years ago

Bummer, did a simple program to attempt to reproduce the issue, but it's working just fine. It would suggest that something I did is at fault, but why was it working as expected in (much) earlier version of SDL_gpu? Gonna leave this issue open in hopes that @grimfang4 will be able to shed some light on it. And in the meantime I still need to get over whole code of my game/engine, so maybe I'll find the cause. Anyway, thanks for trying to help @dhiahassen - much appreciated.

grimfang4 commented 6 years ago

I'm not positive. If you can reproduce it, let's follow up.