-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
version.go
86 lines (70 loc) · 2.23 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package sdl
/*
#include "sdl_wrapper.h"
#if SDL_VERSION_ATLEAST(2,0,16)
static inline int GetRevisionNumber(void)
{
return 0;
}
#else
static inline int GetRevisionNumber(void)
{
return SDL_GetRevisionNumber();
}
#endif
*/
import "C"
import "unsafe"
// The version of SDL in use.
const (
MAJOR_VERSION = C.SDL_MAJOR_VERSION // major version
MINOR_VERSION = C.SDL_MINOR_VERSION // minor version
PATCHLEVEL = C.SDL_PATCHLEVEL // update version (patchlevel)
)
// Version contains information about the version of SDL in use.
// (https://wiki.libsdl.org/SDL_version)
type Version struct {
Major uint8 // major version
Minor uint8 // minor version
Patch uint8 // update version (patchlevel)
}
type cVersion C.SDL_version
func (v *Version) cptr() *C.SDL_version {
return (*C.SDL_version)(unsafe.Pointer(v))
}
// VERSION fills the selected struct with the version of SDL in use.
// (https://wiki.libsdl.org/SDL_VERSION)
func VERSION(v *Version) {
v.Major = MAJOR_VERSION
v.Minor = MINOR_VERSION
v.Patch = PATCHLEVEL
}
// VERSIONNUM converts separate version components into a single numeric value.
// (https://wiki.libsdl.org/SDL_VERSIONNUM)
func VERSIONNUM(x, y, z int) int {
return (x*1000 + y*100 + z)
}
// COMPILEDVERSION returns the SDL version number that you compiled against.
// (https://wiki.libsdl.org/SDL_COMPILEDVERSION)
func COMPILEDVERSION() int {
return VERSIONNUM(MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL)
}
// VERSION_ATLEAST reports whether the SDL version compiled against is at least as new as the specified version.
// (https://wiki.libsdl.org/SDL_VERSION_ATLEAST)
func VERSION_ATLEAST(x, y, z int) bool {
return COMPILEDVERSION() >= VERSIONNUM(x, y, z)
}
// GetVersion returns the version of SDL that is linked against your program.
// (https://wiki.libsdl.org/SDL_GetVersion)
func GetVersion(v *Version) {
C.SDL_GetVersion(v.cptr())
}
// GetRevision returns the code revision of SDL that is linked against your program.
// (https://wiki.libsdl.org/SDL_GetRevision)
func GetRevision() string {
return (string)(C.GoString(C.SDL_GetRevision()))
}
// Deprecated: GetRevisionNumber is deprecated in SDL2 2.0.16 and will return 0. Users should use GetRevision instead.
func GetRevisionNumber() int {
return (int)(C.GetRevisionNumber())
}