Repository: ManimCommunity/manim
File: manim/renderer/shader.py (Python)

Code before:
                "vert": "vertex_shader",
                "frag": "fragment_shader",
                "geom": "geometry_shader",
            }
            assert name is not None
            shader_folder = SHADER_FOLDER / name
            for shader_file in shader_folder.iterdir():
                shader_file_path = shader_folder / shader_file
                shader_source = get_shader_code_from_file(shader_file_path)
                source_dict[source_dict_key[shader_file_path.stem]] = shader_source
            self.shader_program = context.program(**source_dict)

        # Cache the shader.
        if name is not None and name not in shader_program_cache:
            assert self.name is not None
            shader_program_cache[self.name] = self.shader_program

    def set_uniform(self, name: str, value: Any) -> None:
        with contextlib.suppress(KeyError):
            self.shader_program[name] = value


class FullScreenQuad(Mesh):
    def __init__(
        self,
        context: Context,
        fragment_shader_source: str | None = None,
        fragment_shader_name: str | None = None,
    ):
        if fragment_shader_source is None and fragment_shader_name is None:
            raise Exception("Must either pass shader name or shader source.")

        if fragment_shader_name is not None:
            # Use the name.
            shader_file_path = SHADER_FOLDER / f"{fragment_shader_name}.frag"
            fragment_shader_source = get_shader_code_from_file(shader_file_path)
        elif fragment_shader_source is not None:
            fragment_shader_source = textwrap.dedent(fragment_shader_source.lstrip())

        shader = Shader(
            context,
            source={
                "vertex_shader": """
                #version 330
                in vec4 in_vert;
                uniform mat4 u_model_view_matrix;
                uniform mat4 u_projection_matrix;
                void main() {{
                    vec4 camera_space_vertex = u_model_view_matrix * in_vert;
                    vec4 clip_space_vertex = u_projection_matrix * camera_space_vertex;
                    gl_Position = clip_space_vertex;

Review comment (suggestion):
```suggestion
        context: moderngl.Context,
```

Code after:
        if (
            self.name in shader_program_cache
            and shader_program_cache[self.name].ctx == self.context
        ):
            self.shader_program = shader_program_cache[self.name]
        elif self.source is not None:
            # Generate the shader from inline code if it was passed.
            self.shader_program = context.program(**self.source)
        elif self.name is not None:
            # Search for a file containing the shader.
            source_dict = {}
            source_dict_key = {
                "vert": "vertex_shader",
                "frag": "fragment_shader",
                "geom": "geometry_shader",
            }
            shader_folder = SHADER_FOLDER / self.name
            for shader_file in shader_folder.iterdir():
                shader_file_path = shader_folder / shader_file
                shader_source = get_shader_code_from_file(shader_file_path)
                source_dict[source_dict_key[shader_file_path.stem]] = shader_source
            self.shader_program = context.program(**source_dict)
        else:
            raise Exception("Must either pass shader name or shader source.")

        # Cache the shader.
        if self.name is not None and self.name not in shader_program_cache:
            shader_program_cache[self.name] = self.shader_program

    def set_uniform(self, name: str, value: Any) -> None:
        with contextlib.suppress(KeyError):
            self.shader_program[name] = value


class FullScreenQuad(Mesh):
    def __init__(
        self,
        context: moderngl.Context,
        fragment_shader_source: str | None = None,
        fragment_shader_name: str | None = None,
    ):
        if fragment_shader_source is None and fragment_shader_name is None:
            raise Exception("Must either pass shader name or shader source.")

        if fragment_shader_name is not None:
            # Use the name.
            shader_file_path = SHADER_FOLDER / f"{fragment_shader_name}.frag"
            fragment_shader_source = get_shader_code_from_file(shader_file_path)
        elif fragment_shader_source is not None:
            fragment_shader_source = textwrap.dedent(fragment_shader_source.lstrip())