In fact, the principle of full screen OpenGL in BCB is very simple, as long as in the window OpenGL program based on a small change can be: As long as the window properties modified to Ws_popup on it.
Specifically as follows:
Add the following statement to the Createparam () member function of the window class:
params.style=ws_popup| ws_clipchildren| Ws_clipsiblings;
Modify the corresponding window to Ws_popup window and the other two to support OpenGL.
Createparam () member function that is still in the window class, add the following statement:
Changeresolution (800,600);
params.width=800;
params.height=600;
params.x=params.y=0;
The first sentence sets the screen resolution to 800x600 (can be any value supported by the display card)
Then modify the form size to fill the full screen.
Changeresolution () is a small function of a custom, and its principle is as follows:
Query with Winapi:enumdisplaysettings () and get the desired display mode
Modify the display mode with Winapi:changedisplaysettings ().
Complete code for Changeresolution ():
BOOL Changeresolution (DWORD W, DWORD h) {
DEVMODE DEVMODE;
LONG Modeswitch;
LONG i;
CHAR buf[256];
i = 0;
do {
Modeswitch = EnumDisplaySettings (NULL, I, &devmode);
i++;
while ((DEVMODE.DMBITSPERPEL!=16)
|| (Devmode.dmpelswidth!= W)
|| (devmode.dmpelsheight!= h))
&& (Modeswitch));
/* Okay If we found a mode * *
if (!modeswitch) {}
else {
Modeswitch = changedisplaysettings (&devmode, 0);
if (modeswitch!=disp_change_successful)
{
Might be running in Windows95, let's try without the Hertz change
Devmode.dmbitsperpel = 16;
Devmode.dmpelswidth = W;
Devmode.dmpelsheight = h;
Devmode.dmfields = Dm_bitsperpel | Dm_pelswidth | Dm_pelsheight;
Modeswitch = changedisplaysettings (&devmode, 0);
}
}
return TRUE;
}
Sample Program
Description: Usually this program will see the bottom of the screen in a white line, this is caused by the taskbar, if you will be its total in front (always on top) removed or the program window as a always on "top type" will not see it again.