Ejemplo n.º 1
1
// Search for available resolutions - TODO: Move to Common?
wxArrayString GetListOfResolutions()
{
	wxArrayString retlist;
	retlist.Add("Auto");
#ifdef _WIN32
	DWORD iModeNum = 0;
	DEVMODE dmi;
	ZeroMemory(&dmi, sizeof(dmi));
	dmi.dmSize = sizeof(dmi);
	std::vector<std::string> resos;

	while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0)
	{
		char res[100];
		sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
		std::string strRes(res);
		// Only add unique resolutions
		if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
		{
			resos.push_back(strRes);
			retlist.Add(StrToWxStr(res));
		}
		ZeroMemory(&dmi, sizeof(dmi));
	}
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
	main_frame->m_XRRConfig->AddResolutions(retlist);
#elif defined(__APPLE__)
	CFArrayRef modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
	for (CFIndex i = 0; i < CFArrayGetCount(modes); i++)
	{
		std::stringstream res;
		CGDisplayModeRef mode;
		CFStringRef encoding;
		size_t w, h;
		bool is32;

		mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
		w = CGDisplayModeGetWidth(mode);
		h = CGDisplayModeGetHeight(mode);
		encoding = CGDisplayModeCopyPixelEncoding(mode);
		is32 = CFEqual(encoding, CFSTR(IO32BitDirectPixels));
		CFRelease(encoding);

		if (!is32)
			continue;
		if (CGDisplayModeGetIOFlags(mode) & kDisplayModeStretchedFlag)
			continue;

		res << w << "x" << h;

		retlist.Add(res.str());
	}
	CFRelease(modes);
