Tuesday, 10 September 2013

Why the game window closes after specific time?

Why the game window closes after specific time?

Why the window that created by SDL Library are automatically closed after
specific time.
I know the reason is SDL_Delay() function, but if not used that function,
the game will give me runtime error.
How can I create a window that continuously work without appear in
specific period time ?
My code:
SDL_Window *window;
SDL_Renderer *render;
int main(int argc, char* args[]){
if(SDL_Init(SDL_INIT_EVERYTHING) >= 0){
window = SDL_CreateWindow("Simple game", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);
if(window != 0){
render = SDL_CreateRenderer(window, -1, 0);
}
}else{
return 1;
}
SDL_SetRenderDrawColor(render, 0, 0, 0, 255);
SDL_RenderClear(render);
SDL_RenderPresent(render);
SDL_Delay(3000);
SDL_Quit();
return 0
}

No comments:

Post a Comment