THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/04/2011 at 15:54, xxxxxxxx wrote:
Howdy,
Hmmmmm, that seems to cause another problem, that all of the objects in the scene are affected by the DisplayControl() function, when only one object should be affected. And also the other objects are displaying random colors.
The code I added is this:
LONG i, pCnt = ToPoint(dest)->GetPointCount();
#if API_VERSION < 12000
cds.vertex_color = (Vector* )GeAllocNC(sizeof(Vector)*pCnt);
#else
cds.vertex_color = (SVector* )GeAllocNC(sizeof(SVector)*pCnt);
#endif
if(!cds.vertex_color) return FALSE;
for(i=0; i<pCnt; i++)
{
cds.vertex_color[i] = ptColor[i];
}
... the ptColor array is a class member variable that is built in ToolData::InitDisplayControl(), because to build it in ToolData::DisplayControl() is too time consuming. It is then freed in ToolData::FreeDisplayControl().
With the way I had it working before, only the object to be colorized was displaying colors. I was building the ptColor member variable array in TooData::InitDisplayControl(), the same as it is now. Then in ToolData::DisplayControl() I did this:
cds.vertex_color = ptColor;
... and then I simply did NOT free the ptColor array in ToolData::FreeDisplayControl(). It seemed to work and I didn't get any memory leaks. Was that a safe way of doing it, too?
Adios,
Cactus Dan