The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SDL2::version - Information About the Version of SDL in Use

SYNOPSIS

    use SDL2 qw[:version];
    SDL_GetVersion( my $ver = SDL2::version->new );
    CORE::say sprintf 'SDL version %d.%d.%d', $ver->major, $ver->minor, $ver->patch;

DESCRIPTION

SDL2::version represents the library's version as three levels: major, minor, and patch level.

Functions

These may be imported with the <:version> tag.

SDL_VERSION( ... )

Macro to determine SDL version program was compiled against.

This macro fills in a SDL_version structure with the version of the library you compiled against. This is determined by what header the compiler uses. Note that if you dynamically linked the library, you might have a slightly newer or older version at runtime. That version can be determined with SDL_GetVersion(), which, unlike SDL_VERSION(), is not a macro.

Expected parameters include:

x - a pointer to a SDL2::Version struct to initialize

SDL_VERSIONNUM( ... )

This macro turns the version numbers into a numeric value:

    (1,2,3) -> (1203)

This assumes that there will never be more than 100 patchlevels.

Expected parameters include:

major
minor
patch

Returns an integer.

SDL_VERSION_ATLEAST( ... )

Evaluates to true if compiled with SDL at least major.minor.patch.

        if ( SDL_VERSION_ATLEAST( 2, 0, 15 ) ) {
                # Some feature that requires 2.0.15+
        }

Expected parameters include:

major
minor
patch

Returns a boolean value.

GetVersion( ... )

Get the version of SDL that is linked against your program.

        SDL_GetVersion( my $version_ = SDL2::Version->new() );

If you are linking to SDL dynamically, then it is possible that the current version will be different than the version you compiled against. This function returns the current version, while SDL_VERSION( ... ) is a macro that tells you what version you compiled with.

This function may be called safely at any time, even before SDL_Init( ... ).

Expected parameters include:

ver - the SDL2::Version structure that contains the version information

SDL_GetRevision( )

Get the code revision of SDL that is linked against your program.

This value is the revision of the code you are linked with and may be different from the code you are compiling with, which is found in the upstream constant SDL_REVISION.

The revision is arbitrary string (a hash value) uniquely identifying the exact revision of the SDL library in use, and is only useful in comparing against other revisions. It is NOT an incrementing number.

If SDL wasn't built from a git repository with the appropriate tools, this will return an empty string.

Prior to SDL 2.0.16, before development moved to GitHub, this returned a hash for a Mercurial repository.

You shouldn't use this function for anything but logging it for debugging purposes. The string is not intended to be reliable in any way.

Returns an arbitrary string, uniquely identifying the exact revision of the SDL library in use.

Defined Values

These may be imported with the <:version> tag.

SDL_MAJOR_VERSION
SDL_MINOR_VERSION
SDL_PATCHLEVEL
SDL_COMPILEDVERSION - Version number for the current SDL version

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.

AUTHOR

Sanko Robinson <sanko@cpan.org>