Results 1 to 4 of 4

Thread: [C++/SDL] Check for Fullscreen

  1. #1
    Join Date
    May 2008
    Beans
    1,029

    Question [C++/SDL] Check for Fullscreen

    Is there a way to check if an SDL window is in fullscreen? Right now I am just setting a boolean variable when I put it in fullscreen.

    PHP Code:
    #define WN 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF
    #define FS 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN

    SDL_Surface *MWindow;

    bool fullscreen false;

    if (
    fullscreen)
    {
        
    fullscreen false;
        
    MWindow SDL_SetVideoMode(WN);
    }
    else
    {
        
    fullscreen true;
        
    MWindow SDL_SetVideoMode(FS);

    Edit: SDL has the function SDL_WM_ToggleFullscreen. But it only works for X11, I am looking for something that is cross-platform.
    Last edited by dodle; March 2nd, 2011 at 01:54 AM. Reason: Changed MWindow to pointer

  2. #2
    Join Date
    Jul 2007
    Location
    Indianapolis, IN
    Beans
    68
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: [C++/SDL] Check for Fullscreen

    Quote Originally Posted by dodle View Post
    Is there a way to check if an SDL window is in fullscreen?
    Just a couple thoughts...

    Is there a way to query the dimensions of the root window and the current window and see if they're the same? And possibly a way to find out if the client area of the window is the same size as the physical window area, indicating there is no border?

    - Rick C. Hodgin
    John 14:6 - Jesus speaking about Himself said "I am the way, the truth, and the life. No one comes to the Father [Heaven], but by me."

  3. #3
    Join Date
    May 2008
    Beans
    1,029

    Re: [C++/SDL] Check for Fullscreen

    I can get the size of the window using m and w:

    PHP Code:
    #define WN 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF
    #define FS 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN

    SDL_Surface *MWindow;
    int width;
    int height;

    bool fullscreen false;

    if (
    fullscreen)
    {
        
    fullscreen false;
        
    MWindow SDL_SetVideoMode(WN);
    }
    else
    {
        
    fullscreen true;
        
    MWindow SDL_SetVideoMode(FS);
    }

    width MWindow->w;
    height MWindow->h
    But I have no clue how to get size of the (screen/client area?), I assume that is platform specific.

  4. #4
    Join Date
    May 2008
    Beans
    1,029

    Talking Re: [C++/SDL] Check for Fullscreen

    SOLVED! I was able to check for fullscreen with:

    PHP Code:
    (SDL_Surface->flags SDL_FULLSCREEN); 
    Example code:
    PHP Code:
    #include <iostream>
    #include <SDL/SDL.h>
    using namespace std;

    int IsFullScreen(SDL_Surface *surface)
    {
        
    // Return true if fullscreen
        
    if (surface->flags SDL_FULLSCREEN) return 1;
        
        
    // Return false if windowed
        
    return 0;
    }

    int main()
    {
        
    SDL_Surface *mwindow;
        
        
    // Start SDL
        
    if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return 1;
        
        
    // Create a video surface
        
    if ((mwindow SDL_SetVideoMode(80060032SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN)) == NULL) return 1;
        
        
    // Check if the surface is in fullscreen
        
    if (IsFullScreen(mwindow)) cout << "Fullscreen\n";
        else 
    cout << "Windowed\n";
        
        
    // Cleanup
        
    SDL_FreeSurface(mwindow);
        
    SDL_Quit();
        
        return 
    0;


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •