ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/daodan_gl.c
Revision: 316
Committed: Mon May 4 12:42:46 2009 UTC (16 years, 5 months ago) by rossy
Content type: text/x-csrc
File size: 2733 byte(s)
Log Message:
custom resoultions :)

File Contents

# Content
1 #include "daodan_gl.h"
2
3 #define max_modes (104) // Dirty hack to add more resolutions, it really should only be 16 ^_^
4 #define builtin_modes (sizeof(daodan_reslist) / sizeof(M3tDisplayMode))
5 #define builtin_depths (sizeof(daodan_resdepths) / sizeof(short))
6
7 const M3tDisplayMode daodan_reslist[] = {
8 { 720 , 480, 0, 0 },
9 { 720 , 576, 0, 0 },
10 { 768 , 480, 0, 0 },
11 { 800 , 480, 0, 0 },
12 { 852 , 480, 0, 0 },
13 { 856 , 480, 0, 0 },
14 { 960 , 540, 0, 0 },
15 { 960 , 720, 0, 0 },
16 { 1024, 576, 0, 0 },
17 { 1024, 600, 0, 0 },
18 { 1024, 640, 0, 0 },
19 { 1024, 768, 0, 0 },
20 { 1152, 768, 0, 0 },
21 { 1152, 864, 0, 0 },
22 { 1280, 720, 0, 0 },
23 { 1280, 768, 0, 0 },
24 { 1280, 800, 0, 0 },
25 { 1280, 960, 0, 0 },
26 { 1280, 1024, 0, 0 },
27 { 1366, 768, 0, 0 },
28 { 1400, 1050, 0, 0 },
29 { 1440, 900, 0, 0 },
30 { 1600, 900, 0, 0 },
31 { 1600, 1200, 0, 0 },
32 { 1920, 1080, 0, 0 },
33 { 1920, 1440, 0, 0 },
34 };
35
36 const short daodan_resdepths[] = { 16, 32 };
37
38 unsigned int ONICALL daodan_enumerate_valid_display_modes(M3tDisplayMode modes[max_modes])
39 {
40 unsigned int vmodes = 0;
41 unsigned int screen_x = GetSystemMetrics(SM_CXSCREEN);
42 unsigned int screen_y = GetSystemMetrics(SM_CYSCREEN);
43
44 int i, j;
45
46 for (i = 0; i < builtin_depths; i ++)
47 {
48 modes[vmodes].Width = 640;
49 modes[vmodes].Height = 480;
50 modes[vmodes].Depth = daodan_resdepths[i];
51
52 if (++vmodes == max_modes - builtin_modes + i)
53 goto modesfull;
54
55 for (j = 0; j < builtin_modes; j ++)
56 if (!(daodan_reslist[j].Width == 640 && daodan_reslist[j].Height == 480) && !(daodan_reslist[j].Width == screen_x && daodan_reslist[j].Height == screen_y) &&
57 ((daodan_reslist[j].Width < screen_x && daodan_reslist[j].Height < screen_y) || daodan_testmode(daodan_reslist[j])))
58 {
59 modes[vmodes].Width = daodan_reslist[j].Width;
60 modes[vmodes].Height = daodan_reslist[j].Height;
61 modes[vmodes].Depth = daodan_resdepths[i];
62
63 if (++vmodes == max_modes - builtin_modes + i)
64 goto modesfull;
65 }
66
67 modes[vmodes].Width = GetSystemMetrics(SM_CXSCREEN);
68 modes[vmodes].Height = GetSystemMetrics(SM_CYSCREEN);
69 modes[vmodes].Depth = daodan_resdepths[i];
70
71 if (++vmodes == max_modes - builtin_modes + i)
72 goto modesfull;
73 }
74
75 modesfull:
76 return vmodes;
77 }
78
79 bool daodan_testmode(M3tDisplayMode mode)
80 {
81 DEVMODE devmode;
82 memset(&devmode, 0, sizeof(devmode));
83
84 devmode.dmSize = sizeof(devmode);
85 devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
86 devmode.dmBitsPerPel = mode.Depth;
87 devmode.dmPelsWidth = mode.Width;
88 devmode.dmPelsHeight = mode.Height;
89
90 return (ChangeDisplaySettings(&devmode, CDS_TEST) == DISP_CHANGE_SUCCESSFUL);
91 }