Optimized OpenGL rendering context creation

This commit is contained in:
mudlord 2007-12-06 03:05:09 +00:00
parent 75a3acacc6
commit 6363b66a21
1 changed files with 2 additions and 9 deletions

View File

@ -151,11 +151,8 @@ OpenGLDisplay::~OpenGLDisplay()
void OpenGLDisplay::EnableOpenGL() void OpenGLDisplay::EnableOpenGL()
{ {
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
int format;
// get the device context (DC) // get the device context (DC)
hDC = GetDC( theApp.m_pMainWnd->GetSafeHwnd() ); hDC = GetDC( theApp.m_pMainWnd->GetSafeHwnd() );
// set the pixel format for the DC // set the pixel format for the DC
ZeroMemory( &pfd, sizeof( pfd ) ); ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd ); pfd.nSize = sizeof( pfd );
@ -165,12 +162,8 @@ void OpenGLDisplay::EnableOpenGL()
pfd.cColorBits = 24; pfd.cColorBits = 24;
pfd.cDepthBits = 16; pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE; pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat( hDC, &pfd ); SetPixelFormat (GetDC (theApp.m_pMainWnd->GetSafeHwnd()), ChoosePixelFormat ( GetDC (theApp.m_pMainWnd->GetSafeHwnd()), &pfd), &pfd);
SetPixelFormat( hDC, format, &pfd ); wglMakeCurrent (GetDC (theApp.m_pMainWnd->GetSafeHwnd()), wglCreateContext(GetDC (theApp.m_pMainWnd->GetSafeHwnd()) ) );
// create and enable the render context (RC)
hRC = wglCreateContext( hDC );
wglMakeCurrent( hDC, hRC );
} }
void OpenGLDisplay::DisableOpenGL() void OpenGLDisplay::DisableOpenGL()