On Monday, 6 June 2016 at 21:09:41 UTC, Alex Parrill wrote:
On Monday, 6 June 2016 at 20:40:12 UTC, Begah wrote:
I have a pretty weird error : Error: mutable method
isolated.graphics.g3d.model.Model.begin is not callable using
a const object
[...]
It may infer const from the type of `this.instance`, which may
be further modified if the method you are running this in is
`const`. If you explicitly specify the type of the foreach loop
variables, does it work?
Seems that it does :
ModelInstance[][ModelType] instances;
void render() {
checkError();
shader.bind();
camera.update();
shader.uniform("uView", camera.viewMatrix);
shader.uniform("uProjection", camera.projectionMatrix);
foreach(ref ModelType model, ref instances; this.instances) {
model.begin();
foreach(instance; instances) {
instance.render();
}
model.end();
}
shader.unbind();
checkError();
}
Adding the type to the loop gives me the error : index must be
type const(Handle), not Handle.
So why does it think that from the associative array that
ModelType should be const?
Does the key of a associative array will be const if the
reference is requested?