#endif
	return retlist;
}
void changeDisplayRes(int displayIndex)
{
	DEVMODE dm;
   
   EnumDisplaySettings(NULL, displayIndex, &dm);
   
   if (ChangeDisplaySettings(&dm, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
   return;
   
   ChangeDisplaySettings(&dm, 0);
}
Ejemplo n.º 3
0
void Window::GetScreenMode(){
    std::cout<<"Get Screen INfo"<<std::endl;
      DEVMODE Screen;
      Screen.dmSize=sizeof(DEVMODE);
      for(int i=0;EnumDisplaySettings(NULL,i,&Screen);i++){
          //LPDWORD BitRequired=0;
          //LPDWORD StructNb;
          //EnumMonitorsW(NULL,1,NULL,0,BitRequired,StructNb);
          //LPBYTE Buffer[(long)*BitRequired];
          //EnumMonitorsW(NULL,1,*Buffer,*BitRequired,BitRequired,StructNb);
          char buff[255];
          char buff2[20];
          strcpy(buff,"Device:");
          strcat(buff,(const char*)Screen.dmDeviceName);
          std::cout<<buff<<std::endl;

          WriteToLog(buff,"DEVMOD");
          strcpy(buff,"extra bit driver:");
          sprintf(buff2,"%i",Screen.dmDriverExtra);
          strcat(buff,buff2);
          std::cout<<buff<<std::endl;
          WriteToLog(buff,"DEVMOD");

        //withd et height
          strcpy(buff,"Width/Height:");
          sprintf(buff2,"%u",Screen.dmPelsWidth);
          strcat(buff,buff2);
          strcat(buff,"/");
          sprintf(buff2,"%u",Screen.dmPelsHeight);
          strcat(buff,buff2);
          std::cout<<buff<<std::endl;
        WriteToLog(buff,"DEVMOD");

          //bit par pixel
          strcpy(buff,"Bit per pixel:");
          sprintf(buff2,"%u",Screen.dmBitsPerPel);
          strcat(buff,buff2);
          std::cout<<buff<<std::endl;
          WriteToLog(buff,"DEVMOD");

          strcpy(buff,"FramePerSecond:");
          sprintf(buff2,"%u",Screen.dmDisplayFrequency);
          strcat(buff,buff2);
          std::cout<<buff<<std::endl;
          WriteToLog(buff,"DEVMOD");

          int* Res=new int[2];
          Res[0]=Screen.dmPelsWidth;
          Res[1]=Screen.dmPelsHeight;
          ResolutionList.push_back(Res);
          FrameRateList.push_back(Screen.dmDisplayFrequency);

      }
      ResolutionList.sort(SortResolution);
      FrameRateList.sort();
}
Ejemplo n.º 4
0
static int fullResInit()
{
	if (!hVideoDlg) {
		return 1;
	}

	DEVMODE devMode;
	devMode.dmSize = sizeof(DEVMODE);
	devMode.dmDriverExtra = 0;

	DISPLAY_DEVICE device;
	device.cb = sizeof(DISPLAY_DEVICE);
	EnumDisplayDevices(NULL, nVidAdapter, &device, 0);

	// fullscreen res box
	// Run through all possible screenmodes and fill the combobox
	for (int i = 0; EnumDisplaySettings(device.DeviceName, i, &devMode); i++) {
		// We're only interested in 16, 24, or 32 bit modes.
		if (devMode.dmBitsPerPel & 0x30) {
			long item = 0, itemValue;
			long newRes = (devMode.dmPelsWidth << 16) | devMode.dmPelsHeight;

			// See if the resolution is already in the combobox
			do {
				itemValue = SendDlgItemMessage(hVideoDlg, IDC_PREF_FULLSCREENRES, CB_GETITEMDATA, item, 0);
				item++;
			} while ((itemValue != CB_ERR) && (itemValue != newRes));

			// If not, add it
			if (itemValue == CB_ERR) {
				TCHAR szRes[MAX_PATH];
				_stprintf(szRes, _T("%li x %li"), devMode.dmPelsWidth, devMode.dmPelsHeight);
				item = SendDlgItemMessage(hVideoDlg, IDC_PREF_FULLSCREENRES, CB_ADDSTRING, 0, (LPARAM)&szRes);
				SendDlgItemMessage(hVideoDlg, IDC_PREF_FULLSCREENRES, CB_SETITEMDATA, item, newRes);
			}
		}
	}

	// set select
	long myRes = (nVidWidth << 16) | nVidHeight;
	long count = SendDlgItemMessage(hVideoDlg, IDC_PREF_FULLSCREENRES, CB_GETCOUNT, 0, 0);
	long item = 0;
	for (long i = 0; i < count; i++) {
		item = SendDlgItemMessage(hVideoDlg, IDC_PREF_FULLSCREENRES, CB_GETITEMDATA, i, 0);
		if (myRes == item) {
			SendDlgItemMessage(hVideoDlg, IDC_PREF_FULLSCREENRES, CB_SETCURSEL, (WPARAM)i, 0);
			break;
		}
	}

	// depth
	SendDlgItemMessage(hVideoDlg, IDC_PREF_16BIT, BM_SETCHECK, (nVidDepth == 16) ? BST_CHECKED : BST_UNCHECKED, 0);
	SendDlgItemMessage(hVideoDlg, IDC_PREF_32BIT, BM_SETCHECK, (nVidDepth == 32) ? BST_CHECKED : BST_UNCHECKED, 0);

	return 0;
}
Ejemplo n.º 5
0
	int Window::GetDesktopRefreshRate() const
	{
		DEVMODE mode;
		memset(&mode, 0, sizeof(mode));
		mode.dmSize = sizeof(mode);

		if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &mode))
			return 60;
		return mode.dmDisplayFrequency;
	}
Ejemplo n.º 6
0
void getPossibleScreenModes(vector<VideoMode> &out_modes) {
	DEVMODE dm = {0};
	dm.dmSize = sizeof(dm);
	for (int iModeNum = 0; EnumDisplaySettings(NULL, iModeNum, &dm) != 0; ++iModeNum) {
		if (dm.dmBitsPerPel == 32/* || dm.dmBitsPerPel == 16*/) {
			VideoMode mode(dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency);
			out_modes.push_back(mode);
		}
	}
}
Ejemplo n.º 7
0
VideoModeInfo DisplayWrapper::dwrapperCurrentVideoMode() {
	DEVMODE devmode;
	EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
	VideoModeInfo videoModeInfo;
	videoModeInfo.width = devmode.dmPelsWidth;
	videoModeInfo.height = devmode.dmPelsHeight;
	videoModeInfo.bpp = devmode.dmBitsPerPel;

	return videoModeInfo;
}
Ejemplo n.º 8
0
	int Window::GetDesktopWidth() const
	{
		DEVMODE mode;
		memset(&mode, 0, sizeof(mode));
		mode.dmSize = sizeof(mode);

		if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &mode))
			return 480;
		return mode.dmPelsWidth;
	}
