Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object
Begah via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 6 13:40:12 PDT 2016
I have a pretty weird error : Error: mutable method
isolated.graphics.g3d.model.Model.begin is not callable using a
const object
The weird part is that i do not use const or immutable objects in
my code ( for the Model ) :
struct Handle {
Model *asset = null;
string asset_name = null;
alias asset this;
@property bool initialized() {
return asset !is null;
}
this(this) {
(*referenceCount)++;
}
~this() {
(*referenceCount)--;
}
size_t *referenceCount;
}
This structure is where the reference is kept ( allocated with
c's malloc )
Then in my code, i have a loop as such :
ModelInstance[][Handle] instances;
foreach(ref model, ref instances; this.instances) {
model.begin();
foreach(instance; instances) {
instance.render();
}
model.end();
}
But for both model.begin or model.end i get that compilation
error.
As you can see, i am calling model.begin ( which extends to
model.asset.begin ) but no const instances are used.
Side note :
When i remove the ref in the for loop :
foreach(model, ref instances; this.instances)
The codes compile and work, i don't understand why being a
reference or not is a problem.
More information about the Digitalmars-d-learn
mailing list