im programming with openGL and i have a problem with initialising an array of
objects, somehow they seem all to change, if i change one. i have a Tree
class, so it looks like this:
Tree *treeArray;
treeArray = new Tree;
then to initialise the position:
treeArray.init(x1, y1, z1);
treeArray.init(x2, y2, z2);
and now a function to draw them:
treeArray.paintTree();
and now the part i dont understand: this tree is painted at the position of
tree, to be precise in fact all the trees of that array are drawn on one spot,
and that are the coordinates of the last initialised tree. this must mean,
when i change one object of the array, all of them change. why is that?? is
something wrong with my code? ive tried also dynamic initialisation with the
"->" operator instead of "." as well as declaring global and local objects -
but it didnt help at all.
pleeeeaaase help!! -_-
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi everyone,
im programming with openGL and i have a problem with initialising an array of
objects, somehow they seem all to change, if i change one. i have a Tree
class, so it looks like this:
Tree *treeArray;
treeArray = new Tree;
then to initialise the position:
treeArray.init(x1, y1, z1);
treeArray.init(x2, y2, z2);
and now a function to draw them:
treeArray.paintTree();
and now the part i dont understand: this tree is painted at the position of
tree, to be precise in fact all the trees of that array are drawn on one spot,
and that are the coordinates of the last initialised tree. this must mean,
when i change one object of the array, all of them change. why is that?? is
something wrong with my code? ive tried also dynamic initialisation with the
"->" operator instead of "." as well as declaring global and local objects -
but it didnt help at all.
pleeeeaaase help!! -_-