46 bool CreateDummyGLWindowWin32( HWND* hWnd, HGLRC* hGLRC )
48 HINSTANCE hInstance = GetModuleHandle( NULL );
51 wc.cbSize =
sizeof( WNDCLASSEX );
52 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
53 wc.lpfnWndProc = DefWindowProc;
56 wc.hInstance = hInstance;
59 wc.hCursor = LoadCursor( hInstance, IDC_ARROW );
60 wc.hbrBackground = NULL;
61 wc.lpszMenuName = NULL;
62 wc.lpszClassName =
"Dummy";
65 RegisterClassEx( &wc );
68 *hWnd = CreateWindowEx( NULL,
"Dummy", NULL, NULL, 0, 0, 1, 1, NULL, NULL, NULL, NULL );
71 HDC hDC = GetDC( *hWnd );
76 static PIXELFORMATDESCRIPTOR pfd =
78 sizeof( PIXELFORMATDESCRIPTOR ),
100 if ( ( pixelformat = ChoosePixelFormat( hDC, &pfd ) ) == 0 )
105 if ( SetPixelFormat( hDC, pixelformat, &pfd ) ==
FALSE )
110 *hGLRC = wglCreateContext( hDC );
112 wglMakeCurrent( hDC, *hGLRC );
118 bool DestroyGLWindowWin32( HWND* hWnd, HGLRC* hGLRC )
120 HDC hDC = GetDC( *hWnd );
121 wglMakeCurrent( NULL, NULL );
122 wglDeleteContext( *hGLRC );
123 if( ReleaseDC( *hWnd, hDC ) == 0 )
127 if( DestroyWindow( *hWnd ) ==
FALSE )
173 if( CreateDummyGLWindowWin32( &hWnd, &hGLRC ) ==
false )
183 LOG_ERROR(
"Could not load OpenGL Affinity extension" );
187 LOG_INFO(
"Listing GPUs available for OpenGL GPU Affinity" );
189 unsigned int GPUIdx = 0;
191 GPU_DEVICE gpuDevice;
192 gpuDevice.cb =
sizeof( gpuDevice );
199 LOG_DEBUG(
"GPU# " << GPUIdx <<
":" );
205 int DisplayDeviceIdx = 0;
208 LOG_DEBUG(
" Display# " << DisplayDeviceIdx );
209 LOG_DEBUG(
" Name: " << gpuDevice.DeviceName );
210 LOG_DEBUG(
" String: " << gpuDevice.DeviceString );
214 if( gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP )
216 LOG_DEBUG(
" Attached to the desktop: LEFT=" << gpuDevice.rcVirtualScreen.left <<
", RIGHT=" << gpuDevice.rcVirtualScreen.right
217 <<
", TOP=" << gpuDevice.rcVirtualScreen.top <<
", BOTTOM=" << gpuDevice.rcVirtualScreen.bottom );
221 LOG_DEBUG(
" Not attached to the desktop." );
225 if( gpuDevice.Flags & DISPLAY_DEVICE_PRIMARY_DEVICE )
227 LOG_DEBUG(
" This is the PRIMARY Display Device." );
234 gpu->
Init( hGPU, bPrimary, bDisplay );
246 if( DestroyGLWindowWin32( &hWnd, &hGLRC ) ==
false )
273 if( index >= 0 && index <
m_nGpu )
319 bool CNvGpu::Init( HGPUNV gpuAffinityHandle,
bool bPrimary,
bool bDisplay )
321 m_hGpu = gpuAffinityHandle;
PFNWGLENUMGPUSNVPROC wglEnumGpusNV
virtual CNvGpu * GetGpu(int index)
virtual CNvGpu * GetPrimaryGpu()
CNvGpu * m_lGpu[MAX_GPUS]
HGPUNV getAffinityHandle()
bool Init(HGPUNV gpuAffinityHandle, bool bPrimary, bool bDisplay)
PFNWGLENUMGPUDEVICESNVPROC wglEnumGpuDevicesNV
virtual ~CNvGpuTopology()
bool loadAffinityExtension()
static CNvGpuTopology & Instance()