PDA

View Full Version : Full Screen OpenGL



omega arts
05-07-2002, 03:41 PM
Im trying to make a program that has a full screen like in video games. The code that is giving in OpenGl Game Programming gives you code for full screen but there is still a bar at the top. Here is the code if you know how to remove the bar please tell me the code change.I think I wrote all the code that deals with full screen If the code change is anywhere is in a window/glaux program tell me where if is.

if (fullScreen)
{
DEVMODE dmScreen Settings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=(dmScreenSettings);
dmScreenSettings.dmPelsWidth=width;
dmScreenSettings.dmPelsHeight=height;
dmScreenSettings.dmPelsBitsPerPel=bits;
dmScreenSettings.dmFields=DM_BITSPERPEL|
DM_PELSWIDTH|DM_PELSHEIGHT;

if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) !=DISP_CHANGE_SUCCESSFUL)
{
MessageBox(NULL, "DISPALY MODE FAILED", NULL, MB_OK);
fullScreen=FALSE;
}
}

if (fullScreen)
{
dwExStyle=WS_EX_APPWINDOW;
dwStyle=WS_POPUP;
ShowCursor(FALSE);
}

zeckensack
05-08-2002, 02:49 AM
WS_POPUP is definitely the right thing here. I don't know about WS_EX_APPWINDOW though, I've never used extended styles for OpenGL windows, nor do I see the need to do so.

That's what works for me, after switching the display mode.

HWND window=CreateWindow("blah","blah",
WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLING S,
0,0,x,y,NULL,NULL,hInst,NULL);

[This message has been edited by zeckensack (edited 05-08-2002).]

Furrage
05-10-2002, 07:56 AM
This is the code I use to set up full screen mode. It works fine so hopefully it helps.



DEVMODE dmScreenSettings; // Create device mode structure.
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
// Clear memory.
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
// Set size of device mode structure.
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dmScreenSettings);
// Get current screen settings to determine bits per pixel.
if (MessageBox(NULL, "Switch to full screen mode?", "Full Screen?", MB_YESNO | MB_ICONQUESTION) == IDYES) {
// Prompt for screen mode. If fullscreen mode chosen...
dmScreenSettings.dmPelsWidth = ogsSCREENWIDTH;
// Indicate desired screen width.
dmScreenSettings.dmPelsHeight = ogsSCREENHEIGHT;
// Indicate desired screen height
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
// Indicate fields being changed.
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
// Change display settings to desired format. If failed...
Log = fopen("Error.log", "a");
// Open error log.
fprintf(Log, "Could not enter full screen mode.\n");
// Note error.
fclose(Log); // Close log.
MessageBox(NULL, "Could not enter full screen mode. Selecting windowed mode.", "Error", MB_OK | MB_ICONEXCLAMATION);
// Indicate error.
}
else FullScreenMode = TRUE;
// Successfully entered full screen mode.
}

DWORD dwStyle, dwExStyle; // Windows style and extended style.
if (FullScreenMode) { // If in full screen mode set styles for full screen mode.
dwExStyle = WS_EX_APPWINDOW;
dwStyle = WS_POPUP;
}
else { // Otherwise set options for windowed mode.
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle = WS_OVERLAPPEDWINDOW;
}

// (TODO) Uncomment to hide mouse.
// ShowCursor(FALSE); // Hide mouse pointer.

RECT WindowRect = {0, 0, ogsSCREENWIDTH, ogsSCREENHEIGHT};
// Rectangle containing window's dimensions.
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
// Adjust rectangle to represent true window's size.
if (!FullScreenMode) { // If not in full screen mode...
int OffsetX = (dmScreenSettings.dmPelsWidth - ogsSCREENWIDTH) / 2;
int OffsetY = (dmScreenSettings.dmPelsHeight - ogsSCREENHEIGHT) / 2;
// Calculate window offset.
OffsetRect(&WindowRect, OffsetX, OffsetY);
// Reposition window rectangle.
}
if (!(hWnd = CreateWindowEx(dwExStyle, WindowClassName, WindowClassName, dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WindowRect.left, WindowRect.top, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, hInstance, NULL))) {
// Create window. If failed...
Log = fopen("Error.log", "a");
// Open error log.
fprintf(Log, "Could not create window.\n");
// Note error.
fclose(Log); // Close log.

marcus256
05-12-2002, 10:03 PM
You will probably notice that there is a lot more to fullscreen mode handling...

What to do with the mouse cursor?
What to do when a user presses ALT+TAB or Win+M?
...

Have you checked out GLFW (http://hem.passagen.se/opengl/glfw/) ? It deals with these things, and gives you a very neat framework at the same time. http://www.opengl.org/discussion_boards/ubb/smile.gif