-
-
Save nawarian/319d363dacea2feebc409e5413d03887 to your computer and use it in GitHub Desktop.
PHP FFI nested struct bug
This file contains 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
<?php | |
$ffi = FFI::load(__DIR__ . '/raylib.h'); | |
$camera = $ffi->new('Camera2D'); | |
$ffi->InitWindow(800, 600, 'Nawarian'); | |
while (!$ffi->WindowShouldClose()) { | |
$ffi->BeginDrawing(); | |
$ffi->BeginMode2D($camera); | |
$ffi->EndMode2D(); | |
$ffi->EndDrawing(); | |
} | |
$ffi->CloseWindow(); |
This file contains 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
// .dylib is specific to MacOS, please replace with a .so or .dll if necessary | |
#define FFI_LIB "libraylib.dylib" | |
typedef struct Vector2 { | |
float x; | |
float y; | |
} Vector2; | |
typedef struct Camera2D { | |
Vector2 offset; | |
Vector2 target; | |
float rotation; | |
float zoom; | |
} Camera2D; | |
void InitWindow(int width, int height, const char *title); | |
bool WindowShouldClose(void); | |
void CloseWindow(void); | |
void BeginDrawing(void); | |
void EndDrawing(void); | |
void BeginMode2D(Camera2D camera); // <---- Buggy function | |
void EndMode2D(void); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment