Omdat bij OpenGL je met rendercontexts werkt die verbinding
hebben met je window, is het niet mogelijk om een popup
window zonder frame (wat je opent bij fullscreen) te
vervangen door een framed window bij windowed mode en TOCH
je rendercontext te behouden. Dit is ook de reden waarom
bij Quake based games wanneer je iets wijzigt in je
screensettings de game opnieuw alles laadt (textures etc).
Hieronder heb ik codesnippets geplakt uit de DemoGL
Sourcecode. DemoGL is een library voor OpenGL based
effects, die je programmeert in C++. (
http://www.demogl.com)
Naar full screen switchen: (staat wellicht wat overbodige
code in voor je, maar je krijgt een idee

)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| // Purpose: switches the screenmode to fullscreen.
//
// Returns: SYS_OK if succeeded, SYS_NOK if not.
int
SwitchToFullScreen()
{
DEVMODE dMode;
int iModeNo, iResult;
bool bModeSwitch;
long lChangeResult;
// Walk all modes supported
for(iModeNo=0, bModeSwitch=false;!bModeSwitch;)
{
bModeSwitch = !EnumDisplaySettings(NULL, iModeNo, &dMode );
if(dMode.dmBitsPerPel == (unsigned int)m_gpDemoDat->GetiDepth()&&
dMode.dmPelsWidth == (unsigned int)m_gpDemoDat->GetiWindowWidth() &&
dMode.dmPelsHeight == (unsigned int)m_gpDemoDat->GetiWindowHeight())
{
break;
}
iModeNo++;
}
if(bModeSwitch)
{
// didn't find mode
ChangeDisplaySettings(NULL, 0);
MessageBox(m_gpDemoDat->GethWnd(), "Couldn't switch to full screen." , "DemoGL Init Error",MB_ICONERROR|MB_APPLMODAL);
return SYS_NOK;
}
dMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
lChangeResult = ChangeDisplaySettings(&dMode, CDS_TEST);
switch (lChangeResult)
{
case DISP_CHANGE_SUCCESSFUL:
{
ChangeDisplaySettings(&dMode, CDS_FULLSCREEN);
};break;
case DISP_CHANGE_FAILED:
{
MessageBox(NULL,
"DemoGL failed to change the screenresolution and desktop bitdepth to the desired settings. Try Windowed Appearance.",
"DemoGL Error occured",MB_ICONERROR|MB_APPLMODAL);
return SYS_NOK;
};break;
case DISP_CHANGE_BADMODE:
{
MessageBox(NULL,
"The fullscreen mode you selected, with the options you selected, is not supported by your system. Try a lower bitdepth for Display Quality.",
"DemoGL Error occured",MB_ICONERROR|MB_APPLMODAL);
return SYS_NOK;
};break;
case DISP_CHANGE_RESTART:
{
// the user has to reboot to get the fullscreen setting, because the drivers in the system and the system itself (win95
// first release) are not able to switch the resolution using this call. (they are, but the nagging thing is.... we're not
// allowed :(
// The user doesn't have to reboot if the user matches the bitdepth and resolution of the desktop.
iResult=MessageBox(NULL,
"The fullscreen mode you selected requires a reboot, according to windows or your videocard drivers.\n\nDo you want to ignore the reboot message and continue? (it might refuse to work)",
"DemoGL Error occured",MB_ICONERROR|MB_APPLMODAL|MB_YESNO);
if(iResult==IDYES)
{
// User wants to continue...
lChangeResult=ChangeDisplaySettings(&dMode, CDS_FULLSCREEN);
if(lChangeResult==DISP_CHANGE_FAILED)
{
MessageBox(NULL,
"DemoGL failed to change the screenresolution and desktop bitdepth to the desired settings. Try Windowed Appearance.",
"DemoGL Error occured",MB_ICONERROR|MB_APPLMODAL);
return SYS_NOK;
}
else
{
// successful
break;
}
}
else
{
// user doesn't want to continue...
return SYS_NOK;
}
};break;
}
return SYS_OK;
} |
Window openen: (geen functie, is codesnippet uit functie)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| // ... other code
// Create windowframe because all went well.
if(m_gpDemoDat->GetbFullScreen())
{
if(SwitchToFullScreen()==SYS_NOK)
{
// error occured...
// let the user select another option. so don't quit.
// unregister class.
UnregisterClass(sAppName,m_gpDemoDat->GethInstance());
// continue
return SYS_CW_RECOVERABLEERROR;
}
else
{
// remove cursor
ShowCursor(FALSE);
}
// create an always on top borderless window.
// FIXED:
// [FB] 29-mar-2001: removed WS_EX_TOPMOST
hWnd = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_NOPARENTNOTIFY, sAppName,sWindowTitle,
WS_POPUP , 0, 0, m_gpDemoDat->GetiWindowWidth(),
m_gpDemoDat->GetiWindowHeight(), hParentWnd, NULL, m_gpDemoDat->GethInstance(), NULL);
}
else
{
// create a window with no system menubuttons or resizing capabilities.
// FIXED:
// [FB] 29-mar-2001: removed WS_EX_TOPMOST
hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, sAppName,sWindowTitle,
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, m_gpDemoDat->GetiWindowWidth(),
m_gpDemoDat->GetiWindowHeight(), hParentWnd, NULL, m_gpDemoDat->GethInstance(), NULL);
}
// ... other code |
Enfin, you get the thrill.