Ejemplo n.º 9
0
	int Window::GetDesktopBitsPerPixel() const
	{
		DEVMODE mode;
		memset(&mode, 0, sizeof(mode));
		mode.dmSize = sizeof(mode);

		if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &mode))
			return 16;
		return mode.dmBitsPerPel;
	}
Ejemplo n.º 10
0
static DEVMODE deviceInfoForWidget(Widget* widget)
{
    DEVMODE deviceInfo;
    deviceInfo.dmSize = sizeof(DEVMODE);
    deviceInfo.dmDriverExtra = 0;
    MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
    EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &deviceInfo);

    return deviceInfo;
}
Ejemplo n.º 11
0
double getrefresh() {
  DEVMODE DevMode;

  DevMode.dmDriverExtra = 0;
  if (EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&DevMode)) {
    return (double)DevMode.dmDisplayFrequency;
  } else {
    return 0;
  }
}
Ejemplo n.º 12
0
BOOL Window::IsResolutionSupported(int width, int height) {
	DEVMODE mode;
	for (int i = 0; EnumDisplaySettings(0, i, &mode); i++) {
		if (ChangeDisplaySettings(&mode, CDS_TEST) == DISP_CHANGE_SUCCESSFUL)
			if (width == mode.dmPelsWidth && height == mode.dmPelsHeight) {
				return TRUE;
			}
	}
	return FALSE;
}
Ejemplo n.º 13
0
VideoModeInfo DisplayWrapper::dw_currentMode()
{
  DEVMODE devmode;
  EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
  VideoModeInfo mode;
  mode.width = devmode.dmPelsWidth;
  mode.height = devmode.dmPelsHeight;
  mode.bpp = devmode.dmBitsPerPel;
  return mode;
}
Ejemplo n.º 14
0
// Search for avaliable resolutions - TODO: Move to Common?
wxArrayString GetListOfResolutions()
{
	wxArrayString retlist;
#ifdef _WIN32
	DWORD iModeNum = 0;
	DEVMODE dmi;
	ZeroMemory(&dmi, sizeof(dmi));
	dmi.dmSize = sizeof(dmi);
	std::vector<std::string> resos;

	while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0)
	{
		char res[100];
		sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
		std::string strRes(res);
		// Only add unique resolutions
		if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
		{
			resos.push_back(strRes);
			retlist.Add(wxString::FromAscii(res));
		}
		ZeroMemory(&dmi, sizeof(dmi));
	}
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
	main_frame->m_XRRConfig->AddResolutions(retlist);
#elif defined(__APPLE__)
	CFArrayRef modes = CGDisplayAvailableModes(CGMainDisplayID());
	for (CFIndex i = 0; i < CFArrayGetCount(modes); i++)
	{
		std::stringstream res;
		CFDictionaryRef mode;
		CFNumberRef ref;
		int w, h, d;

		mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i);
		ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayWidth);
		CFNumberGetValue(ref, kCFNumberIntType, &w);
		ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayHeight);
		CFNumberGetValue(ref, kCFNumberIntType, &h);
		ref = (CFNumberRef)CFDictionaryGetValue(mode,
			kCGDisplayBitsPerPixel);
		CFNumberGetValue(ref, kCFNumberIntType, &d);

		if (CFDictionaryContainsKey(mode, kCGDisplayModeIsStretched))
			continue;
		if (d != 32)
			continue;

		res << w << "x" << h;

		retlist.Add(res.str());
	}
