src/video/windows/SDL_windowsmodes.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 15 Feb 2011 23:07:14 -0800
changeset 5305 75f5ff92ad08
parent 5262 b530ef003506
child 5535 96594ac5fd1a
permissions -rwxr-xr-x
Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5250
diff changeset
     3
    Copyright (C) 1997-2011 Sam Lantinga
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 4569
diff changeset
    24
#include "SDL_windowsvideo.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    26
/* Windows CE compatibility */
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    27
#ifndef CDS_FULLSCREEN
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    28
#define CDS_FULLSCREEN 0
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    29
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
static SDL_bool
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
    SDL_DisplayModeData *data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    DEVMODE devmode;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    36
#ifndef _WIN32_WCE
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
    HDC hdc;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    38
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
    devmode.dmSize = sizeof(devmode);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    devmode.dmDriverExtra = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    if (!EnumDisplaySettings(deviceName, index, &devmode)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
        return SDL_FALSE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
    data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
    if (!data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
        return SDL_FALSE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
    data->DeviceMode = devmode;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
    data->DeviceMode.dmFields =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
        (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
         DM_DISPLAYFLAGS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
    /* Fill in the mode information */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    56
    mode->format = SDL_PIXELFORMAT_UNKNOWN;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
    mode->w = devmode.dmPelsWidth;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    mode->h = devmode.dmPelsHeight;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
    mode->refresh_rate = devmode.dmDisplayFrequency;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    mode->driverdata = data;
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    61
#ifdef _WIN32_WCE
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    62
    /* In WinCE EnumDisplaySettings(ENUM_CURRENT_SETTINGS) doesn't take the user defined orientation
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
    63
       into account but GetSystemMetrics does. */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
    64
    if (index == ENUM_CURRENT_SETTINGS) {
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
    65
        mode->w = GetSystemMetrics(SM_CXSCREEN);
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
    66
        mode->h = GetSystemMetrics(SM_CYSCREEN);
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    67
    }
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    68
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    70
/* WinCE has no GetDIBits, therefore we can't use it to get the display format */
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    71
#ifndef _WIN32_WCE
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    72
    if (index == ENUM_CURRENT_SETTINGS
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    73
        && (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
        char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
        LPBITMAPINFO bmi;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
        HBITMAP hbm;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
        SDL_zero(bmi_data);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
        bmi = (LPBITMAPINFO) bmi_data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        hbm = CreateCompatibleBitmap(hdc, 1, 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
        GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
        DeleteObject(hbm);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
        DeleteDC(hdc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
        if (bmi->bmiHeader.biCompression == BI_BITFIELDS) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
            switch (*(Uint32 *) bmi->bmiColors) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
            case 0x00FF0000:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    90
                mode->format = SDL_PIXELFORMAT_RGB888;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
            case 0x000000FF:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    93
                mode->format = SDL_PIXELFORMAT_BGR888;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
            case 0xF800:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    96
                mode->format = SDL_PIXELFORMAT_RGB565;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
            case 0x7C00:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    99
                mode->format = SDL_PIXELFORMAT_RGB555;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
        } else if (bmi->bmiHeader.biBitCount == 8) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   103
            mode->format = SDL_PIXELFORMAT_INDEX8;
3175
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   104
        } else if (bmi->bmiHeader.biBitCount == 4) {
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   105
            mode->format = SDL_PIXELFORMAT_INDEX4LSB;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
        }
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   107
    } else
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   108
#endif /* _WIN32_WCE */
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   109
    {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   110
        /* FIXME: Can we tell what this will be? */
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3175
diff changeset
   111
        if ((devmode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
3175
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   112
            switch (devmode.dmBitsPerPel) {
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   113
            case 32:
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   114
                mode->format = SDL_PIXELFORMAT_RGB888;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   115
                break;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   116
            case 24:
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   117
                mode->format = SDL_PIXELFORMAT_RGB24;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   118
                break;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   119
            case 16:
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   120
                mode->format = SDL_PIXELFORMAT_RGB565;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   121
                break;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   122
            case 15:
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   123
                mode->format = SDL_PIXELFORMAT_RGB555;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   124
                break;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   125
            case 8:
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   126
                mode->format = SDL_PIXELFORMAT_INDEX8;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   127
                break;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   128
            case 4:
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   129
                mode->format = SDL_PIXELFORMAT_INDEX4LSB;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   130
                break;
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   131
            }
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3175
diff changeset
   132
        }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
    return SDL_TRUE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
2149
eba4fd03b4f6 Fixed mode code under VMware running Windows 98
Sam Lantinga <slouken@libsdl.org>
parents: 2119
diff changeset
   137
static SDL_bool
2119
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   138
WIN_AddDisplay(LPTSTR DeviceName)
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   139
{
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   140
    SDL_VideoDisplay display;
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   141
    SDL_DisplayData *displaydata;
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   142
    SDL_DisplayMode mode;
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   143
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   144
#ifdef DEBUG_MODES
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   145
    printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   146
#endif
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   147
    if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
2149
eba4fd03b4f6 Fixed mode code under VMware running Windows 98
Sam Lantinga <slouken@libsdl.org>
parents: 2119
diff changeset
   148
        return SDL_FALSE;
2119
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   149
    }
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   150
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   151
    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   152
    if (!displaydata) {
2149
eba4fd03b4f6 Fixed mode code under VMware running Windows 98
Sam Lantinga <slouken@libsdl.org>
parents: 2119
diff changeset
   153
        return SDL_FALSE;
2119
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   154
    }
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   155
    SDL_memcpy(displaydata->DeviceName, DeviceName,
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   156
               sizeof(displaydata->DeviceName));
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   157
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   158
    SDL_zero(display);
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   159
    display.desktop_mode = mode;
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   160
    display.current_mode = mode;
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   161
    display.driverdata = displaydata;
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   162
    SDL_AddVideoDisplay(&display);
2149
eba4fd03b4f6 Fixed mode code under VMware running Windows 98
Sam Lantinga <slouken@libsdl.org>
parents: 2119
diff changeset
   163
    return SDL_TRUE;
2119
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   164
}
9341a884a4d9 Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   165
3521
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   166
int
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
WIN_InitModes(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
{
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   169
    int pass;
2149
eba4fd03b4f6 Fixed mode code under VMware running Windows 98
Sam Lantinga <slouken@libsdl.org>
parents: 2119
diff changeset
   170
    DWORD i, j, count;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
    DISPLAY_DEVICE device;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
    device.cb = sizeof(device);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   175
    /* Get the primary display in the first pass */
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   176
    for (pass = 0; pass < 2; ++pass) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   177
        for (i = 0; ; ++i) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   178
            TCHAR DeviceName[32];
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   179
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   180
            if (!EnumDisplayDevices(NULL, i, &device, 0)) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
                break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
            if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
                continue;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
            }
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   186
            if (pass == 0) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   187
                if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   188
                    continue;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   189
                }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   190
            } else {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   191
                if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   192
                    continue;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   193
                }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   194
            }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   195
            SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName));
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   196
#ifdef DEBUG_MODES
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   197
            printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   198
#endif
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   199
            count = 0;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   200
            for (j = 0; ; ++j) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   201
                if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   202
                    break;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   203
                }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   204
                if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   205
                    continue;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   206
                }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   207
                if (pass == 0) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   208
                    if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   209
                        continue;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   210
                    }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   211
                } else {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   212
                    if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   213
                        continue;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   214
                    }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   215
                }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   216
                count += WIN_AddDisplay(device.DeviceName);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   217
            }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   218
            if (count == 0) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   219
                WIN_AddDisplay(DeviceName);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   220
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
    }
