MCPcopy Create free account
hub / github.com/crownengine/crown / bind

Method bind

src/world/material.cpp:25–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void Material::bind(u8 view, u32 depth) const
26{
27 using namespace material_resource;
28
29 // Set samplers.
30 const TextureData *td = texture_data_array(_resource);
31 for (u32 i = 0; i < _resource->num_textures; ++i) {
32 const TextureHandle *th = texture_handle(td, i, _data);
33
34 bgfx::UniformHandle sampler;
35 bgfx::TextureHandle texture;
36 sampler.idx = th->sampler_handle;
37 texture.idx = th->texture_handle;
38
39 for (u32 si = 0; si < _shader.num_samplers; ++si) {
40 if (_shader.samplers[si].name == td[i].name._id) {
41 bgfx::setTexture(_shader.samplers[si].stage
42 , sampler
43 , texture
44 , _shader.samplers[si].state
45 );
46 break;
47 }
48 }
49 }
50
51 // Set uniforms.
52 const UniformData *ud = uniform_data_array(_resource);
53 for (u32 i = 0; i < _resource->num_uniforms; ++i) {
54 const UniformHandle *uh = uniform_handle(ud, i, _data);
55
56 bgfx::UniformHandle buh;
57 buh.idx = uh->uniform_handle;
58 bgfx::setUniform(buh, (char *)uh + sizeof(uh->uniform_handle));
59 }
60
61 bgfx::setState(_shader.state | BGFX_STATE_MSAA);
62 bgfx::setStencil(_shader.stencil_front, _shader.stencil_back);
63 bgfx::submit(view, _shader.program, depth);
64}
65
66template<typename T>
67static void set_uniform_value(StringId32 name, const T &value, const MaterialResource *mr, char *dynamic_data)

Callers 7

submit_with_materialMethod · 0.45
draw_meshFunction · 0.45
renderMethod · 0.45
bind_auto_portFunction · 0.45
listenMethod · 0.45
badge_only.jsFile · 0.45
theme.jsFile · 0.45

Calls 5

setTextureFunction · 0.50
setUniformFunction · 0.50
setStateFunction · 0.50
setStencilFunction · 0.50
submitFunction · 0.50

Tested by

no test coverage detected