Skip to content

add SDL_AppInit argument parser #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged

Conversation

drakbar
Copy link
Contributor

@drakbar drakbar commented Apr 8, 2025

Added function to convert the c strings passed into SDL_AppInit to python strings. It seems like a pretty common use case that is worth implemented.

minimal example:

import os, ctypes

os.environ["SDL_MAIN_USE_CALLBACKS"] = "1"

import sdl3

def SDL_AppInit(appstate: sdl3.LP_c_void_p, argc: ctypes.c_int, argv: sdl3.LP_c_char_p) -> sdl3.SDL_AppResult:
    args = sdl3.SDL_PARSE_ARGUMENTS(argc, argv)

    for i, arg in enumerate(args):
        sdl3.SDL_LOGGER.Log(sdl3.SDL_LOGGER.Info, f"Arg[{i}]: {arg}")
    
    return sdl3.SDL_APP_FAILURE

def SDL_AppEvent(appstate: ctypes.c_void_p, event: sdl3.LP_SDL_Event) -> sdl3.SDL_AppResult:
    ...

def SDL_AppIterate(appstate: ctypes.c_void_p) -> sdl3.SDL_AppResult:
    ...

def SDL_AppQuit(appstate: ctypes.c_void_p, result: sdl3.SDL_AppResult) -> None:
    ...

@Aermoss Aermoss merged commit d2509c7 into Aermoss:main Apr 9, 2025
16 of 20 checks passed
@Aermoss
Copy link
Owner

Aermoss commented Apr 9, 2025

Merged it, thanks!

@drakbar
Copy link
Contributor Author

drakbar commented Apr 9, 2025

@Aermoss Not a problem. Also awesome job on this repo. I look forward to the shader_cross additions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants