rig_picker/constants.py

30 lines
706 B
Python
Raw Permalink Normal View History

2024-02-26 11:26:49 +01:00
import gpu
from pathlib import Path
2022-04-06 10:12:32 +02:00
2024-02-26 11:26:49 +01:00
class LazyDict(dict):
def __getitem__(self, k):
v = super().__getitem__(k)
if callable(v):
v = v()
super().__setitem__(k, v)
return v
def get(self, k, default=None):
if k in self:
return self.__getitem__(k)
return default
PICKERS = {}
MODULE_DIR = Path(__file__).parent
SHADER_DIR = MODULE_DIR / 'shaders'
SHADERS = LazyDict()
vertex_shader = Path(SHADER_DIR, "dash_shader.vert").read_text(encoding='utf-8')
fragment_shader = Path(SHADER_DIR, "dash_shader.frag").read_text(encoding='utf-8')
SHADERS['dashed_line'] = lambda : gpu.types.GPUShader(vertex_shader, fragment_shader)