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

OpenGL Setup problem

Started by Sickboy Jan 27, 2004 at 9:45 AM 0 replies 250+ 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)
	{
		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) ; 
}
When i insert " hglrc = wglCreateContext(hdc); " it works. But that bring me other problems. The "wglDeleteContext(hglrc);" happens on the destructor. Any ideas what i forgot ? thx daSickboy [edited by - Sickboy on January 27, 2004 10:51:46 AM] [edited by - Sickboy on January 27, 2004 11:19:09 AM]

Topic Locked

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

Sign in to reply to this topic.