Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render operations take too long #341

Open
Pixdigit opened this issue Jul 10, 2018 · 5 comments
Open

Render operations take too long #341

Pixdigit opened this issue Jul 10, 2018 · 5 comments
Labels
sdl2-issue This issue is related to the native SDL2 library

Comments

@Pixdigit
Copy link

When doing drawing operations the renderers buffer is not immediately updated. If e.g. I fill a rect and directly present afterwards the rect will not be drawn.
I think this is an issue with sdl. Either they are not mentioning it in their docu or is indeed a bug. It could however be solved within go. But I would recommend against since it would just be a workaround and not a fix. However this could be noted in the documentation of go-sdl2 that drawing operations take a while to succeed.

@nitrix
Copy link

nitrix commented Jul 11, 2018

Do you have a code example to help reproduce the problem?

I suspect a bad manipulation or faulty hardware, because there would be way much of a bigger uproar had this been the case...

@Pixdigit
Copy link
Author

See the Pastebin here.

@nitrix
Copy link

nitrix commented Jul 12, 2018

The default color is white and you set it again to white.

Then you draw with SDL_RenderFillRect, which, when the argument is NULL, draws over the entire render target (your whole screen) with said new white.

Then we present the result, which is of course, going to look blank.

For fun, I switched to red and it behaved as expected and could not reproduce your issue.

-	screenRenderer.SetDrawColor(255, 255, 255, 255)
+	screenRenderer.SetDrawColor(255, 0, 0, 255)

untitled

@Pixdigit
Copy link
Author

I set it again to the default colour because it is more descriptive. Also makes it easier to change colour.

For me this program results in this picture:
picture

Note: the content is part of my desktop background. As soon as I add delay between the Draw call and the Present it works as intended.

@veeableful
Copy link
Contributor

veeableful commented Jul 14, 2018

It does appear to be the behavior of native SDL2 when I run the C equivalent of the example which is this:

#include <SDL2/SDL.h>

int main()
{
    SDL_Window *window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0, 0);
    SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);

    SDL_SetWindowSize(window, 400, 400);

    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
    SDL_RenderFillRect(renderer, NULL);
    SDL_Delay(1000);
    SDL_RenderPresent(renderer);
    SDL_Delay(3000);
}

I have put a note about this in the README.md under the FAQ section.

@veeableful veeableful added the sdl2-issue This issue is related to the native SDL2 library label Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdl2-issue This issue is related to the native SDL2 library
Projects
None yet
Development

No branches or pull requests

3 participants