PHP code example of microscrap / vulkan-gfx

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


use Microscrap\GFX\Vulkan\VulkanHandledFramebuffer;
use Microscrap\GFX\Vulkan\VulkanRenderer2D;
use Microscrap\GFX\Vulkan\VulkanWindowHandler;
use ScrapyardIO\Tubes\Core\MagicAliases\Framebuffer;
use ScrapyardIO\Tubes\Core\MagicAliases\Window;
use ScrapyardIO\Tubes\HumanInput\EngineInput;

$buffer = Framebuffer::driver('vulkan')
    ->size(320, 240)
    ->format(VulkanHandledFramebuffer::rgbaSpec())
    ->create(); // DeferredFramebuffer — headless

$buffer->setPixel(10, 10, 0xFF0000FF);
$bytes = $buffer->flush(VulkanHandledFramebuffer::rgbaSpec());

$window = Window::driver('vulkan')->title('Demo')->size(800, 600)->open();
$fb = $window->framebuffer();
$gfx = (new VulkanRenderer2D)->setFramebuffer($fb);
$gfx->fill(0x141820FF)
    ->fillCircle(400, 300, 80, 0xF0A030FF)
    ->setTextColor(0xFFFFFFFF)
    ->setCursor(40, 40)
    ->print('Vulkan');

$handler = $window->handler();
$input = $handler instanceof VulkanWindowHandler
    ? new EngineInput($handler->inputHandler())
    : null;

$window->present()->pollEvents(); // also refreshes HumanInput devices
$mouse = $input?->mouse();
bash
php -m | grep vulkan
composer =tubes-framebuffers-vulkan
php workshop vendor:publish --tag=tubes-windows-vulkan
# or: php workshop install:gfx vulkan