]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/renderer.cpp
Support binding individual mipmap levels of textures
[libs/gl.git] / source / render / renderer.cpp
index 5262d09a90ee2862e6c0db07dcd02e71044241fd..946f0100bbbf0a5467877e451343d643a0f13670 100644 (file)
@@ -139,6 +139,11 @@ void Renderer::add_shader_data(const ProgramData &d)
 }
 
 void Renderer::set_texture(Tag tag, const Texture *tex, const Sampler *samp)
+{
+       set_texture(tag, tex, -1, samp);
+}
+
+void Renderer::set_texture(Tag tag, const Texture *tex, int level, const Sampler *samp)
 {
        State &state = get_state();
 
@@ -170,6 +175,7 @@ void Renderer::set_texture(Tag tag, const Texture *tex, const Sampler *samp)
        bound_tex.tag = tag;
        bound_tex.texture = tex;
        bound_tex.sampler = samp;
+       bound_tex.level = level;
        state.texture_count = texture_stack.size();
 }
 
@@ -344,7 +350,7 @@ void Renderer::apply_state()
                        if(t.binding<0 || shprog_changed)
                                t.binding = state.shprog->get_uniform_binding(t.tag);
                        if(t.binding>=0)
-                               pipeline_state.set_texture(t.binding, t.texture, t.sampler);
+                               pipeline_state.set_texture(t.binding, t.texture, t.level, t.sampler);
                }
 
        pipeline_state.set_depth_test(state.depth_test);