PageRenderTime 12ms CodeModel.GetById 6ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Core_WindowEvents/Win32OpenGL/DisplayModeManagerPimpl_WINDOWS.cpp

http://github.com/Akranar/daguerreo
C++ | 49 lines | 41 code | 8 blank | 0 comment | 6 complexity | adad65c2c697d84095b7292f1e71a309 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
 1#include "DisplayModeManagerPimpl_WINDOWS.h"
 2#include <vector>
 3#include <set>
 4#include <algorithm>
 5#include <iostream>
 6
 7DisplayModeManagerPimpl::DisplayModeManagerPimpl()
 8{
 9	std::set<std::pair<int, int> > unique_resolutions;
10	std::vector<std::pair<int, int> > sorted_modes;
11
12	DEVMODE display_setting;
13	display_setting.dmSize = sizeof(DEVMODE);
14	
15	EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &display_setting);
16	int i = 0;
17	int bpp;
18	bpp = display_setting.dmBitsPerPel;
19	sorted_modes.push_back(std::make_pair(display_setting.dmPelsWidth, display_setting.dmPelsHeight));
20
21	while (EnumDisplaySettings(NULL, i, &display_setting))
22	{
23		if (display_setting.dmBitsPerPel == bpp)
24		{
25			unique_resolutions.insert(std::make_pair(display_setting.dmPelsWidth, display_setting.dmPelsHeight));
26		}
27		++i;
28	}
29
30	for (std::set<std::pair<int, int> >::iterator it = unique_resolutions.begin(); it != unique_resolutions.end(); ++it)
31	{
32		sorted_modes.push_back(*it);
33	}
34	std::sort(sorted_modes.begin()+1, sorted_modes.end());
35
36	mode_count = sorted_modes.size();
37	modes = new DisplayMode[mode_count];
38
39	for (unsigned int i = 0; i < sorted_modes.size(); ++i)
40	{
41		modes[i].width = sorted_modes[i].first;
42		modes[i].height = sorted_modes[i].second;
43	}
44
45}
46DisplayModeManagerPimpl::~DisplayModeManagerPimpl()
47{
48	delete [] modes;
49}