I get a violation problem when I try to update the value of a CArray. (I use MFC) The update of values is made in other thread (where RecalculateActualTrajectory is called) than the of where I have the opengl painting codes (where drawActualPath is called). I see that the number of elements of ‘m_av6PointandOrientationActual’ is bigger than the one generated. Something happens that increase that. Is there some way to be able to update this carray variable?
from CTrajectoryGuide: CArray <CVector6, CVector6> m_av6PointandOrientationActual;
void CTrajectoryGuide::drawActualPath()
{
glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glLineWidth(2.0);
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0xFF00);
// LINES
glBegin(GL_LINES);
glColor3ub(0, 0, 255);
for (int i=1; i< m_av6PointandOrientationActual.GetCount(); i++)
{
glVertex3d(m_av6PointandOrientationActual.GetAt(i-1)(0),m_av6PointandOrientationActual.GetAt(i-1)(1),m_av6PointandOrientationActual.GetAt(i-1)(2));
glVertex3d(m_av6PointandOrientationActual.GetAt(i)(0),m_av6PointandOrientationActual.GetAt(i)(1),m_av6PointandOrientationActual.GetAt(i)(2));
}
glEnd();
…
}
void CTrajectoryGuide::RecalculateActualTrajectory(CVector6 v6ActualPosition,CArray <CVector6, CVector6> *paSeedPath){
…
// Generate new actual trajectory
// Reset m_av6PointandOrientationActual
m_av6PointandOrientationActual.RemoveAll();
// First point: v6ActualPosition
m_av6PointandOrientationActual.Add(v6ActualPosition);
// Second point: projection point
m_av6PointandOrientationActual.Add(v6ProjectionPoint);
// Further points: from original trajectory
for (int i=iPoint2_index; i<= paSeedPath->GetUpperBound(); i++){
m_av6PointandOrientationActual.Add(paSeedPath->GetAt(i));
}
…
}
Thanks