I have a simple SDL application with a re-sizeable window, if I minimise then maximise the window the rendering freezes. If I “window” the window the rendering starts again fine, and if I go from windowed to maximised it renders fine as well. I’ve included a simple code example below which makes the screen flash through varying shades of grey. Try minimising, then maximising, then windowing… How do I stop the rendering freezing when going from minimised to maximised?
I’m currently running SDL2.0 v 2.0.3 on Windows 10 machine (experienced the same problem running on previous Windows 7 machine).
I posted similar query on SDL Development group but got no response, sorry for re-posting but I’m a bit desperate… Thanks
//FLASHING SCREEN CODE
//Demonstrates screen freeze when you minimise then maximise the screen....
#include "SDL.h"
using namespace std;
int main( int argc, char* args[] )
{
//Initialise SDL2, declare Window + Renderer
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ); //Initialize SDL for video and audio
SDL_Window* pWindow = NULL;
SDL_Renderer* pRenderer = NULL;
pWindow = SDL_CreateWindow("Minimise Maximise Test", 50, 50, 1200, 600, SDL_WINDOW_RESIZABLE | SDL_WINDOW_MAXIMIZED);
pRenderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_TARGETTEXTURE);
//The Screen colour which is going to flash through different shades of grey
SDL_Color screenColour = {0, 0, 0};
//SDL event for detecting X-out (quit)
SDL_Event event;
bool quit = false;
//Loop
while( quit == false ) //While SDL has not been X'ed out
{
////Handle quit
if (SDL_PollEvent(&event) != 0)
{
if(event.type == SDL_QUIT) quit = true; //Press X-out to quit (but not visible on fullscreen)
}
//Make screen flash by changing its colour through shades of grey
screenColour.r++;
screenColour.g++;
screenColour.b++;
//Render the screen
SDL_SetRenderDrawColor(pRenderer, screenColour.r, screenColour.g, screenColour.b, 255);
SDL_RenderFillRect(pRenderer, NULL);
SDL_RenderPresent(pRenderer); //like SDL_flip
}
//Shutdown
SDL_DestroyRenderer(pRenderer);
SDL_DestroyWindow(pWindow);
SDL_Quit();
return 0;
}[/quote]