Skip to main content

SDL_CreateRenderer

Function SDL_CreateRenderer 

Source
pub unsafe extern "C" fn SDL_CreateRenderer(
    window: *mut SDL_Window,
    name: *const c_char,
) -> *mut SDL_Renderer
Expand description

Create a 2D rendering context for a window.

If you want a specific renderer, you can specify its name here. A list of available renderers can be obtained by calling SDL_GetRenderDriver() multiple times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you don’t need a specific renderer, specify NULL and SDL will attempt to choose the best option for you, based on what is available on the user’s system.

If name is a comma-separated list, SDL will try each name, in the order listed, until one succeeds or all of them fail.

By default the rendering size matches the window size in pixels, but you can call SDL_SetRenderLogicalPresentation() to change the content size and scaling options.

Parameter: window the window where rendering is displayed. Parameter: name the name of the rendering driver to initialize, or NULL to let SDL choose one. Returns: a valid rendering context or NULL if there was an error; call SDL_GetError() for more information.

Thread Safety: This function should only be called on the main thread.

Available Since: This function is available since SDL 3.2.0.

See Also: SDL_CreateRendererWithProperties See Also: SDL_CreateSoftwareRenderer See Also: SDL_DestroyRenderer See Also: SDL_GetNumRenderDrivers See Also: SDL_GetRenderDriver See Also: SDL_GetRendererName