#endif
	return retlist;
}
Ejemplo n.º 15
0
void adjustWindow(WindowsDesc* winDesc)
{
	HWND hwnd = (HWND)winDesc->handle;

	if (winDesc->fullScreen)
	{
		RECT windowedRect = {};
		// Save the old window rect so we can restore it when exiting fullscreen mode.
		GetWindowRect(hwnd, &windowedRect);
		winDesc->windowedRect = { (int)windowedRect.left, (int)windowedRect.top, (int)windowedRect.right, (int)windowedRect.bottom };

		// Make the window borderless so that the client area can fill the screen.
		SetWindowLong(hwnd, GWL_STYLE, WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE);

		// Get the settings of the primary display. We want the app to go into
		// fullscreen mode on the display that supports Independent Flip.
		DEVMODE devMode = {};
		devMode.dmSize = sizeof(DEVMODE);
		EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);

		SetWindowPos(
			hwnd,
			HWND_TOPMOST,
			devMode.dmPosition.x,
			devMode.dmPosition.y,
			devMode.dmPosition.x + devMode.dmPelsWidth,
			devMode.dmPosition.y + devMode.dmPelsHeight,
			SWP_FRAMECHANGED | SWP_NOACTIVATE);

		ShowWindow(hwnd, SW_MAXIMIZE);
	}
	else
	{
		// Restore the window's attributes and size.
		SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);

		SetWindowPos(
			hwnd,
			HWND_NOTOPMOST,
			winDesc->windowedRect.left,
			winDesc->windowedRect.top,
			winDesc->windowedRect.right - winDesc->windowedRect.left,
			winDesc->windowedRect.bottom - winDesc->windowedRect.top,
			SWP_FRAMECHANGED | SWP_NOACTIVATE);

		if (winDesc->maximized)
		{
			ShowWindow(hwnd, SW_MAXIMIZE);
		}
		else
		{
			ShowWindow(hwnd, SW_NORMAL);
		}
	}
}
Ejemplo n.º 16
0
/*
** GLimp_GetCurrentMode
*/
int GLimp_GetCurrentMode( void )
{
	DEVMODE dm;
		
	memset( &dm, 0, sizeof( dm ) );
	dm.dmSize = sizeof( dm );

	EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &dm );

	return VID_GetModeNum( dm.dmPelsWidth, dm.dmPelsHeight );
}
Ejemplo n.º 17
0
void s_video_gdi_server_fullscreen (void)
{
	RECT rect;
        DEVMODE settings;
	s_video_gdi_data_t *priv = (s_video_gdi_data_t *) xynth_server->driver->driver_data;
	
	if (priv->fullscreen == 0) {
                EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &priv->dmode);
                memset(&settings, 0, sizeof(DEVMODE));
                settings.dmSize = sizeof(DEVMODE);
                settings.dmBitsPerPel = priv->bpp_windows;
                settings.dmPelsWidth = xynth_server->window->surface->width;
                settings.dmPelsHeight = xynth_server->window->surface->height;
                settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
        } else {
                settings.dmSize = sizeof(DEVMODE);
                settings.dmBitsPerPel = priv->dmode.dmBitsPerPel;
                settings.dmPelsWidth = priv->dmode.dmPelsWidth;
                settings.dmPelsHeight = priv->dmode.dmPelsHeight;
                settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
        }

        switch (ChangeDisplaySettings(&settings, CDS_FULLSCREEN)) {
                case DISP_CHANGE_SUCCESSFUL:
                        break;
                case DISP_CHANGE_BADFLAGS:
                case DISP_CHANGE_BADMODE:
                case DISP_CHANGE_BADPARAM:
                case DISP_CHANGE_FAILED:
                case DISP_CHANGE_NOTUPDATED:
                case DISP_CHANGE_RESTART:
                        break;
        }

	if (priv->fullscreen == 0) {
        	rect.left = 0;
        	rect.right = xynth_server->window->surface->width;
        	rect.top = 0;
        	rect.bottom = xynth_server->window->surface->height;
                AdjustWindowRect(&rect, GetWindowLong(priv->hwndMain, GWL_STYLE), FALSE);
                SetWindowPos(priv->hwndMain, HWND_TOPMOST, rect.left, rect.top, rect.right + 100, rect.bottom + 100, 0);
                priv->fullscreen = 1;
        } else {
        	rect.left = 0;
        	rect.right = xynth_server->window->surface->width;
        	rect.top = 0;
        	rect.bottom = xynth_server->window->surface->height;
                AdjustWindowRect(&rect, GetWindowLong(priv->hwndMain, GWL_STYLE), FALSE);
                SetWindowPos(priv->hwndMain, HWND_NOTOPMOST, 0, 0, rect.right - rect.left, rect.bottom - rect.top, 0);
                priv->fullscreen = 0;
        }

	UpdateWindow(priv->hwndMain);
}
Ejemplo n.º 18
0
void CFixApp::PopulateDialog()
{
    //Populate the GUI scale combobox
    for (size_t i = 1; i < 6; i++)
    {
        wchar_t szBuf[3];
        swprintf_s(szBuf, L"x%Iu", i);
        ComboBox_AddString(m_hWndCBGUIScales, szBuf);
    }
    ComboBox_SetCurSel(m_hWndCBGUIScales, 0);

    //Populate the resolution combobox
    DEVMODE dm = {};
    dm.dmSize = sizeof(dm);
    Resolution r= {};
    for(DWORD iModeNum = 0; EnumDisplaySettings(NULL, iModeNum, &dm) != FALSE; iModeNum++)
    {
        if((dm.dmPelsWidth != r.iX || dm.dmPelsHeight != r.iY) && dm.dmBitsPerPel == 32) //Only add each res once, but don't actually check if it matches the current color depth/refresh rate
        {
            r.iX = dm.dmPelsWidth;
            r.iY = dm.dmPelsHeight;
            m_Resolutions.push_back(r);

            wchar_t szBuffer[20];
            _snwprintf_s(szBuffer, _TRUNCATE, L"%Iux%Iu", r.iX, r.iY);
            int iIndex = ComboBox_AddString(m_hWndCBResolutions, szBuffer);
            ComboBox_SetItemData(m_hWndCBResolutions, iIndex, &(m_Resolutions.back()));
        }
    }
    ComboBox_SetCurSel(m_hWndCBResolutions, 0);


    //Renderers (based on UnEngineWin.h), requires appInit() to have been called
    TArray<FRegistryObjectInfo> Classes;
    Classes.Empty();

    UObject::GetRegistryObjects( Classes, UClass::StaticClass(), URenderDevice::StaticClass(), 0 );
    for( TArray<FRegistryObjectInfo>::TIterator It(Classes); It; ++It )
    {
        FString Path = It->Object, Left, Right;
        if( Path.Split(L".",&Left,&Right)  )
        {
            const wchar_t* pszDesc = Localize(*Right,L"ClassCaption",*Left);
            assert(pszDesc);
            if(ComboBox_FindStringExact(m_hWndCBRenderers, -1, pszDesc) == CB_ERR)
            {
                ComboBox_AddString(m_hWndCBRenderers, pszDesc);
                m_Renderers.emplace_back(static_cast<wchar_t*>(Path.GetCharArray().GetData()));
            }
        }
    }

}
Ejemplo n.º 19
0
void GLWindow::changeDisplaySettings()
{
	RECT screenRect = { };
	GetClientRect(GetDesktopWindow(), &screenRect);

	DEVMODE deviceMode = { };
	EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &deviceMode);
	deviceMode.dmSize = sizeof(DEVMODE);
	deviceMode.dmPelsWidth = screenRect.right;
	deviceMode.dmPelsHeight = screenRect.bottom;
	ChangeDisplaySettings(&deviceMode, CDS_FULLSCREEN);
}
Ejemplo n.º 20
0
void DisplayWrapper::dw_init(bool filter, int minWidth, int minHeight)
{
  base_height = base_width = 0;
  base_bpp = 0;

  DEVMODE devmode;
  DWORD modenum = 0;
  VideoModeInfo mode;

  modes.clear();
  modeNames.clear();

  // get current display
  wchar_t *device = NULL;
  DISPLAY_DEVICE display_device;
  display_device.cb = sizeof(DISPLAY_DEVICE);

  if (base_widget)
  {
    QDesktopWidget desktop;
    int screen = desktop.screenNumber(base_widget);
    if (screen >= 0)
    {
      if (EnumDisplayDevices(NULL, screen, &display_device, 0))
      {
        device = display_device.DeviceName;
        //qDebug() << QString::fromWCharArray(device);
      }
    }
  }

  // enumerate display modes
  while (EnumDisplaySettings(device, modenum, &devmode))
  {
    if (devmode.dmPelsWidth >= minWidth && devmode.dmPelsHeight >= minHeight)
    {
      modeNames.append(QString("%1 x %2")
                       .arg(devmode.dmPelsWidth)
                       .arg(devmode.dmPelsHeight)
                       );

      mode.width = devmode.dmPelsWidth;
      mode.height = devmode.dmPelsHeight;
      mode.bpp = devmode.dmBitsPerPel;
      modes.append(mode);
    }
    modenum++;
  }

  if (filter)
    modeNames.removeDuplicates();
}
Ejemplo n.º 21
0
/**
 * Choose displaymodes using extended codepath (multiple displaydevices)
 */
