Skip to content

API: Turn flags field of render::RendererInfo into a proper bitflags struct #1054

Open
@LunarLambda

Description

@LunarLambda

Currently only a raw u32 is given.

SDL2 defines RendererFlags as follows (Source):

enum SDL_RendererFlags {
    SDL_RENDERER_SOFTWARE = 1,
    SDL_RENDERER_ACCELERATED = 2,
    SDL_RENDERER_PRESENTVSYNC = 4,
    SDL_RENDERER_TARGETTEXTURE = 8,
};

The equivalent bitflags type would be:

bitflags! {
    struct RendererFlags: u32 {
        const SOFTWARE = 1;
        const ACCELERATED = 2;
        const PRESENT_VSYNC = 4;
        const TARGET_TEXTURE = 8;
    }
}

Changes needed would be in the definition of RendererInfo and in RendererInfo::from_ll.

On the topic of RendererInfo, it seems max_texture_height and max_texture_width are reported as 0 when the driver does not give a limit. Should Option<u32> or Option<NonZeroU32> be used?

We could avoid an immediate breaking change today by instead giving RendererInfo proper accessors name(), flags(), etc. and deprecating raw field access (and eventually making them private altogether)

I would be happy to open a PR for this change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions