From 6363b66a212864f08de05ac1d576aae5e62241e8 Mon Sep 17 00:00:00 2001 From: mudlord Date: Thu, 6 Dec 2007 03:05:09 +0000 Subject: [PATCH] Optimized OpenGL rendering context creation --- src/win32/OpenGL.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/win32/OpenGL.cpp b/src/win32/OpenGL.cpp index 3c673908..7f201b26 100644 --- a/src/win32/OpenGL.cpp +++ b/src/win32/OpenGL.cpp @@ -151,11 +151,8 @@ OpenGLDisplay::~OpenGLDisplay() void OpenGLDisplay::EnableOpenGL() { PIXELFORMATDESCRIPTOR pfd; - int format; - // get the device context (DC) hDC = GetDC( theApp.m_pMainWnd->GetSafeHwnd() ); - // set the pixel format for the DC ZeroMemory( &pfd, sizeof( pfd ) ); pfd.nSize = sizeof( pfd ); @@ -165,12 +162,8 @@ void OpenGLDisplay::EnableOpenGL() pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; - format = ChoosePixelFormat( hDC, &pfd ); - SetPixelFormat( hDC, format, &pfd ); - - // create and enable the render context (RC) - hRC = wglCreateContext( hDC ); - wglMakeCurrent( hDC, hRC ); + SetPixelFormat (GetDC (theApp.m_pMainWnd->GetSafeHwnd()), ChoosePixelFormat ( GetDC (theApp.m_pMainWnd->GetSafeHwnd()), &pfd), &pfd); + wglMakeCurrent (GetDC (theApp.m_pMainWnd->GetSafeHwnd()), wglCreateContext(GetDC (theApp.m_pMainWnd->GetSafeHwnd()) ) ); } void OpenGLDisplay::DisableOpenGL()