jobjectArray getAvailableDisplayModes(JNIEnv * env) {

	int i = 0, j = 0, n = 0;

//	DISPLAY_DEVICE DisplayDevice;
	DEVMODE DevMode;
	jobject *display_mode_objects = NULL;
	int list_size = 0;

	jclass displayModeClass;
	jobjectArray ret;
	displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode");

	ZeroMemory(&DevMode, sizeof(DEVMODE));
//	ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));

	DevMode.dmSize = sizeof(DEVMODE);
//	DisplayDevice.cb = sizeof(DISPLAY_DEVICE);

	/* Multi-monitor stuff commented out since we're only really interested in the primary monitor */
/*	while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) {
		// continue if mirroring device
		if((DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) != 0) {
			continue;
		}

		j = 0;
		while(EnumDisplaySettings((const char *) DisplayDevice.DeviceName, j++, &DevMode) != 0) {*/
		while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
			// Filter out indexed modes
			if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) {
				jobject displayMode;
				if (list_size <= n) {
					list_size += 1;
					display_mode_objects = (jobject *)realloc(display_mode_objects, sizeof(jobject)*list_size);
					if (display_mode_objects == NULL)
						return NULL;
				}
				displayMode = createDisplayMode(env, &DevMode);
				display_mode_objects[n++] = displayMode;
			}
		}
