Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,892 questions

51,823 answers

573 users

How to create an empty window that close itself after N seconds using SDL2 in C

2 Answers

0 votes
#include <stdio.h>
#include <SDL.h>

int main(int argc, char *argv[]) {

    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        printf("SDL_Init Error: %s\n", SDL_GetError());
    }

    SDL_Window *window = SDL_CreateWindow("SDL",
        SDL_WINDOWPOS_CENTERED,
        SDL_WINDOWPOS_CENTERED,
        800, 600, SDL_WINDOW_SHOWN);

    SDL_Surface* screen = SDL_GetWindowSurface(window);
    
    SDL_Delay(2000); // 2 Sec
    SDL_DestroyWindow(window);

    SDL_Quit();

    return 0;
}

 



answered Jan 2, 2022 by avibootz
edited Jan 7, 2022 by avibootz
0 votes
#include <stdio.h>
#include <SDL.h>

int main(int argc, char* argv[]) {

    SDL_Window* window;                   

    SDL_Init(SDL_INIT_VIDEO);             

    window = SDL_CreateWindow(
        "SDL2",                  
        SDL_WINDOWPOS_UNDEFINED,          
        SDL_WINDOWPOS_UNDEFINED,           
        800,                              
        600,                              
        SDL_WINDOW_OPENGL                  
    );

    if (window == NULL) {
        printf("SDL_CreateWindow Error: %s\n", SDL_GetError());
        return 1;
    }

    
    SDL_Delay(3000); // 3 Sec

    SDL_DestroyWindow(window);

    SDL_Quit();

    return 0;
}

 



answered Jan 7, 2022 by avibootz

Related questions

1 answer 262 views
1 answer 233 views
1 answer 217 views
1 answer 204 views
1 answer 217 views
1 answer 291 views
...