You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
/** @noinspection PhpUnused */
|
|
|
|
namespace Cijber\GraphicsToolkit;
|
|
|
|
use Cijber\GraphicsToolkit\Consts\GLFWConsts;
|
|
use FFI;
|
|
|
|
|
|
/**
|
|
* @method static void windowHint(int $hint, int $hintValue)
|
|
* @method static FFI\CData createWindow(int $width, int $height, string $title, $window, $screen)
|
|
* @method static void makeContextCurrent($window)
|
|
* @method static int windowShouldClose($window)
|
|
* @method static void swapBuffers($window)
|
|
* @method static void pollEvents()
|
|
* @method static void terminate()
|
|
* @method static int setWindowShouldClose(FFI\CData $window, int $shouldClose)
|
|
* @method static int getKey(FFI\CData $window, int $key)
|
|
* @method static void setFramebufferSizeCallback(FFI\CData $window, \Closure $callback)
|
|
*/
|
|
class GLFW extends GLFWConsts
|
|
{
|
|
private static FFI $ffi;
|
|
private static bool $started = false;
|
|
|
|
static function init()
|
|
{
|
|
if (static::$started) {
|
|
return;
|
|
}
|
|
|
|
static::$ffi = FFI::load(__DIR__."/../headers/glfw.h");
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
static::$ffi->glfwInit();
|
|
static::$started = true;
|
|
}
|
|
|
|
static function __callStatic($name, $arguments)
|
|
{
|
|
return static::$ffi->{"glfw".ucfirst($name)}(...$arguments);
|
|
}
|
|
} |