UniversityOfGdanskTeamPython / pyglslang

Python wrapper around glslang GLSL optimizing compiler and validator.
0 stars 0 forks source link

Create API shader compilation with glslang #4

Closed Argmaster closed 9 months ago

Argmaster commented 10 months ago

Something like compile_shader(source: str, params: GlslangParams) should be sufficient. A good starting point would be glslang --help, afterterwards you could simply create dataclass with all necessary fields to reduce size of code that has to be generated. I imagine something along the lines of:

from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

@dataclass
class GlslangParams:
    """Glslang compiler command line parameters."""

    shader_source: str | Path | StringIO
    cascading_erros: bool = False
    is_hlsl: bool = False
    define_macros: Optional[dict[str, str]] = None
    ...