SDL3 with C not generating window

Why is the window not showing even though there aren't any errors in my code


#define SDL_MAIN_USE_CALLBACKS
#include <stdio.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> // For SDL_main on some platforms

SDL_Window* window;
SDL_Renderer* renderer;

void SDL_AppQuit(void *appstate, SDL_AppResult result) {
    SDL_DestroyRenderer(renderer);
    renderer = NULL;

    SDL_DestroyWindow(window);
    window = NULL;

    SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {

}

void update() {

}

void render() {
    SDL_RenderClear(renderer);
    SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
    SDL_RenderPresent(renderer);

}

SDL_AppResult SDL_AppIterate(void *appstate) {
    render();
    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
    if (!SDL_Init(SDL_INIT_VIDEO)) {
        SDL_Log("ERROR INITIALIZING SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    window = SDL_CreateWindow(
        "SDL3 Game",
        800,
        600,
        -0
        );

    if (!window) {
        SDL_Log("ERROR CREATING WINDOW: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    renderer = SDL_CreateRenderer(window, NULL);

    if (!renderer) {
        SDL_Log("ERROR CREATING RENDERER: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    return SDL_APP_CONTINUE;
}


 

 

This Is My CMakeLists.txt

cmake_minimum_required(VERSION 4.0)
project(MyFirstGame C)

set(CMAKE_C_STANDARD 23)

# Set the path to your SDL3 CMake configuration
set(SDL3_DIR "C:\\Users\\pc\\OneDrive\\Documents\\SDL3-devel-3.2.28-mingw\\SDL3-3.2.28\\cmake")

# Find the SDL3 package
find_package(SDL3 REQUIRED)

# Add your executable
add_executable(MyFirstGame main.c)

# Link the SDL3 library
target_link_libraries(MyFirstGame PRIVATE SDL3::SDL3)


 

1

Please sign in to leave a comment.