我用OpenGL在MFC中画了一幅图,其中有个函数是用鼠标控制三维图形的旋转和移动,代码如下:
void CWelcomeView::OnMouseMove(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default

CView::OnMouseMove(nFlags, point);
if(TRUE==lDowned)
{
xRotAng -= (xRotAngInit - point.x);
yRotAng -= (yRotAngInit - point.y);
xRotAngInit = (float)point.x;
yRotAngInit = (float)point.y;
Invalidate(FALSE);
}
if(TRUE==rDowned)
{
xTrans -= (xTransInit - point.x)/50;
yTrans -= (yTransInit - point.y)/50;
xTransInit = (float)point.x;
yTransInit = (float)point.y;
Invalidate(FALSE);
}
}////////////////////下面是画图的函数中旋转和移动的实现:
         glTranslatef(xTrans, 0.0f, 0.0f);
glTranslatef(0.0f, -yTrans, 0.0f);
glRotated(xRotAng,0,1,0);
glRotated(yRotAng,1,0,0);程序运行后确实能用鼠标来控制旋转和移动,但半分钟左右(时间不定)程序就动不了了。但同样的方法在C#中我也试过,完全没问题,这是怎么搞得?
是不是C#对使用过的内存资源自动回收,而C++没有?