Full Screen OpenGL Program

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.