Search by

jovian / venusian-opengl

projectsaturnstudios

The 'opengl' GPU driver for Venusian topside: a device for each OpenGL context, the driver's own with no window or one lent with its window, its textures, buffers, shaders, pipelines and passes, through ext-opengl.

Package info

github.com/jovian-packages/venusian-ogx

Homepage

Issues

Language:GLSL

pkg:composer/jovian/venusian-opengl

Statistics

Installs: 20

Dependents: 0

Suggesters: 1

Stars: 0

v0.11.0 2026-11-08 15:30 UTC

This package is auto-updated.

Last update: 2026-12-03 06:17:59 UTC


README

The opengl GPU driver for Venusian topside: a device for each OpenGL context, the driver's own with no window or one lent with its window, its textures, buffers, shaders, pipelines and passes, through ext-opengl.

Requirements

  • PHP 8.4 and ext-opengl ^0.11.0. On macOS the driver's own context is CGL with OpenGL 4.1 core; on Linux it is EGL with OpenGL ES 3.0 on a surfaceless display.
  • The test suite also needs ext-posi, and the package does not. ext-posi writes the memory a test hands over as an address and reads the pixels read() answers; it is in require-dev and suggest, never require. A test that needs it is skipped where it is not loaded.

Install

composer require jovian/venusian-opengl

The provider is discovered through extra.venusian.providers and registers the opengl driver with topside's GPU component.

Usage

With GPU_DRIVER=opengl, topside's Gpu gives a device on a context of the driver's own, with no window:

use Surface\Gpu\Gpu;
use Surface\Gpu\PassSpec;
use Surface\Gpu\TextureSpec;
use Surface\NutsAndBolts\Color;
use Surface\NutsAndBolts\FormatSpec;
use Surface\Contracts\Gpu\TextureUse;
use Surface\Contracts\Gpu\TextureFormat;

$device = Gpu::device();
$texture = $device->texture(new TextureSpec(320, 240, TextureFormat::RGBA8, [TextureUse::TARGET]));

$commands = $device->commands();
$commands->render(new PassSpec($texture, clear: new Color(1.0, 0.5, 0.0, 1.0)))->end();
$commands->submit();

$memory = $device->read($texture, FormatSpec::rgba8Premultiplied());   // a PixelMemory, top row first

A shader is handed over in GLSL, named glsl on macOS (#version 410 core) and essl on Linux (#version 300 es); its entry point is main. Every vertex stage ends by negating gl_Position.y, which makes a target's first row its top, as on the other drivers:

gl_Position.y = -gl_Position.y;
What a shader binds Its name in GLSL
texture slot n of the vertex stage, with its sampler uniform sampler2D vertex_texture_n;
texture slot n of the fragment stage, with its sampler uniform sampler2D fragment_texture_n;
uniform-block slot n of the vertex stage layout(std140) uniform vertex_uniforms_n { ... };
uniform-block slot n of the fragment stage layout(std140) uniform fragment_uniforms_n { ... };
vertex attribute at location n layout(location = n) in ...;

Gpu::target($context) answers the target for a context a window's owner lends while it is current: a CGLContextObj on macOS, an EGLContext on Linux. Its device is a device on that context, and the same target is answered for the same context while it lives. On Linux present() copies what fits of the texture into the window, its first row at the window's top, and swaps. On macOS no call ext-opengl binds answers a lent context's drawable size, so present() answers false when the context has no image and otherwise throws a GpuException naming that question.

Earlier code

The package's earlier engines and their shaders and tests are kept in deprecated/, deprecated2/ and deprecated3/. None is autoloaded or run.

Security

See SECURITY.md.

License

MIT. See LICENSE.