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,907 questions

51,839 answers

573 users

How to create a window with the specified dimensions and flag with SDL3 in Win32 C++

1 Answer

0 votes
#include <SDL3/SDL.h>

#if _WIN32 // PLATFORM_WINDOWS 

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
    _In_opt_ HINSTANCE hPrevInstance,
    _In_ LPWSTR lpCmdLine,
    _In_ int nCmdShow) {

    if (!SDL_Init(SDL_INIT_VIDEO)) {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    SDL_Window* window = SDL_CreateWindow(
                                "SDL3 window",    // window title
                                800,              // width, in pixels
                                600,              // height, in pixels
                                SDL_WINDOW_OPENGL // flag
    );

    // Check that the window was successfully created
    if (window == NULL) {
        // SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Could not create window: %s\n", SDL_GetError());
        MessageBoxA(0, SDL_GetError(), "Could not create window", MB_OK);
        return 1;
    }

    // The window is open for 2 second

    SDL_Delay(2000);  // Pause execution for 2000 milliseconds

    // Close and destroy the window
    SDL_DestroyWindow(window);

    SDL_Quit();

    return 0;
}

#endif

 



answered Dec 28, 2024 by avibootz
edited Dec 29, 2024 by avibootz
...