PHP code example of php-io-extensions / glfw

1. Go to this page and download the library: Download php-io-extensions/glfw library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

php-io-extensions / glfw example snippets


glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);           // Metal, Vulkan or a CPU blit draws it
$window = glfwCreateWindow(1280, 720, 'Game');
glfwSetWindowSizeLimits($window, 640, 360, GLFW_DONT_CARE, GLFW_DONT_CARE);
glfwSetWindowAspectRatio($window, 16, 9);
glfwSetFramebufferSizeCallback($window, function (GLFWwindow $w, int $width, int $height): void {
    // resize the swapchain to the pixels
});

// Exclusive full screen in the monitor's current mode, and back to a window.
$monitor = glfwGetPrimaryMonitor();
$mode = glfwGetVideoMode($monitor);
glfwSetWindowMonitor($window, $monitor, 0, 0, $mode->width, $mode->height, $mode->refreshRate);
glfwSetWindowMonitor($window, null, 100, 100, 1280, 720, GLFW_DONT_CARE);

// Borderless, always on top, click-through.
glfwSetWindowAttrib($window, GLFW_DECORATED, GLFW_FALSE);
glfwSetWindowAttrib($window, GLFW_FLOATING, GLFW_TRUE);
glfwSetWindowAttrib($window, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE);

while (! glfwWindowShouldClose($window)) {
    glfwWaitEventsTimeout(1 / 60);
}
glfwDestroyWindow($window);
glfwTerminate();

$result = glfwCreateWindowSurface($instance->pointer(), $window, 0, $surface);
$vkSurface = VkSurfaceKHR::fromPointer($surface);
bash
./install-macos.sh              # Homebrew [email protected] and [email protected]
./install-debian-trixie.sh      # Debian trixie / Raspberry Pi OS
bash
composer install
php -d memory_limit=128M vendor/bin/pest