Skip to main content

A simple window with your own main loop.

Project description

glwindow

pip install glwindow

A simple window with your own main loop.

Examples

import glwindow

window = glwindow.window()

while window.visible:
    glwindow.update()

Multiple Windows

import glwindow

windows = [
    glwindow.window((640, 480)),
    glwindow.window((640, 480)),
    glwindow.window((640, 480)),
]

while any(x.visible for x in windows):
    glwindow.update()

Keyboard Input

import glwindow

window = glwindow.window()

while window.visible:
    glwindow.update()
    if window.key_pressed('escape'):
        break

Vulkan Surface

import glnext
import glwindow
from glnext_compiler import glsl

instance = glnext.instance(surface=True)
task = instance.task()

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

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

        layout (location = 0) out vec4 out_color;

        vec2 positions[3] = vec2[](
            vec2(-0.5, -0.5),
            vec2(0.5, -0.5),
            vec2(0.0, 0.5)
        );

        vec4 colors[3] = vec4[](
            vec4(1.0, 0.0, 0.0, 1.0),
            vec4(0.0, 1.0, 0.0, 1.0),
            vec4(0.0, 0.0, 1.0, 1.0)
        );

        void main() {
            gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
            out_color = colors[gl_VertexIndex];
            gl_Position.y *= -1.0;
        }
    '''),
    fragment_shader=glsl('''
        #version 450
        #pragma shader_stage(fragment)

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

        void main() {
            out_color = in_color;
        }
    '''),
    vertex_count=3,
)

wnd = glwindow.window(size, title='Hello World!')

instance.surface(wnd.handle, framebuffer.output[0])

while wnd.visible:
    glwindow.update()
    task.run()
    instance.present()

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

glwindow-4.2.0.tar.gz (8.0 kB view hashes)

Uploaded source

Built Distributions

glwindow-4.2.0-cp39-cp39-win_amd64.whl (11.8 kB view hashes)

Uploaded cp39

glwindow-4.2.0-cp38-cp38-win_amd64.whl (11.9 kB view hashes)

Uploaded cp38

glwindow-4.2.0-cp37-cp37m-win_amd64.whl (11.7 kB view hashes)

Uploaded cp37

glwindow-4.2.0-cp36-cp36m-win_amd64.whl (11.7 kB view hashes)

Uploaded cp36

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page