PHP code example of microscrap / vulkan

1. Go to this page and download the library: Download microscrap/vulkan 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/ */

    

microscrap / vulkan example snippets


use Microscrap\Bindings\GLFW\Enums\ClientApi;
use Microscrap\Bindings\GLFW\Enums\TrueFalse;
use Microscrap\Bindings\GLFW\Enums\WindowHint;

glfwInit();
glfwWindowHint(WindowHint::GLFW_CLIENT_API, ClientApi::GLFW_NO_API->value);
$window = glfwCreateWindow(400, 600, 'vulkan');

$extensions = glfwGetRequiredInstanceExtensions();
$instance = vkCreateInstance($extensions, 'demo');
$created = vkCreateWindowSurface($instance, $window);
$surface = $created['surface'];

// ... enumerate devices, create device/queue/swapchain, presentFrame ...

vkDestroySurface($instance, $surface);
vkDestroyInstance($instance);
glfwDestroyWindow($window);
glfwTerminate();

use Microscrap\Bindings\Vulkan\Vk;

$instance = Vk::createInstance([], 'demo');
Vk::destroyInstance($instance);