Skip to main content

shadertest

A Python library for unit testing GLSL functions

Example

Below we have a very simple fragment shader called add.frag.

#version 330

out vec4 outColor;

float add(float a, float b) {
    return a + b;
}
void main() {
	outColor = vec4(add(0.5, 0.5));
}

To test using shadertest, we just need to create a ShaderContext, and start calling functions from the shader.

import pytest

import shadertest


@pytest.fixture(scope='module')
def basic_shader():
    with shadertest.ShaderContext.from_file('add.frag') as funcs:
        yield funcs


def test_add(basic_shader):
    assert basic_shader.add(4, 2) == 6

Supported data types

The following data types are supported for return values and function arguments:

  • bool
  • int
  • uint
  • float
  • bvecn
  • ivecn
  • vecn

For more information about GLSL data types, checkout the Khronos wiki page on them.

Release files for shadertest 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shadertest 0.2.1
File Size Uploaded
shadertest-0.2.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shadertest 0.2.1
File Interpreter ABI Platform
shadertest-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / shadertest-0.2.1.tar.gz

Download URL shadertest-0.2.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
37a31872ab39dc751e51f4bfca306d999b41622841352a7f34c20ff8182240ab
BLAKE2b-256 checksum
How to use checksums
6029f10479de8693834f053520eca61f03972588c743345af9deb88785fd1d09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / shadertest-0.2.1-py3-none-any.whl

Download URL shadertest-0.2.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46fa227e1fb97308f2e960d0449e3bd6f4bc969ae9f4816b4e612852f95fb9d8
BLAKE2b-256 checksum
How to use checksums
7963bf20be15f741faa843249a35d7b762903b7203ced13077bd8acb2d08984f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page