3521
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   223
    if (_this->num_displays == 0) {
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   224
        SDL_SetError("No displays available");
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   225
        return -1;
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   226
    }
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   227
    return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   230
int
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   231
WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   232
{
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   233
    SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->current_mode.driverdata;
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   234
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   235
#ifdef _WIN32_WCE
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   236
    // WINCE: DEVMODE.dmPosition not found, or may be mingw32ce bug
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   237
    rect->x = 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   238
    rect->y = 0;
5250
f908e06b3c96 Fixed compiling on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   239
    rect->w = _this->windows->w;
f908e06b3c96 Fixed compiling on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   240
    rect->h = _this->windows->h;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   241
#else
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   242
    rect->x = (int)data->DeviceMode.dmPosition.x;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   243
    rect->y = (int)data->DeviceMode.dmPosition.y;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   244
    rect->w = data->DeviceMode.dmPelsWidth;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   245
    rect->h = data->DeviceMode.dmPelsHeight;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   246
#endif
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   247
    return 0;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   248
}
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3521
diff changeset
   249
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
void
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   251
WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
{
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   253
    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
    DWORD i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
    SDL_DisplayMode mode;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
    for (i = 0;; ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
        if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
        }
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   261
        if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   262
            /* We don't support palettized modes now */
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   263
            continue;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   264
        }
3521
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   265
        if (mode.format != SDL_PIXELFORMAT_UNKNOWN) {
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   266
            if (!SDL_AddDisplayMode(display, &mode)) {
3175
e6c113f1ea43 Fixed support for 4bpp video modes enumeration, otherwise mode with zero bpp appears in the list.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   267
                SDL_free(mode.driverdata);
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3175
diff changeset
   268
            }
3521
76f9b76ddf0f Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
   269
        }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
int
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   274
WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
{
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   276
    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
    SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
    LONG status;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
   279
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   280
#ifdef _WIN32_WCE
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   281
    /* TODO: implement correctly.
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   282
       On my Asus MyPAL, if I execute the code below
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   283
       I get DISP_CHANGE_BADFLAGS and the Titlebar of the fullscreen window stays
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
   284
       visible ... (SDL_RaiseWindow() would fix that one) */
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   285
    return 0;
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   286
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
    status =
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   289
        ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode,
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3186
diff changeset
   290
                                NULL, CDS_FULLSCREEN, NULL);
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   291
    if (status != DISP_CHANGE_SUCCESSFUL) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
        const char *reason = "Unknown reason";
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
        switch (status) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
        case DISP_CHANGE_BADFLAGS:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
            reason = "DISP_CHANGE_BADFLAGS";
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
        case DISP_CHANGE_BADMODE:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
            reason = "DISP_CHANGE_BADMODE";
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
        case DISP_CHANGE_BADPARAM:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
            reason = "DISP_CHANGE_BADPARAM";
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
        case DISP_CHANGE_FAILED:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
            reason = "DISP_CHANGE_FAILED";
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
        SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
        return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
    }
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   310
    EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   311
    return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
WIN_QuitModes(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
{
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   317
    /* All fullscreen windows should have restored modes by now */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
/* vi: set ts=4 sw=4 expandtab: */