Ejemplo n.º 1
0
DisplayMode NPAPICoreMacOSPlatform::GetCurrentDisplayMode()
{
	CFDictionaryRef currentMode = CGDisplayCurrentMode(kCGDirectMainDisplay);
	
	DisplayMode mode;
	mode.width = GetModeWidth(currentMode);
	mode.height = GetModeHeight(currentMode);
	mode.refreshRate = GetModeRefreshRate(currentMode);
	mode.bpp = GetModeBitsPerPixel(currentMode);
	
	return mode;
}
void CoreMacOSPlatform::GetAvailableDisplayModes(List<DisplayMode> & availableModes)
{
	CFArrayRef availableModesSystem = CGDisplayAvailableModes(kCGDirectMainDisplay);
	int32 numberOfAvailableModes = CFArrayGetCount(availableModesSystem);
	
	for (int modeIndex = 0; modeIndex < numberOfAvailableModes; ++modeIndex)
	{
		// look at each mode in the available list
		CFDictionaryRef modeSystem = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModesSystem, modeIndex);
	
		DisplayMode mode;
		mode.width = GetModeWidth(modeSystem);
		mode.height = GetModeHeight(modeSystem);
		mode.refreshRate = GetModeRefreshRate(modeSystem);
		mode.bpp = GetModeBitsPerPixel(modeSystem);
		availableModes.push_back(mode);
	}
	
//		LPDIRECT3D9 direct3D = RenderManager::Instance()->GetD3D();
//		availableDisplayModes.clear();
//		
//		D3DFORMAT formats[] = {D3DFMT_R5G6B5, D3DFMT_X8R8G8B8}; 
//		
//		for (int format = 0; format < sizeof(formats) / sizeof(D3DFORMAT); ++format)
//		{
//			for (int32 mode = 0; mode < direct3D->GetAdapterModeCount(D3DADAPTER_DEFAULT, formats[format]); ++mode)
//			{
//				D3DDISPLAYMODE displayMode;
//				HRESULT hr = direct3D->EnumAdapterModes(D3DADAPTER_DEFAULT, formats[format], mode, &displayMode);	
//				if (!FAILED(hr))
//				{
//					DisplayMode mode;
//					mode.width = displayMode.Width;
//					mode.height = displayMode.Height;
//					if (displayMode.Format == D3DFMT_R5G6B5)mode.bpp = 16;
//					else if (displayMode.Format == D3DFMT_X8R8G8B8) mode.bpp = 32;
//					else if (displayMode.Format == D3DFMT_R8G8B8) mode.bpp = 24;
//					mode.refreshRate = displayMode.RefreshRate;
//					availableDisplayModes.push_back(mode);
//					
//					Logger::Debug("[RenderManagerDX9::GetAvailableDisplayModes] mode found: %d x %d x %d", 
//								  mode.width,
//								  mode.height,
//								  mode.bpp);
//				}
//			}
//		}
	
	
}
DisplayMode CoreMacOSPlatform::GetCurrentDisplayMode()
{
	CFDictionaryRef currentMode = CGDisplayCurrentMode(kCGDirectMainDisplay);
	
	// look at each mode in the available list
	//CFDictionaryRef modeSystem = (CFDictionaryRef)CFArrayGetValueAtIndex(currentMode, mode);

	DisplayMode mode;
	mode.width = GetModeWidth(currentMode);
	mode.height = GetModeHeight(currentMode);
	mode.refreshRate = GetModeRefreshRate(currentMode);
	mode.bpp = GetModeBitsPerPixel(currentMode);
	
	return mode;
}