samedi 25 juin 2016

C++ SDL2 Non refreshing window randomly

(you can skip first point in TOC and go to second point right away Table of Content Introduction, about project What is the problem How did I try to solve it Introduction, about project I am writing a game in C++, using SDL graphics and SDL_Mixer for music. The project is already quite big, I am writing engine, kindof, yet, having 11 000 lines and it is like 20 percent done. What is the problem I am facing very strange issue. The window does not refresh, ALLTHOUGH I [DO] call SDL_RenderPresent(renderer); The stranger thing is, that sometimes, it does work nicely (all updates and so on), but sometimes, I need to drag window with mouse in order to refresh it (drawn stuff freezes). If this ,,random issue" occurs, it persits ALL the time, until I quit application. Because of the size of project, I am not able to provide all code here. Theoretically, however, if you would like all code, I have all documented with doxygen aswell. Here is shown the top Draw method... void Core::Draw(SDL_Renderer * renderer) const { SDL_RenderClear(renderer); if(Variables::Game::GameState == Variables::MAIN_MENU) { Main_Menu->Draw(renderer); } else if(Variables::Game::GameState == Variables::GAME_RUNNING) { Game_Object->Draw(renderer); } Printer::PrintMessage(__FUNCTION__, "Render update"); SDL_RenderPresent(renderer); } Now the Printing text for render update is being shown all the time, even if the window freezes. How did I try to solve it I tried to run it in debug mode, from code:blocks, and even just running compiled binary from terminal. I also tried to call SDL_UpdateWindowSurface( window ); but no success. I personally think that maybe it is because of the size of project...? I mean, SDL seems quite nooby and unstable...Have anyone ever encountered such an issue? Any help would be appreciated Have a nice day

Aucun commentaire:

Enregistrer un commentaire