//	}
	printfDebugJava(env, "Found %d displaymodes", n);

	ret = (*env)->NewObjectArray(env, n, displayModeClass, NULL);
	for (i = 0; i < n; i++) {
		(*env)->SetObjectArrayElement(env, ret, i, display_mode_objects[i]);
	}
	free(display_mode_objects);   
	return ret;
}
DisplayModeManagerPimpl::DisplayModeManagerPimpl()
{
	std::set<std::pair<int, int> > unique_resolutions;
	std::vector<std::pair<int, int> > sorted_modes;

	DEVMODE display_setting;
	display_setting.dmSize = sizeof(DEVMODE);
	
	EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &display_setting);
	int i = 0;
	int bpp;
	bpp = display_setting.dmBitsPerPel;
	sorted_modes.push_back(std::make_pair(display_setting.dmPelsWidth, display_setting.dmPelsHeight));

	while (EnumDisplaySettings(NULL, i, &display_setting))
	{
		if (display_setting.dmBitsPerPel == bpp)
		{
			unique_resolutions.insert(std::make_pair(display_setting.dmPelsWidth, display_setting.dmPelsHeight));
		}
		++i;
	}

	for (std::set<std::pair<int, int> >::iterator it = unique_resolutions.begin(); it != unique_resolutions.end(); ++it)
	{
		sorted_modes.push_back(*it);
	}
	std::sort(sorted_modes.begin()+1, sorted_modes.end());

	mode_count = sorted_modes.size();
	modes = new DisplayMode[mode_count];

	for (unsigned int i = 0; i < sorted_modes.size(); ++i)
	{
		modes[i].width = sorted_modes[i].first;
		modes[i].height = sorted_modes[i].second;
	}

}
Ejemplo n.º 23
0
void NzVideoModeImpl::GetFullscreenModes(std::vector<NzVideoMode>& modes)
{
	DEVMODE win32Mode;
	win32Mode.dmSize = sizeof(DEVMODE);
	for (unsigned int i = 0; EnumDisplaySettings(nullptr, i, &win32Mode); ++i)
	{
		NzVideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, static_cast<nzUInt8>(win32Mode.dmBitsPerPel));

		// Il existe plusieurs modes avec ces trois caractéristques identiques
		if (std::find(modes.begin(), modes.end(), mode) == modes.end())
			modes.push_back(mode);
	}
}
Ejemplo n.º 24
0
//! \return Returns a pointer to a list with all video modes supported
//! by the gfx adapter.
video::IVideoModeList* CIrrDeviceWin32::getVideoModeList()
{
	if (!VideoModeList.getVideoModeCount())
	{
		// enumerate video modes.
		DWORD i=0;
		DEVMODE mode;

		while (EnumDisplaySettings(NULL, i, &mode))
		{
			VideoModeList.addMode(core::dimension2d<s32>(mode.dmPelsWidth, mode.dmPelsHeight),
				mode.dmBitsPerPel);

			++i;
		}

		if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode))
			VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d<s32>(mode.dmPelsWidth, mode.dmPelsHeight));
	}

	return &VideoModeList;
}
Ejemplo n.º 25
0
void GLWindow::initialize()
{
	isActive			= true;
	isFullscreen		= false;
	windowedMode	= 1; 
	fullscreenMode = 0; 

	EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &nativeMode);

	videoModes[0] = VideoMode(4*nativeMode.dmPelsWidth/4, 4*nativeMode.dmPelsHeight/4, 32);
	videoModes[1] = VideoMode(3*nativeMode.dmPelsWidth/4, 3*nativeMode.dmPelsHeight/4, 32);
	videoModes[2] = VideoMode(2*nativeMode.dmPelsWidth/4, 2*nativeMode.dmPelsHeight/4, 32);
}
Ejemplo n.º 26
0
// 获得最大显示模式时屏幕的宽度和高度(以像素为单位)
void CContourView::GetLargestDisplayMode( int* pcxBitmap, int* pcyBitmap )
{
    DEVMODE devmode;
    int iModeNum = 0;
    ZeroMemory( &devmode, sizeof( DEVMODE ) );
    devmode.dmSize = sizeof( DEVMODE );

    while( EnumDisplaySettings( NULL, iModeNum++, &devmode ) )
    {
        *pcxBitmap = max( *pcxBitmap, ( int )devmode.dmPelsWidth );
        *pcyBitmap = max( *pcyBitmap, ( int )devmode.dmPelsHeight );
    }
}
Ejemplo n.º 27
0
	D3D9VideoOutputInfo::D3D9VideoOutputInfo(IDirect3D9* d3d9device, UINT32 adapterIdx)
		:mMonitorHandle(0)
	{
		IDirect3D9* pD3D = D3D9RenderAPI::getDirect3D9();

		D3DADAPTER_IDENTIFIER9 adapterIdentifier;
		pD3D->GetAdapterIdentifier(adapterIdx, 0, &adapterIdentifier);

		mName = adapterIdentifier.DeviceName;

		for (UINT32 i = 0; i < pD3D->GetAdapterModeCount(adapterIdx, D3DFMT_X8R8G8B8); i++)
		{
			D3DDISPLAYMODE displayMode;
			pD3D->EnumAdapterModes(adapterIdx, D3DFMT_X8R8G8B8, i, &displayMode);

			bool foundVideoMode = false;
			for (auto videoMode : mVideoModes)
			{
				D3D9VideoMode* d3d9videoMode = static_cast<D3D9VideoMode*>(videoMode);

				UINT32 intRefresh = Math::roundToInt(d3d9videoMode->mRefreshRate);
				if (d3d9videoMode->mWidth == displayMode.Width && d3d9videoMode->mHeight == displayMode.Height && intRefresh == displayMode.RefreshRate)
				{
					foundVideoMode = true;
					break;
				}
			}

			if (!foundVideoMode)
			{
				D3D9VideoMode* videoMode = bs_new<D3D9VideoMode>(displayMode.Width, displayMode.Height, (float)displayMode.RefreshRate, adapterIdx);

				mVideoModes.push_back(videoMode);
			}
		}

		// Get desktop display mode
		HMONITOR hMonitor = pD3D->GetAdapterMonitor(adapterIdx);
		MONITORINFOEX monitorInfo;
		monitorInfo.cbSize = sizeof(MONITORINFOEX);
		GetMonitorInfo(hMonitor, &monitorInfo);

		DEVMODE devMode;
		devMode.dmSize = sizeof(DEVMODE);
		devMode.dmDriverExtra = 0;
		EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);

		D3D9VideoMode* desktopVideoMode = bs_new<D3D9VideoMode>(devMode.dmPelsWidth, devMode.dmPelsHeight, (float)devMode.dmDisplayFrequency, adapterIdx);

		mDesktopVideoMode = desktopVideoMode;
	}
