I have now established that the problem is the stage at which I am rendering the points to the screen however I dont know how to fix this. When I am hardcoding the points in the ArrayPoints() and calling it from Stereoscopic(), which is called from RenderScene(), the points are displayed and visible. However when I am calling ArrayPoints() from Serialize() the hardcoded points are not visible! I am not sure how to overcome this as I only want the points to be displayed when a text file of choice is opened and therefore Serialize() would seem the most likely place to me!
Thanks for your help.
void CMy3DView::ArrayPoints() {
CMy3DDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
glPushMatrix();
glColor3f(0.0f,1.0f,0.0f);
glTranslatef(-2.0f, 1.3f, 0.0f);
glPointSize(4);
glBegin(GL_POINTS);
glVertex3f(1.1156f, 1.0036f, 1.0482f);
glVertex3f(0.136f, 0.079f, 0.21f);
glVertex3f(0.1152f, 0.0056f, 0.0684f);
glVertex3f(0.0308f, 0.0066f, 0.02f);
glVertex3f(0.0534f, 0.0434f, 0.1114f);
glVertex3f(0.122f, 0.0048f, 0.0682f);
glVertex3f(0.1154f, 0.0136f, 0.0486f);
glVertex3f(0.0972f, 0.1008f, 0.2198f);
glVertex3f(0.1186f, 0.015f, 0.0474f);
glVertex3f(0.0518f, 0.0526f, 0.0922f);
glEnd();
glPopMatrix();
glFinish(); }
void CMy3DView::Stereoscopic() {
CMy3DDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
glDrawBuffer(GL_BACK_LEFT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.015f, 0.0f, 0.0f);
Grid();
glPopMatrix();
glDrawBuffer(GL_BACK_RIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(-0.015f, 0.0f, 0.0f);
Grid();
ArrayPoints();//Displays hardcoded points when function is called here
glPopMatrix();
glFinish();
SwapBuffers(m_pDC->GetSafeHdc()); }
void CMy3DDoc::Serialize(CArchive& ar) {
CString str;
data.coord_x = data.coord_y = data.coord_z = 0;
POSITION pos = GetFirstViewPosition();
CMy3DView* pView = (CMy3DView *)GetNextView(pos);
if (ar.IsStoring()) {}
else {
while (ar.ReadString(str)) {
sscanf(str, "%f %f %f", &data.coord_x, &data.coord_y, &data.coord_z); }
FileOpen = true;
pView->ArrayPoints(); //calls the function but hardcoded points are not visible on screen }
}