Esempio n. 1
0
static BOOL GetDisplayDeviceInfo(IN OUT LPDIRECT3D9_INT pDirect3D9)
{
    DISPLAY_DEVICEA DisplayDevice;
    DWORD AdapterIndex;

    memset(&DisplayDevice, 0, sizeof(DISPLAY_DEVICEA));
    DisplayDevice.cb = sizeof(DISPLAY_DEVICEA);   

    pDirect3D9->NumDisplayAdapters = 0;
    D3D9_PrimaryDeviceName[0] = '\0';

    AdapterIndex = 0;
    while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) == TRUE &&
           pDirect3D9->NumDisplayAdapters < D3D9_INT_MAX_NUM_ADAPTERS)
    {
        if ((DisplayDevice.StateFlags & (DISPLAY_DEVICE_DISCONNECT | DISPLAY_DEVICE_MIRRORING_DRIVER)) == 0 &&
            (DisplayDevice.StateFlags & (DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) != 0)
        {
            SetAdapterInfo(&pDirect3D9->DisplayAdapters[pDirect3D9->NumDisplayAdapters], &DisplayDevice);

            if (pDirect3D9->NumDisplayAdapters == 0)
                lstrcpynA(D3D9_PrimaryDeviceName, DisplayDevice.DeviceName, sizeof(D3D9_PrimaryDeviceName));

            ++pDirect3D9->NumDisplayAdapters;
            break;
        }

        ++AdapterIndex;
    }

    AdapterIndex = 0;
    while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) == TRUE &&
           pDirect3D9->NumDisplayAdapters < D3D9_INT_MAX_NUM_ADAPTERS)
    {
        if ((DisplayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0 &&
            (DisplayDevice.StateFlags & (DISPLAY_DEVICE_MIRRORING_DRIVER | DISPLAY_DEVICE_PRIMARY_DEVICE)) == 0)
        {
            SetAdapterInfo(&pDirect3D9->DisplayAdapters[pDirect3D9->NumDisplayAdapters], &DisplayDevice);
            ++pDirect3D9->NumDisplayAdapters;
        }

        ++AdapterIndex;
    }

    /* Check if minimum DirectDraw is supported */
    if (IsDirectDrawSupported() == FALSE)
        return FALSE;

    for (AdapterIndex = 0; AdapterIndex < pDirect3D9->NumDisplayAdapters; AdapterIndex++)
    {
        GetDirect3D9AdapterInfo(pDirect3D9->DisplayAdapters, AdapterIndex);
    }

    return TRUE;
}
Esempio n. 2
0
///////////////////////////////////////////////////////////////
//
// CVideoModeManager::IsMultiMonitor
//
//
//
///////////////////////////////////////////////////////////////
bool CVideoModeManager::IsMultiMonitor ( void )
{
    if ( m_ulMonitorCount == 0 )
    {
        // Count attached monitors
        for ( int i = 0 ; true ; i++ )
        {
            DISPLAY_DEVICE device;
            device.cb = sizeof(device);

            // Get next DISPLAY_DEVICE from the system
            if( !EnumDisplayDevicesA ( NULL, i, &device, 0 ) )
                break;

            // Calc flags
            bool bAttachedToDesktop = ( device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP ) != 0;
            bool bMirroringDriver   = ( device.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER ) != 0;
            bool bPrimaryDevice     = ( device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ) != 0;

            // Ignore devices that are not required
            if( !bAttachedToDesktop || bMirroringDriver )
                continue;

            m_ulMonitorCount++;
        }
    }

    return m_ulMonitorCount > 1;
}
Esempio n. 3
0
//--------------------------------------------------------------------------
bool WindowsVideoDevice::AddDisplay(const VeChar8* pcDeviceName) noexcept
{
	VeDebugOutputCore("Display: %s\n", pcDeviceName);

	VeDisplayMode kMode;
	
	if (!GetDisplayMode(pcDeviceName, ENUM_CURRENT_SETTINGS, &kMode))
	{
		return false;
	}

	m_kDisplayList.resize(m_kDisplayList.size() + 1);
	VeVideoDisplay& kDisplay = m_kDisplayList.back();

	VeDisplayData* pkDisplayData = VE_NEW VeDisplayData;
	VE_ASSERT(pkDisplayData);
	DISPLAY_DEVICEA device;
	device.cb = sizeof(device);
	if (EnumDisplayDevicesA(pcDeviceName, 0, &device, 0))
	{
		kDisplay.m_kName = device.DeviceString;
	}

	kDisplay.m_kDesktopMode = kMode;
	kDisplay.m_kCurrentMode = kMode;
	kDisplay.m_spDriverData = pkDisplayData;
	return true;
}
Esempio n. 4
0
BOOL LSEnumDisplayDevices(
    LPCSTR lpDevice,
    DWORD iDevNum,
    PDISPLAY_DEVICEA lpDisplayDevice,
    DWORD dwFlags)
{
    return EnumDisplayDevicesA(lpDevice, iDevNum, lpDisplayDevice, dwFlags);
}
//Imago - 7/28/09 this function will return the adapter's Windows desktop refresh rate setting
				// used to set the maximum refresh rate and avoid any PnP issues (thanks Sgt_Baker)
