Skip to main content
GameDev.net gamedev.net
🔒 Locked

wglCreateContext problem

Started by Sickboy Jan 27, 2004 at 10:00 AM 0 replies 200+ views
Original Post
Sickboy
Sickboy
Hi guys, i have problems to get following code working. hdc and hglrc are member variables of the class.
int COpenGL::OnCreate(LPCREATESTRUCT lpCreateStruct) {    
if (CWnd::OnCreate(lpCreateStruct) == -1)
	return -1;
	hdc = ::GetDC(m_hWnd);
 	MySetPixelFormat(::GetDC(m_hWnd));
	hglrc = wglCreateContext(hdc);
	return 0;
}
void COpenGL::DrawGLContent()
{
	//hglrc = wglCreateContext(hdc);

	if (wglMakeCurrent(hdc, hglrc)
	{
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);			
	glBegin(GL_LINE_LOOP);
        	glColor3f (1.0, 0.0, 1.0);		
	        glVertex2f(-1.0,1.0);
	        glVertex2f( 0.0,1.0);
	        glVertex2f( 0.0,0.0);
	glEnd();
	SwapBuffers(hdc);
	} 	
        wglMakeCurrent(NULL, NULL) ;
 }
The "wglDeleteContext(hglrc);" happens on the destructor. When i insert " hglrc = wglCreateContext(hdc); " in the "DrawGLContent()" function it works. But that bring me other problems (my real app has display lists which get lost). Any ideas why it doesn´t work? thx daSickboy

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.