Ejemplo n.º 28
0
/** Get the refresh rate for the monitor, in Hz */
static int
get_refresh_rate(void)
{
   DEVMODE devModes;

   if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devModes)) {
      /* clamp the value, just in case we get garbage */
      return CLAMP(devModes.dmDisplayFrequency, 30, 120);
   }
   else {
      /* reasonable default */
      return 60;
   }
}
int getNextDisplayResDown(int *xScrnRes, int *yScrnRes, int colorDepth)
{
	DEVMODE dm;
   int displayFound = 0;
	int i;
   
	i = 0;
	while (EnumDisplaySettings(NULL, i++, &dm)) 
   {
      if (dm.dmBitsPerPel == colorDepth)
      if ((dm.dmPelsWidth == *xScrnRes) && (dm.dmPelsHeight == *yScrnRes))
      {
         displayFound = 1;
         break;
      }
   }
   
   if (!displayFound)
   return -1;
   
   while (EnumDisplaySettings(NULL, i++, &dm)) 
   {
      if (dm.dmBitsPerPel == colorDepth)
      if ((dm.dmPelsWidth < *xScrnRes) || (dm.dmPelsHeight < *yScrnRes))
      break;
   }
   
   if ((dm.dmBitsPerPel != colorDepth) ||
      ((dm.dmPelsWidth >= *xScrnRes) && (dm.dmPelsHeight >= *yScrnRes)))
   return -1;
   
   *xScrnRes = dm.dmPelsWidth;
   *yScrnRes = dm.dmPelsHeight;
   i--;
   
	return i;
}
bool CScreenManager::SetLowResolution()
{
	if(!m_bInit)
	{
		return false;
	}

	DEVMODE DevMod;
    DevMod.dmSize = sizeof(DEVMODE);
    if (!EnumDisplaySettings(m_MainDevice.DeviceName, ENUM_CURRENT_SETTINGS, &DevMod))
    {
		DoLog("Failed to enum display settings, low resolution canceled", MSG_ERROR);
        return false;
    }
 
	if( (DevMod.dmPelsWidth <= 1366) || (DevMod.dmPelsWidth <= 768) )
	{
		DoLog("Screen has already a low res, ignore resolution change", MSG_WARNING);
		return true;
	}

	// Flag for what we want to set
	DevMod.dmFields = (DM_PELSWIDTH | DM_PELSHEIGHT);

	// Try a 19/9 low res
    DevMod.dmPelsWidth = 1366;
    DevMod.dmPelsHeight = 768;   
    if (ChangeDisplaySettings(&DevMod, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
    {
		// Try a 4/3 low res
		DevMod.dmPelsWidth = 1024;
		DevMod.dmPelsHeight = 768;
		if (ChangeDisplaySettings(&DevMod, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
		{
			DoLog("Low resolution display settings not supported, canceled", MSG_ERROR);
			return false;
		 }
    }
 
    if(ChangeDisplaySettings(&DevMod, 0) != DISP_CHANGE_SUCCESSFUL)
	{
		DoLog("Failed to apply low resolution display settings", MSG_ERROR);
        return false;
	}

	m_bIsLowRes = true;
	
	return true;
}