Hi all, I am currently working on a MFC app and is trying to draw a shape on click. However, when i clicked, the shape is not rendering - I simply cant see it on screen. The render function works fine when it’s called in OnDraw, but not when I call it in a function. Can someone tell me what is wrong?
void CTutorial2View::OnLButtonDblClk(UINT nFlags, CPoint point)
{CView::OnLButtonDblClk(nFlags, point); TRACE("Left Clicked!\n"); RenderScene(); InvalidateRect(0, FALSE);
}
void CTutorial2View::RenderScene()
{glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glShadeModel(GL_SMOOTH); glScalef(m_fScale, m_fScale, m_fScale); glTranslatef(xtrans, ytrans, ztrans); glRotatef(xrot, 1, 0, 0); glRotatef(yrot, 0, 1, 0); ////Triangle glNormal3f(0.0, 0.0, 1.0); glBegin(GL_TRIANGLES); glVertex3f(0.0f, 2.0f, 0.0f); glVertex3f(-2.0f, -2.0f, 0.0f); glVertex3f(2.0f, -2.0f, 0.0f); glEnd(); glFlush();
}