Skip to content

File: ShaderFlow/Variable.py

ShaderFlow.Variable

GlslQualifier

GlslQualifier = Literal['uniform', 'attribute', 'varying']

GlslType

GlslType = Literal[
    "sampler2D",
    "float",
    "int",
    "bool",
    "vec2",
    "vec3",
    "vec4",
    "mat2",
    "mat3",
    "mat4",
]

GlslDirection

GlslDirection = Literal['in', 'out']

GlslInterpolation

GlslInterpolation = Literal[
    "flat", "smooth", "noperspective"
]

DECLARATION_ORDER

DECLARATION_ORDER = (
    "interpolation",
    "direction",
    "qualifier",
    "type",
    "name",
)

ShaderVariable

Bases: BrokenFluent

Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@define(eq=False, slots=True)
class ShaderVariable(BrokenFluent):
    type: GlslType
    name: str
    value: Optional[Any] = None
    qualifier: Optional[GlslQualifier] = None
    direction: Optional[GlslDirection] = None
    interpolation: Optional[GlslInterpolation] = None

    def __hash__(self) -> int:
        return hash(self.name)

    def __eq__(self, other: Self) -> bool:
        return (self.name == other.name)

    @property
    def size_string(self) -> str:
        return dict(
            float="f",
            int="i",
            bool="i",
            vec2="2f",
            vec3="3f",
            vec4="4f",
        ).get(self.type)

    @property
    def declaration(self) -> str:
        parts = (getattr(self, key, None) for key in DECLARATION_ORDER)
        return " ".join(filter(None, parts)).strip() + ";"

type

type: GlslType

name

name: str

value

value: Optional[Any] = None

qualifier

qualifier: Optional[GlslQualifier] = None

direction

direction: Optional[GlslDirection] = None

interpolation

interpolation: Optional[GlslInterpolation] = None

__hash__

__hash__() -> int
Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
56
57
def __hash__(self) -> int:
    return hash(self.name)

__eq__

__eq__(other: Self) -> bool
Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
59
60
def __eq__(self, other: Self) -> bool:
    return (self.name == other.name)

size_string

size_string: str

declaration

declaration: str

Uniform

Bases: ShaderVariable

Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
80
81
82
@define(eq=False, slots=True)
class Uniform(ShaderVariable):
    qualifier: GlslQualifier = "uniform"

qualifier

qualifier: GlslQualifier = 'uniform'

InVariable

Bases: ShaderVariable

Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
84
85
86
@define(eq=False, slots=True)
class InVariable(ShaderVariable):
    direction: GlslDirection = "in"

direction

direction: GlslDirection = 'in'

OutVariable

Bases: ShaderVariable

Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
88
89
90
@define(eq=False, slots=True)
class OutVariable(ShaderVariable):
    direction: GlslDirection = "out"

direction

direction: GlslDirection = 'out'

FlatVariable

Bases: ShaderVariable

Source code in Projects/ShaderFlow/ShaderFlow/Variable.py
92
93
94
@define(eq=False, slots=True)
class FlatVariable(ShaderVariable):
    interpolation: GlslInterpolation = "flat"

interpolation

interpolation: GlslInterpolation = 'flat'