int GetMaxRate(int index = 0)
{
    DISPLAY_DEVICEA dd;
    dd.cb = sizeof(DISPLAY_DEVICEA);

	if (!EnumDisplayDevicesA(NULL, index, &dd, 0))
    {
		debugf("1: EnumDisplayDevices failed:%d\n", GetLastError());
        return 60;
    }
 
    DISPLAY_DEVICEA monitor;
    monitor.cb = sizeof(DISPLAY_DEVICEA);
    if (!EnumDisplayDevicesA(dd.DeviceName, 0, &monitor, 0))
    {
		debugf("2: EnumDisplayDevices failed:%d\n", GetLastError());
		if (!EnumDisplayDevicesA(NULL, 0, &monitor, 0))	{
			debugf("22: EnumDisplayDevices failed:%d\n", GetLastError());
			return 60;
		}
	}
 
    DEVMODEA dm;
    dm.dmSize = sizeof(DEVMODEA);
 
    if (!EnumDisplaySettingsA(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm))
    {
		debugf("3: EnumDisplaySettings failed:%d\n", GetLastError());
        return 60;
    }
 
	debugf("Device string: %s\n", dd.DeviceString);
    debugf("Monitor ID: %s\n", monitor.DeviceID);
	debugf("Monitor name: %s\n", monitor.DeviceName);
	debugf("Monitor string: %s\n", monitor.DeviceString);
    debugf("Refresh rate, in hertz: %d\n", dm.dmDisplayFrequency);
    debugf("Color depth: %d\n", dm.dmBitsPerPel);
    debugf("Screen resolution, in pixels: %d x %d\n", 
        dm.dmPelsWidth, dm.dmPelsHeight);

	return dm.dmDisplayFrequency;
}
HRESULT GetDeviceIDFromHMonitor( HMONITOR hm, WCHAR* strDeviceID, int cchDeviceID )
{

    HINSTANCE hInstDDraw;

    hInstDDraw = LoadLibrary( L"ddraw.dll" );
    if( hInstDDraw )
    {
        DDRAW_MATCH match = {};
        match.hMonitor = hm;

        LPDIRECTDRAWENUMERATEEXA pDirectDrawEnumerateEx = nullptr;
        pDirectDrawEnumerateEx = ( LPDIRECTDRAWENUMERATEEXA )GetProcAddress( hInstDDraw, "DirectDrawEnumerateExA" );

        if( pDirectDrawEnumerateEx )
            pDirectDrawEnumerateEx( DDEnumCallbackEx, ( VOID* )&match, DDENUM_ATTACHEDSECONDARYDEVICES );

        if( match.bFound )
        {
            LONG iDevice = 0;
            DISPLAY_DEVICEA dispdev = {};
            dispdev.cb = sizeof( dispdev );

            while( EnumDisplayDevicesA( nullptr, iDevice, ( DISPLAY_DEVICEA* )&dispdev, 0 ) )
            {
                // Skip devices that are monitors that echo another display
                if( dispdev.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER )
                {
                    iDevice++;
                    continue;
                }

                // Skip devices that aren't attached since they cause problems
                if( ( dispdev.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP ) == 0 )
                {
                    iDevice++;
                    continue;
                }

                if( _stricmp( match.strDriverName, dispdev.DeviceName ) == 0 )
                {
                    MultiByteToWideChar( CP_ACP, 0, dispdev.DeviceID, -1, strDeviceID, cchDeviceID );
                    return S_OK;
                }

                iDevice++;
            }
        }

        FreeLibrary( hInstDDraw );
    }

    return E_FAIL;
}
Esempio n. 7
0
//--------------------------------------------------------------------------
void VeWindows::InitDisplayModes()
{
	DISPLAY_DEVICE kDevice;
	kDevice.cb = sizeof(DISPLAY_DEVICE);
	for(VeInt32 i32Pass(0); i32Pass < 2; ++i32Pass)
	{
		for(VeDWord i(0); ; ++i)
		{
			VeChar8 acDeviceName[32];
			if(!EnumDisplayDevicesA(NULL, i, &kDevice, 0)) 
				break;
			if(!(kDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
				continue;
			if(i32Pass == 0)
			{
				if(!(kDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))
					continue;
			}
			else
			{
				if(kDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
					continue;
			}
			VeStrcpy(acDeviceName, kDevice.DeviceName);
			VeDWord dwCount(0);
			for(VeDWord j(0); ; ++j)
			{
				if(!EnumDisplayDevices(acDeviceName, j, &kDevice, 0))
					break;
				if(!(kDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
					continue;
				if(i32Pass == 0)
				{
					if(!(kDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))
						continue;
				}
				else
				{
					if(kDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
						continue;
				}
				dwCount += AddDisplay(kDevice.DeviceName);
			}
			if(dwCount == 0)
			{
				AddDisplay(acDeviceName);
			}
		}
	}
	VE_ASSERT(m_kDisplays.Size());
}
// From http://stackoverflow.com/questions/9524309/enumdisplaydevices-function-not-working-for-me
void GetGraphicsCardList( Array< String > &gpus)
{
    gpus.Clear();

    DISPLAY_DEVICEA dd;

    dd.cb = sizeof(dd);

    DWORD deviceNum = 0;
    while( EnumDisplayDevicesA(NULL, deviceNum, &dd, 0) ) {
        if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
            gpus.PushBack(dd.DeviceString);
        deviceNum++;
    }
}
Esempio n. 9
0
void initDisplayDeviceInfo()
{
   Con::printf( "Reading Display Device information..." );

   U8 i = 0;

   DISPLAY_DEVICEA ddData;
   ddData.cb = sizeof( DISPLAY_DEVICEA );

   // Search for the primary display adapter, because that is what the rendering
   // context will get created on.
   while( EnumDisplayDevicesA( NULL, i, &ddData, 0 ) != 0 )
   {
      // If we find the primary display adapter, break out
      if( ddData.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE )
         break;

      i++;
   }

   Con::printf( "   Primary Display Device Found:" );

   // Ok, now we have the primary display device. Parse the device information.
   char ven[9];
   char dev[9];

   ven[8] = dev[8] = '\0';

   // It may seem a bit silly here to cast, but there are two implimentations in Platform.h
   // This usage is the "const" version...
   char *pos = dStrstr( ddData.DeviceID, (const char *)"VEN_");

   dStrncpy( ven, ( pos ) ? pos : "VEN_0000", 8 );

   Con::printf( "      Vendor Id: %s", ven );

   pos = dStrstr( ddData.DeviceID, (const char *)"DEV_" );

   dStrncpy( dev, ( pos ) ? pos : "DEV_0000", 8 );

   Con::printf( "      Device Id: %s", dev );

   // We now have the information, set them to console variables so we can parse
   // the file etc in script using getField and so on.
   Con::setVariable( "$PCI_VEN", ven );
   Con::setVariable( "$PCI_DEV", dev );
}
Esempio n. 10
0
HRESULT WINAPI
Main_DirectDraw_GetDeviceIdentifier7(LPDDRAWI_DIRECTDRAW_INT This,
                                     LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags)
{
    HRESULT retVal = DDERR_INVALIDPARAMS;

    BOOL found = FALSE;
    DWORD iDevNum = 0;
    DISPLAY_DEVICEA DisplayDeviceA;
    HKEY hKey;
    DWORD lpType = 0;
    DWORD strSize = MAX_DDDEVICEID_STRING;
    char *pdest;
    char* pcCnvEnd;
    long *lpdata;

    DX_WINDBG_trace();

    EnterCriticalSection( &ddcs );

    _SEH2_TRY
    {
        if ( (IsBadWritePtr( pDDDI, sizeof(DDDEVICEIDENTIFIER2) ) ) ||
        (dwFlags & ~DDGDI_GETHOSTIDENTIFIER))
        {
            retVal = DDERR_INVALIDPARAMS;
            _SEH2_LEAVE;
        }

        /* now we can start getting the driver data */

        while (1)
        {
            ZeroMemory(&DisplayDeviceA,sizeof(DISPLAY_DEVICEA));

            DisplayDeviceA.cb = sizeof(DISPLAY_DEVICEA);

            if ( EnumDisplayDevicesA( NULL, iDevNum, &DisplayDeviceA, 0) == 0)
            {
                retVal = DDERR_INVALIDPARAMS;
                break;
            }

            if (_stricmp(DisplayDeviceA.DeviceName, This->lpLcl->lpGbl->cDriverName) != 0)
            {
                /* if we got another device like hardware mpeg decoder or video card or another drv */
                found = TRUE;
            }
            else if (DisplayDeviceA.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
            {
                /* double check if it primary driver we just found */
                if (!_stricmp( This->lpLcl->lpGbl->cDriverName, "DISPLAY"))
                {
                    /* yeah we found it */
                    found = TRUE;
                }
            }

            if (found == TRUE)
            {
                /* we found our driver now we start setup it */
                if (!_strnicmp(DisplayDeviceA.DeviceKey,"\\REGISTRY\\Machine\\",18))
                {
                    if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, &DisplayDeviceA.DeviceKey[18], 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS )
                    {

                        if (RegQueryValueExA(hKey, "InstalledDisplayDrivers",0, &lpType, (LPBYTE)pDDDI->szDriver, &strSize) != ERROR_SUCCESS)
                        {
                            ZeroMemory(pDDDI->szDriver,MAX_DDDEVICEID_STRING);
                        }
                        else
                        {
                            strcat(pDDDI->szDriver,".dll");
                        }
                        RegCloseKey(hKey);
                    }

                    strcpy( pDDDI->szDescription, DisplayDeviceA.DeviceString);
                    pDDDI->liDriverVersion.HighPart = 0;
                    pDDDI->liDriverVersion.LowPart = 0;

                    pdest = strstr(DisplayDeviceA.DeviceID,"REV_");
                    pDDDI->dwRevision =  strtol ( &pdest[4], &pcCnvEnd, 16);

                    pdest = strstr(DisplayDeviceA.DeviceID,"SUBSYS_");
                    pDDDI->dwSubSysId =  strtol ( &pdest[7], &pcCnvEnd, 16);

                    pdest = strstr(DisplayDeviceA.DeviceID,"DEV_");
                    pDDDI->dwDeviceId = strtol ( &pdest[4], &pcCnvEnd, 16);

                    pdest = strstr(DisplayDeviceA.DeviceID,"VEN_");
                    pDDDI->dwVendorId =strtol ( &pdest[4], &pcCnvEnd, 16);

                    /* Count out the guidDeviceIdentifier */
                    memcpy(&pDDDI->guidDeviceIdentifier, &CLSID_DirectDraw,sizeof(GUID));

                    pDDDI->guidDeviceIdentifier.Data1 ^= pDDDI->dwVendorId;

                    lpdata = (long *)&pDDDI->guidDeviceIdentifier.Data2;
                    *lpdata ^= pDDDI->dwDeviceId;

                    lpdata = (long *)&pDDDI->guidDeviceIdentifier.Data4;
                    *lpdata = (*lpdata ^ pDDDI->dwSubSysId) ^ pDDDI->liDriverVersion.LowPart;

                    lpdata = (long *)&pDDDI->guidDeviceIdentifier.Data4[4];
                    *lpdata = (*lpdata ^ pDDDI->dwRevision) ^ pDDDI->liDriverVersion.HighPart;

                    /* FIXME pDDDI->dwWHQLLevel
                     * we leave this with no informations, I do not known
                     * if program care for it, I mark this api done, and
                     * tested, no bugs was found in it
                     */
                    pDDDI->dwWHQLLevel = 0;
                    retVal = DD_OK;
                }

                break;
            }

            iDevNum++;
        }

    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        retVal = DD_FALSE;
    }
    _SEH2_END;

    LeaveCriticalSection( &ddcs );
    return retVal;
}
Esempio n. 11
0
bool NativeApp::PreInit() {
	
	COut(C_Info) << "Detecting video system..." << std::endl;

//#define HACK_DISABLE_GL
#if defined(RAD_OPT_GL) && !defined(HACK_DISABLE_GL)

	{
		WNDCLASSEXA clex;
		memset(&clex, 0, sizeof(WNDCLASSEXA));

		clex.cbSize = sizeof(WNDCLASSEXA);
		clex.style = CS_OWNDC;
		clex.lpfnWndProc = DefWindowProc;
		clex.hInstance = s_hInstance;
		clex.lpszClassName = "rad_openGL_ini";

		RegisterClassExA(&clex);
	}

	HWND wglWnd = CreateWindowA(
		"rad_openGL_ini", 
		"", 
		WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
		0,
		0,
		100,
		100,
		0,
		0,
		s_hInstance,
		0
	);

	if (!wglWnd) {
		COut(C_Error) << "ERROR: Unable to create device window!" << std::endl;
		return false;
	}

	HDC wglDC = GetDC(wglWnd);

	{
		PIXELFORMATDESCRIPTOR pfd;
		memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
		pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
		pfd.nVersion = 1;
		pfd.dwFlags = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER;
		pfd.iPixelType = PFD_TYPE_RGBA;
		pfd.cColorBits = 24;
		pfd.cAlphaBits = 8;
		pfd.cDepthBits = 24;
		pfd.cStencilBits = 8;
		pfd.iLayerType = PFD_MAIN_PLANE;

		int pf = ChoosePixelFormat(wglDC, &pfd);
		if (pf < 1) {
			ReleaseDC(wglWnd, wglDC);
			DestroyWindow(wglWnd);
			COut(C_Error) << "ERROR: Unable to bind device window pixel format!" << std::endl;
			return false;
		}

		DescribePixelFormat(wglDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);

		if (!SetPixelFormat(wglDC, pf, &pfd)) {
			COut(C_Error) << "ERROR: Unable to bind device window pixel format!" << std::endl;
			return false;
		}
	}

	HGLRC wglRC = myWglCreateContex(wglDC);
	
	if (!wglRC) {
		COut(C_Error) << "ERROR: Unable to create device window context!" << std::endl;
		return false;
	}

	wglMakeCurrent(wglDC, wglRC);
	
	PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
	if (!wglGetExtensionsStringARB) {
		wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
		if (!wglGetExtensionsStringARB) {
			wglMakeCurrent(0, 0);
			wglDeleteContext(wglRC);
			ReleaseDC(wglWnd, wglDC);
			DestroyWindow(wglWnd);
			COut(C_Error) << "Unable to find wglGetExtensionsStringARB" << std::endl;
			return false;
		}
	}

	const char *wglStrings = wglGetExtensionsStringARB(wglDC);

	if (wglStrings)
		COut(C_Info) << "wglGetExtensionsStringARB: " << wglStrings << std::endl;

	if (!wglStrings || !string::strstr(wglStrings, "WGL_ARB_pixel_format")) {
		wglMakeCurrent(0, 0);
		wglDeleteContext(wglRC);
		ReleaseDC(wglWnd, wglDC);
		DestroyWindow(wglWnd);
		COut(C_Error) << "WGL_ARB_pixel_format is required but not found." << std::endl;
		return false;
	}

	bool multiSample = false;
	if (string::strstr(wglStrings, "WGL_ARB_multisample"))
		multiSample = true;

	PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
	PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB");

#endif

	DISPLAY_DEVICEA wdd;
	for (int i = 0; ; ++i) {
		wdd.cb = sizeof(DISPLAY_DEVICEA);
		if (!EnumDisplayDevicesA(0, (DWORD)i, &wdd, 0))
			break;
		if (!(wdd.StateFlags&DISPLAY_DEVICE_ACTIVE))
			continue;
		
		::DisplayDevice::Ref _dd(new (ZEngine) ::DisplayDevice());
		DisplayDevice *dd = &_dd->m_imp;

		dd->m_vars.reset(new (ZEngine) DDVars());
		DDVars *ddv = DDVars::Get(dd->m_vars);

		memcpy(&ddv->dd, &wdd, sizeof(DISPLAY_DEVICEA));

		if (wdd.StateFlags&DISPLAY_DEVICE_PRIMARY_DEVICE) {
			dd->m_primary = true;
		} else {
			dd->m_primary = false;
		}

		DEVMODEA dm;
		dm.dmSize = sizeof(DEVMODEA);

		BOOL r = EnumDisplaySettingsA(ddv->dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm);

		if (!r || ((dm.dmFields&kRequiredDMFields) != kRequiredDMFields)) {
			if (dd->m_primary) {
				// this is kinda bad
				COut(C_Error) << "ERROR: failed to enumerate primary display, initialization failed." << std::endl;
				return false;
			}

			continue;
		}

		if (!(dm.dmFields & DM_POSITION)) {
			// dmPosition is not valid, meaning we cannot identify this as secondary monitor...
			if (dd->m_primary) {
				dm.dmPosition.x = 0;
				dm.dmPosition.y = 0;
				dm.dmFields |= DM_POSITION;
			} else {
				continue; // this monitor cannot be identified.
			}
		}

		string::ncpy((char*)dm.dmDeviceName, wdd.DeviceName, 32);
		memcpy(&ddv->dm, &dm, sizeof(DEVMODEA));
		dd->m_defMode = VidModeFromDevMode(dm);
		dd->m_curMode = dd->m_defMode;
		dd->m_maxMSAA = 0;
		dd->m_maxAnisotropy = 0;

		// enumerate valid display modes.
		COut(C_Info) << "Display " << i << ": '" << ddv->dd.DeviceName << " - " << ddv->dd.DeviceString << "':" << std::endl;

		for (int k = 0; ; ++k) {
			dm.dmSize = sizeof(DEVMODEA);
			if (!EnumDisplaySettingsA(ddv->dd.DeviceName, k, &dm))
				break;
			if ((dm.dmFields&kRequiredDMFields) != kRequiredDMFields)
				continue;
			if (dm.dmBitsPerPel < 32)
				continue;
			r::VidMode m = VidModeFromDevMode(dm);

			r::VidModeVec::iterator it;
			for (it = dd->m_vidModes.begin(); it != dd->m_vidModes.end(); ++it) {
				r::VidMode &x = *it;

				if (x.w == m.w &&
					x.h == m.h) {
					// matches.
					// prefer we use the same hz as our desktop...
					if (m.hz == dd->m_defMode.hz)
						x.hz = m.hz;
					break;
				}
			}

			if (it == dd->m_vidModes.end())
				dd->m_vidModes.push_back(m);
		}

		for (r::VidModeVec::const_iterator it = dd->m_vidModes.begin(); it != dd->m_vidModes.end(); ++it) {
			const r::VidMode &m = *it;
			COut(C_Info) << "\t" << (it-dd->m_vidModes.begin()) << ": " << m.w << "x" << m.h << "x" << m.bpp << " @ " << m.hz << "hz" << std::endl;
		}

		if (dd->m_vidModes.empty()) {
			if (dd->m_primary) {
				COut(C_Error) << "ERROR: primary display '" << ddv->dd.DeviceName << "' is invalid, initialization failed." << std::endl;
				return false;
			}
			continue;
		}

#if defined(RAD_OPT_GL) && !defined(HACK_DISABLE_GL)
		if (multiSample) {

			int maxSamples = 0;

			int reqAttribs[9] = {
				WGL_SUPPORT_OPENGL_ARB,
				WGL_DRAW_TO_WINDOW_ARB,
				WGL_ACCELERATION_ARB,
				WGL_PIXEL_TYPE_ARB,
				WGL_COLOR_BITS_ARB,
				WGL_ALPHA_BITS_ARB,
				WGL_DEPTH_BITS_ARB,
				WGL_STENCIL_BITS_ARB,
				WGL_SAMPLES_ARB
			};

			int attribs[9];

			// Enumerate all pixel formats, find highest multi-sample count
			for (int k = 1; ; ++k) { // PF's are 1 based
				if (!wglGetPixelFormatAttribivARB(wglDC, k, PFD_MAIN_PLANE, 9, reqAttribs, attribs))
					break;
				if (attribs[0] != TRUE)
					continue;
				if (attribs[1] != TRUE)
					continue;
				if (attribs[2] != WGL_FULL_ACCELERATION_ARB)
					continue;
				if (attribs[3] != WGL_TYPE_RGBA_ARB)
					continue;
				if (attribs[4] < 24)
					continue;
				if (attribs[5] < 8)
					continue;
				if (attribs[6] < 24)
					continue;
				if (attribs[7] < 8)
					continue;

				if (maxSamples < attribs[8])
					maxSamples = attribs[8];

				if (maxSamples >= kMaxMultiSample)
					break;
			}

			dd->m_maxMSAA = maxSamples;
		}

		const char *glExt = (const char *)glGetString(GL_EXTENSIONS);
		if (glExt && string::strstr(glExt, "GL_EXT_texture_filter_anisotropic")) {
			GLint maxAnisotropy;
			glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
			dd->m_maxAnisotropy = maxAnisotropy;
		}
		
#endif

		m_displayDevices.push_back(_dd);

		if (dd->m_primary)
			m_primaryDisplay = _dd;
	}

	if (!m_primaryDisplay) {
		COut(C_Error) << "ERROR: no primary display detected, initialization failed!" << std::endl;
		return false;
	}

	return true;
}
Esempio n. 12
0
//--------------------------------------------------------------------------
void WindowsVideoDevice::InitModes() noexcept
{
	VeInt32 pass;
	DWORD i, j, count;
	DISPLAY_DEVICEA device;

	device.cb = sizeof(device);

	for (pass = 0; pass < 2; ++pass)
	{
		for (i = 0;; ++i)
		{
			CHAR DeviceName[32];

			if (!EnumDisplayDevicesA(nullptr, i, &device, 0))
			{
				break;
			}
			if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
			{
				continue;
			}
			if (pass == 0)
			{
				if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))
				{
					continue;
				}
			}
			else
			{
				if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
				{
					continue;
				}
			}
			VeMemoryCopy(DeviceName, device.DeviceName, sizeof(DeviceName));

			VeDebugOutputCore("Device: %s\n", DeviceName);

			count = 0;
			for (j = 0;; ++j)
			{
				if (!EnumDisplayDevicesA(DeviceName, j, &device, 0))
				{
					break;
				}
				if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
				{
					continue;
				}
				if (pass == 0)
				{
					if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))
					{
						continue;
					}
				}
				else {
					if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
					{
						continue;
					}
				}
				count += AddDisplay(device.DeviceName);
			}
			if (count == 0)
			{
				AddDisplay(DeviceName);
			}
		}
	}

	VE_ASSERT(m_kDisplayList.size());
}
Esempio n. 13
0
BOOL ZEnumDisplayDevicesA( DEVICEENUMPROC lpfnDeviceCallback, DWORD dwData)
{
    return  EnumDisplayDevicesA(lpfnDeviceCallback,dwData) ;
}