pub fn load_shader(
    draw: &mut DrawContext,
    graphics: &Graphics<Vertex>,
    name: impl Into<Cow<'static, str>>,
    vertex: &str,
    fragment: &str
)
Examples found in repository?
examples/pcg_island.rs (lines 122-128)
119
120
121
122
123
124
125
126
127
128
129
    fn enter(&mut self, context: GameContext) {
        context.graphics.main_camera.scaling = CameraScaling::FitVertical(SIZE as f32 * 10.0);

        load_shader(
            context.draw,
            context.graphics,
            "color",
            Shader::COLORED_VERTEX_2D,
            Shader::PASS_FRAGMENT,
        );
    }
More examples
Hide additional examples
examples/hello_world.rs (lines 43-49)
37
38
39
40
41
42
43
44
45
46
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
77
78
79
80
81
    fn enter(&mut self, context: GameContext) {
        context.graphics.color = [0.2, 0.2, 0.2];
        context.graphics.main_camera.screen_alignment = 0.5.into();
        context.graphics.main_camera.scaling = CameraScaling::FitVertical(500.0);
        context.gui.coords_map_scaling = CoordsMappingScaling::FitVertical(500.0);

        load_shader(
            context.draw,
            context.graphics,
            "color",
            Shader::COLORED_VERTEX_2D,
            Shader::PASS_FRAGMENT,
        );
        load_shader(
            context.draw,
            context.graphics,
            "image",
            Shader::TEXTURED_VERTEX_2D,
            Shader::TEXTURED_FRAGMENT,
        );
        load_shader(
            context.draw,
            context.graphics,
            "text",
            Shader::TEXT_VERTEX,
            Shader::TEXT_FRAGMENT,
        );

        load_texture(
            context.draw,
            context.graphics,
            "ferris",
            load_asset!("./resources/ferris.png"),
            1,
            1,
        );

        load_font(
            context.draw,
            "roboto",
            load_asset!("./resources/Roboto-Regular.ttf"),
        );

        *context.state_change = GameStateChange::Swap(Box::new(State::default()));
    }