Last active
January 22, 2021 22:57
-
-
Save timsneath/983764458690f89a5c8231b4ff2e2e64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// struct XrApplicationInfo { | |
// char applicationName[128]; // 128 bytes | |
// uint32_t applicationVersion; // 4 bytes | |
// char engineName[128]; // 128 bytes | |
// uint32_t engineVersion; // 4 bytes | |
// XrVersion apiVersion; // assume this is a uint64_t, i.e. 8 bytes | |
// }; | |
class XrApplicationInfo extends Struct { | |
Pointer<Utf8> get applicationName => addressOf.cast<Utf8>(); | |
int get ApplicationVersion => | |
addressOf.cast<Uint8>().elementAt(128).cast<Uint32>().value; | |
Pointer<Utf8> get engineName => addressOf.cast<Utf8>().elementAt(128 + 4); | |
int get engineVersion => | |
addressOf.cast<Uint8>().elementAt(128 + 4 + 128).cast<Uint32>().value; | |
int get apiVersion => | |
addressOf.cast<Uint8>().elementAt(128 + 4 + 128 + 4).cast<Uint64>().value; | |
factory XrApplicationInfo.allocate() { | |
final structSize = 128 + 4 + 128 + 4 + 8; | |
final ptr = allocate<Uint8>(count: structSize); | |
for (var idx = 0; idx < structSize; idx++) { | |
ptr.elementAt(idx).value = 0; | |
} | |
return ptr.cast<XrApplicationInfo>().ref; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment