Problems trying to assign **varname to *varname[]. c++ -
in .h, have variable, texture ** skyboxtextures
. assign texture pointers in 1 method, , use them right away:
texture *skt[] = { tleft, tright, tfront, tback, tup, tdown }; skyboxtextures = skt; for(int = 0; < 6; i++) { skyboxtextures[i]->load(); }
then later in method try use textures again.
texture *skt[] = skyboxtextures; // render front quad skyboxtextures[0]->activate();
this issue cannot access objects more. not compile because of error:
error c2440: 'initializing' : cannot convert 'texture **' 'texture *[]'
if comment out line texture *skt[] = skyboxtextures;
, invalid texture pointers.
then later in method try use textures again.
you cannot that. converting array pointer it's first element 1 way process. while array still array compiler has information size of array available @ compile time. once it's pointer, compiler no longer has information.
you either have reference skt
itself, or not convert skyboxtextures
array @ all. skyboxtextures[0]->activate();
should work expect.
if comment out line texture *skt[] = skyboxtextures;, invalid texture pointers.
my guess issue lies here:
texture *skt[] = { tleft, tright, tfront, tback, tup, tdown };
you must ensure tleft, tright, tfront, tback, tup, , tdown valid when use other array. if did allocated them on stack , returned skyboxtextures
pointer method you'd have undefined behavior. you'll have put these on heap allocation.
Comments
Post a Comment