Skip to main content

No project description provided

Project description

glnext

High-Performance offscreen rendering for python.

pip install glnext

Examples

import glnext
from glnext_compiler import glsl
from PIL import Image

instance = glnext.instance()
task = instance.task()

framebuffer = task.framebuffer((512, 512))

pipeline = framebuffer.render(
    vertex_shader=glsl('''
        #version 450
        #pragma shader_stage(vertex)

        layout (location = 0) in vec2 in_vert;
        layout (location = 1) in vec3 in_color;

        layout (location = 0) out vec3 out_color;

        void main() {
            gl_Position = vec4(in_vert, 0.0, 1.0);
            out_color = in_color;
        }
    '''),
    fragment_shader=glsl('''
        #version 450
        #pragma shader_stage(fragment)

        layout (location = 0) in vec3 in_color;
        layout (location = 0) out vec4 out_color;

        void main() {
            out_color = vec4(in_color, 1.0);
        }
    '''),
    vertex_format='2f 3f',
    vertex_count=3,
)

pipeline.update(
    vertex_buffer=glnext.pack([
        -0.5, -0.5, 0.0, 0.0, 1.0,
        0.5, -0.5, 0.0, 1.0, 0.0,
        0.0, 0.5, 1.0, 0.0, 0.0,
    ])
)

task.run()
data = framebuffer.output[0].read()
img = Image.frombuffer('RGBA', (512, 512), data)
img.save('hello_world.png')

Windows

With up2date drivers the vulkan runtime binaries should already be on your system. Install the vulkan-sdk if needed.

Linux

Install the vulkan-sdk.

apt-get install libx11-dev

Without GPU

This project is compatible with swiftshader. The CI also runs on pure CPU. (Dockerfile)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glnext-0.8.1.tar.gz (113.9 kB view hashes)

Uploaded Source

Built Distributions

glnext-0.8.1-cp39-cp39-win_amd64.whl (37.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

glnext-0.8.1-cp39-cp39-manylinux1_x86_64.whl (162.0 kB view hashes)

Uploaded CPython 3.9

glnext-0.8.1-cp38-cp38-win_amd64.whl (37.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

glnext-0.8.1-cp38-cp38-manylinux1_x86_64.whl (162.1 kB view hashes)

Uploaded CPython 3.8

glnext-0.8.1-cp37-cp37m-win_amd64.whl (37.5 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

glnext-0.8.1-cp37-cp37m-manylinux1_x86_64.whl (161.3 kB view hashes)

Uploaded CPython 3.7m

glnext-0.8.1-cp36-cp36m-win_amd64.whl (37.5 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

glnext-0.8.1-cp36-cp36m-manylinux1_x86_64.whl (160.4 kB view hashes)

Uploaded CPython 3.6m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page