Hi. I’m kind of a newbie to MFC proramming, but I’ve been doing OpenGL for a while now. I am making a program called Particle Studio, which shows a particle cluster in the view window, and provides a series of dialogs for the user to edit the attributes of the particles.
Everything works fine except that after it’s been running for a while it sometimes freezes. The freezes are not caused by my particle code, because the particle code is taken directly from my main engine (which uses SDL), and there are no freezes in that.
The program is an SDI program, and I use the view window to issue OpenGL commands. I update my scene and redraw it when the OnIdle function of the app is called. In the PreCreateWindow function for the view, I specify the following class styles:
AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_OWNDC, AfxGetApp()->LoadStandardCursor(IDC_ARROW), NULL,NULL);
I set up OpenGL as follows:
int CParticleStudioView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
static HGLRC hRC = NULL;
static HDC hDC = NULL;
hDC = ::GetDC(m_hWnd);
SetDCPixelFormat(hDC);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
glClearColor(0,0,0,1);
TEXTUREMANAGER.LoadTextures();
SCENEMANAGER.Init();
return 0;
}
SetDCPixelFormat is a function I wrote that picks the best pixel format.
Any ideas what is causing the freezing?
[This message has been edited by ioquan (edited 11-18-2002).]