Have shader_info remember its own id

This commit is contained in:
Grant Sanderson 2020-06-15 11:59:24 -07:00
parent 9d772496dd
commit 1e6eef89ec

View file

@ -46,22 +46,19 @@ def get_shader_info(data=None,
depth_test=False, depth_test=False,
render_primative=moderngl.TRIANGLE_STRIP, render_primative=moderngl.TRIANGLE_STRIP,
): ):
return { result = {
key: value "data": data,
for key, value in zip( "vert": vert_file,
SHADER_INFO_KEYS, "geom": geom_file,
[ "frag": frag_file,
data, "uniforms": uniforms or dict(),
vert_file, "texture_paths": texture_paths or dict(),
geom_file, "depth_test": depth_test,
frag_file, "render_primative": str(render_primative),
uniforms or dict(),
texture_paths or dict(),
depth_test,
str(render_primative)
]
)
} }
# A unique id for a shader
result["id"] = "|".join([str(result[key]) for key in SHADER_KEYS_FOR_ID])
return result
def is_valid_shader_info(shader_info): def is_valid_shader_info(shader_info):
@ -75,7 +72,7 @@ def is_valid_shader_info(shader_info):
def shader_info_to_id(shader_info): def shader_info_to_id(shader_info):
# A unique id for a shader # A unique id for a shader
return "|".join([str(shader_info[key]) for key in SHADER_KEYS_FOR_ID]) return shader_info["id"]
def same_shader_type(info1, info2): def same_shader_type(info1, info2):