Original Post
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]