Results 1 to 4 of 4

Thread: Full Screen OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    Little Rock, AR,
    Posts
    7

    Full Screen OpenGL

    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);
    }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Full Screen OpenGL

    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.
    Code :
    HWND window=CreateWindow("blah","blah",
    		WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
    		0,0,x,y,NULL,NULL,hInst,NULL);
    [This message has been edited by zeckensack (edited 05-08-2002).]

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    282

    Re: Full Screen OpenGL

    This is the code I use to set up full screen mode. It works fine so hopefully it helps.
    Code :
    	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.

  4. #4
    Senior Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    764

    Re: Full Screen OpenGL

    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 ? It deals with these things, and gives you a very neat framework at the same time.

Similar Threads

  1. Full Screen antialiasing in iphone opengl
    By quint- iphone designer in forum OpenGL: macOS
    Replies: 7
    Last Post: 11-05-2010, 11:17 AM
  2. Full-Screen OpenGL App
    By MKAI in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 06-17-2003, 02:16 AM
  3. Possible openGL problem with full screen programs
    By in forum OpenGL: User Software
    Replies: 0
    Last Post: 09-20-2002, 08:57 AM
  4. Full Screen Mode w/openGL in MFC SDI
    By pleopard in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-24-2002, 02:30 PM
  5. How to create a OpenGL full-screen?
    By dodocool in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-01-2000, 07:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean