When driving and motionlessness, the square periodically disappears for a moment. This happens when using the Graphics.updateWindow () class method. Please tell me how to get rid of the problem.
Graphics.cpp
Void Graphics :: DrawRect (SDL_Rect * RECT, UINT8_T RGBA [4])
{
SDL_setRenderDRAWColor (Renderer, RGBA [0], RGBA [1], RGBA [2], RGBA [3]);
SDL_RenderFillRect (Renderer, RECT);
SDL_RENDERDRAWRECT (Renderer, RECT);
SDL_RENDERPRESENT (Renderer);
}
Void Graphics :: UPDATEWINDOW (UINT16_T FPS)
{
SDL_DELAY (1000 / FPS); // 1000 Miliseconds. Result Is Miliseconds Delay
SDL_SetRenderDRAWColor (Renderer, 0, 0, 0, 0);
SDL_RENDERFILLRECT (Renderer, & amp; Background);
}
Answer 1
The problem was solved. Thank you, @ こきん .
Moved the SDL_RenderPresent call from the DrawRect method to the beginning of the UpdateWindow method
Now the Graphics.updateWindow ()
method
void graphics :: updatewindow (uint16_t fps)
{
SDL_RENDERPRESENT (Renderer);
SDL_DELAY (1000 / FPS); // 1000 Miliseconds. Result Is Miliseconds Delay
SDL_SetRenderDRAWColor (Renderer, 0, 0, 0, 0);
SDL_RENDERFILLRECT (Renderer, & amp; Background);
}
Thanks again.