I originally wrote my game using glfw. However due to it lack of android portability I have to replace all of my glfw code with SDL, since SDL is more portable.
My original game loop using the glfw frame work was very striaghtforward. Here it is:
// game loop
while (!glfwWindowShouldClose(window)) {
//if-else statements that create
//the games state machine
//player input is received here
//rendering done here
}
Ok. There are probably better ways of writing this game loop, but the point is the code worked for the game prototype.
However now that I'm switching to SDL I have encountered a problem. It seems that SDL_Event has to be placed into a while loop to constantly check for events. And THIS while_loop is within another while_loop. So my code looks like this:
while(!Quit) {
SDL_Event event;
while(SDL_PollEvent(&event)) {
//if-else statements that create
//the games state machine
//player input is received here
//rendering done here
}
}
However this while_loop within a while_loop has completely messed up the games rendering! I'm now getting flickering! Is there any other way to express this code in just a single while_loop as I did earlier with glfw. Or is there any way to check for events without using an embedded while_loop