My SDL 2 game crashes when it is idle |
Naith
|
Sorry to say it, but I am really unsure about the structure of your code.
Does your render_world function execute each frame? Why are you having the main loop (' while(!quit) ') in the render_world function? In my opinion you should have it the other way around, i.e, have a main loop which execute an update function (which calculates the FPS, checks for events and such) and after that, the render_world function is called. It looks to me that you're loading some font file (' fpsText = load.load_font(fpsFont.str().c_str(), fontTypes, fontColor, render); '), each frame. You really shouldn't do that. Instead, load the textures, fonts and such in some Create/Init function before the main loop start and destroy everything in your Close function. Also, by the text written out in the console, it looks like you're calling some CreateTexture function somewhere in your code and you should show us that aswell. |
|||||||||||
|
cyberspace009
|
Hey, Naith Thank you for responding my post and providing some insight. I will rename the "render_world(...)" function into "main_loop(...)" or something. Sorry to cause any confusion .
I am glad you mention the issue about the [b]fpsText[b] I will fix that and see if it improves.
I never created such a function, CreateTexture, so I will look into my code and see what's going on. Thanks for the help![/quote] |
|||||||||||||||||
|
Solved! |
cyberspace009
|
I found the solution to the problem:
Naith was right about this:
My game is able to stay idle for sometime now. I can finally get back to work on my project. Thank you very much, Naith! |
|||||||||||||
|