src/video/SDL_video.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Tue, 10 May 2016 21:14:36 +0200
changeset 10166 2393160743ca
parent 10056 4f139e059592
permissions -rw-r--r--
Fixed missing error message if SDL_GetDisplayDPI() is unsupported.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     1
/*
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     2
  Simple DirectMedia Layer
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9988
diff changeset
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     4
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     5
  This software is provided 'as-is', without any express or implied
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     7
  arising from the use of this software.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     8
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    11
  freely, subject to the following restrictions:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    12
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    14
     claim that you wrote the original software. If you use this software
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    16
     appreciated but is not required.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    18
     misrepresented as being the original software.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 8072
diff changeset
    21
#include "../SDL_internal.h"
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    22
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    23
/* The high-level video driver subsystem */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    24
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    25
#include "SDL.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    26
#include "SDL_video.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    27
#include "SDL_sysvideo.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    28
#include "SDL_blit.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    29
#include "SDL_pixels_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    30
#include "SDL_rect_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    31
#include "../events/SDL_events_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    32
#include "../timer/SDL_timer_c.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    33
8616
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8601
diff changeset
    34
#include "SDL_syswm.h"
ec011c16e2fd Added missing copyright notices
Sam Lantinga <slouken@libsdl.org>
parents: 8601
diff changeset
    35
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    36
#if SDL_VIDEO_OPENGL
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    37
#include "SDL_opengl.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    38
#endif /* SDL_VIDEO_OPENGL */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    39
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    40
#if SDL_VIDEO_OPENGL_ES
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    41
#include "SDL_opengles.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    42
#endif /* SDL_VIDEO_OPENGL_ES */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    43
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    44
/* GL and GLES2 headers conflict on Linux 32 bits */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    45
#if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    46
#include "SDL_opengles2.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    47
#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    48
9416
d5c12b28df2d Patched to compile on OpenGL ES-based platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 9412
diff changeset
    49
#ifndef GL_CONTEXT_RELEASE_BEHAVIOR_KHR
d5c12b28df2d Patched to compile on OpenGL ES-based platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 9412
diff changeset
    50
#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB
d5c12b28df2d Patched to compile on OpenGL ES-based platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 9412
diff changeset
    51
#endif
d5c12b28df2d Patched to compile on OpenGL ES-based platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 9412
diff changeset
    52
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    53
/* On Windows, windows.h defines CreateWindow */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    54
#ifdef CreateWindow
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    55
#undef CreateWindow
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    56
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    57
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    58
/* Available video drivers */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    59
static VideoBootStrap *bootstrap[] = {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    60
#if SDL_VIDEO_DRIVER_COCOA
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    61
    &COCOA_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    62
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    63
#if SDL_VIDEO_DRIVER_X11
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    64
    &X11_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    65
#endif
8153
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    66
#if SDL_VIDEO_DRIVER_MIR
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    67
    &MIR_bootstrap,
3e43c73ac79b Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    68
#endif
9164
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9163
diff changeset
    69
#if SDL_VIDEO_DRIVER_WAYLAND
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9163
diff changeset
    70
    &Wayland_bootstrap,
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9163
diff changeset
    71
#endif
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9163
diff changeset
    72
#if SDL_VIDEO_DRIVER_VIVANTE
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9163
diff changeset
    73
    &VIVANTE_bootstrap,
494876610c49 Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents: 9163
diff changeset
    74
#endif
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    75
#if SDL_VIDEO_DRIVER_DIRECTFB
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    76
    &DirectFB_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    77
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    78
#if SDL_VIDEO_DRIVER_WINDOWS
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    79
    &WINDOWS_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    80
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    81
#if SDL_VIDEO_DRIVER_WINRT
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    82
    &WINRT_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    83
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    84
#if SDL_VIDEO_DRIVER_HAIKU
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    85
    &HAIKU_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    86
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    87
#if SDL_VIDEO_DRIVER_PANDORA
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    88
    &PND_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    89
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    90
#if SDL_VIDEO_DRIVER_UIKIT
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    91
    &UIKIT_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    92
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    93
#if SDL_VIDEO_DRIVER_ANDROID
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    94
    &Android_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    95
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    96
#if SDL_VIDEO_DRIVER_PSP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    97
    &PSP_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    98
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
    99
#if SDL_VIDEO_DRIVER_RPI
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   100
    &RPI_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   101
#endif 
8833
ae720d61d14d Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8823
diff changeset
   102
#if SDL_VIDEO_DRIVER_NACL
ae720d61d14d Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8823
diff changeset
   103
    &NACL_bootstrap,
ae720d61d14d Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8823
diff changeset
   104
#endif
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   105
#if SDL_VIDEO_DRIVER_EMSCRIPTEN
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   106
    &Emscripten_bootstrap,
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9164
diff changeset
   107
#endif
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   108
#if SDL_VIDEO_DRIVER_DUMMY
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   109
    &DUMMY_bootstrap,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   110
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   111
    NULL
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   112
};
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   113
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   114
static SDL_VideoDevice *_this = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   115
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   116
#define CHECK_WINDOW_MAGIC(window, retval) \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   117
    if (!_this) { \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   118
        SDL_UninitializedVideo(); \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   119
        return retval; \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   120
    } \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   121
    if (!window || window->magic != &_this->window_magic) { \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   122
        SDL_SetError("Invalid window"); \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   123
        return retval; \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   124
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   125
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   126
#define CHECK_DISPLAY_INDEX(displayIndex, retval) \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   127
    if (!_this) { \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   128
        SDL_UninitializedVideo(); \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   129
        return retval; \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   130
    } \
8651
b1cb565609dc Static analysis fix: let clang know _this->displays isn't NULL.
Ryan C. Gordon <icculus@icculus.org>
parents: 8616
diff changeset
   131
    SDL_assert(_this->displays != NULL); \
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   132
    if (displayIndex < 0 || displayIndex >= _this->num_displays) { \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   133
        SDL_SetError("displayIndex must be in the range 0 - %d", \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   134
                     _this->num_displays - 1); \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   135
        return retval; \
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   136
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   137
8818
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
   138
#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   139
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   140
#ifdef __MACOSX__
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   141
/* Support for Mac OS X fullscreen spaces */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   142
extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   143
extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   144
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   145
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   146
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   147
/* Support for framebuffer emulation using an accelerated renderer */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   148
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   149
#define SDL_WINDOWTEXTUREDATA   "_SDL_WindowTextureData"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   150
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   151
typedef struct {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   152
    SDL_Renderer *renderer;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   153
    SDL_Texture *texture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   154
    void *pixels;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   155
    int pitch;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   156
    int bytes_per_pixel;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   157
} SDL_WindowTextureData;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   158
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   159
static SDL_bool
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   160
ShouldUseTextureFramebuffer()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   161
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   162
    const char *hint;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   163
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   164
    /* If there's no native framebuffer support then there's no option */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   165
    if (!_this->CreateWindowFramebuffer) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   166
        return SDL_TRUE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   167
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   168
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   169
    /* If the user has specified a software renderer we can't use a
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   170
       texture framebuffer, or renderer creation will go recursive.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   171
     */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   172
    hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   173
    if (hint && SDL_strcasecmp(hint, "software") == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   174
        return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   175
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   176
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   177
    /* See if the user or application wants a specific behavior */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   178
    hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   179
    if (hint) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   180
        if (*hint == '0') {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   181
            return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   182
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   183
            return SDL_TRUE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   184
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   185
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   186
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   187
    /* Each platform has different performance characteristics */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   188
#if defined(__WIN32__)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   189
    /* GDI BitBlt() is way faster than Direct3D dynamic textures right now.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   190
     */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   191
    return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   192
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   193
#elif defined(__MACOSX__)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   194
    /* Mac OS X uses OpenGL as the native fast path */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   195
    return SDL_TRUE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   196
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   197
#elif defined(__LINUX__)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   198
    /* Properly configured OpenGL drivers are faster than MIT-SHM */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   199
#if SDL_VIDEO_OPENGL
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   200
    /* Ugh, find a way to cache this value! */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   201
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   202
        SDL_Window *window;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   203
        SDL_GLContext context;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   204
        SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   205
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   206
        window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   207
        if (window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   208
            context = SDL_GL_CreateContext(window);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   209
            if (context) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   210
                const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   211
                const char *vendor = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   212
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   213
                glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   214
                if (glGetStringFunc) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   215
                    vendor = (const char *) glGetStringFunc(GL_VENDOR);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   216
                }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   217
                /* Add more vendors here at will... */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   218
                if (vendor &&
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   219
                    (SDL_strstr(vendor, "ATI Technologies") ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   220
                     SDL_strstr(vendor, "NVIDIA"))) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   221
                    hasAcceleratedOpenGL = SDL_TRUE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   222
                }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   223
                SDL_GL_DeleteContext(context);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   224
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   225
            SDL_DestroyWindow(window);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   226
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   227
        return hasAcceleratedOpenGL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   228
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   229
#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   230
    /* Let's be optimistic about this! */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   231
    return SDL_TRUE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   232
#else
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   233
    return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   234
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   235
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   236
#else
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   237
    /* Play it safe, assume that if there is a framebuffer driver that it's
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   238
       optimized for the current platform.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   239
    */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   240
    return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   241
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   242
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   243
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   244
static int
8922
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   245
SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   246
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   247
    SDL_WindowTextureData *data;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   248
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   249
    data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   250
    if (!data) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   251
        SDL_Renderer *renderer = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   252
        int i;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   253
        const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   254
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   255
        /* Check to see if there's a specific driver requested */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   256
        if (hint && *hint != '0' && *hint != '1' &&
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   257
            SDL_strcasecmp(hint, "software") != 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   258
            for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
8922
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   259
                SDL_RendererInfo info;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   260
                SDL_GetRenderDriverInfo(i, &info);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   261
                if (SDL_strcasecmp(info.name, hint) == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   262
                    renderer = SDL_CreateRenderer(window, i, 0);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   263
                    break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   264
                }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   265
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   266
        }
8833
ae720d61d14d Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8823
diff changeset
   267
        
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   268
        if (!renderer) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   269
            for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
8922
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   270
                SDL_RendererInfo info;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   271
                SDL_GetRenderDriverInfo(i, &info);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   272
                if (SDL_strcmp(info.name, "software") != 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   273
                    renderer = SDL_CreateRenderer(window, i, 0);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   274
                    if (renderer) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   275
                        break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   276
                    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   277
                }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   278
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   279
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   280
        if (!renderer) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   281
            return SDL_SetError("No hardware accelerated renderers available");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   282
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   283
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   284
        /* Create the data after we successfully create the renderer (bug #1116) */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   285
        data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   286
        if (!data) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   287
            SDL_DestroyRenderer(renderer);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   288
            return SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   289
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   290
        SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   291
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   292
        data->renderer = renderer;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   293
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   294
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   295
    /* Free any old texture and pixel data */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   296
    if (data->texture) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   297
        SDL_DestroyTexture(data->texture);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   298
        data->texture = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   299
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   300
    SDL_free(data->pixels);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   301
    data->pixels = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   302
8922
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   303
    {
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   304
        SDL_RendererInfo info;
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   305
        Uint32 i;
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   306
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   307
        if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   308
            return -1;
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   309
        }
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   310
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   311
        /* Find the first format without an alpha channel */
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   312
        *format = info.texture_formats[0];
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   313
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   314
        for (i = 0; i < info.num_texture_formats; ++i) {
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   315
            if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   316
                    !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   317
                *format = info.texture_formats[i];
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   318
                break;
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   319
            }
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   320
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   321
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   322
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   323
    data->texture = SDL_CreateTexture(data->renderer, *format,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   324
                                      SDL_TEXTUREACCESS_STREAMING,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   325
                                      window->w, window->h);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   326
    if (!data->texture) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   327
        return -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   328
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   329
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   330
    /* Create framebuffer data */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   331
    data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   332
    data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   333
    data->pixels = SDL_malloc(window->h * data->pitch);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   334
    if (!data->pixels) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   335
        return SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   336
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   337
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   338
    *pixels = data->pixels;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   339
    *pitch = data->pitch;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   340
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   341
    /* Make sure we're not double-scaling the viewport */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   342
    SDL_RenderSetViewport(data->renderer, NULL);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   343
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   344
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   345
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   346
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   347
static int
8922
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   348
SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   349
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   350
    SDL_WindowTextureData *data;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   351
    SDL_Rect rect;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   352
    void *src;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   353
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   354
    data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   355
    if (!data || !data->texture) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   356
        return SDL_SetError("No window texture data");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   357
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   358
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   359
    /* Update a single rect that contains subrects for best DMA performance */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   360
    if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   361
        src = (void *)((Uint8 *)data->pixels +
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   362
                        rect.y * data->pitch +
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   363
                        rect.x * data->bytes_per_pixel);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   364
        if (SDL_UpdateTexture(data->texture, &rect, src, data->pitch) < 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   365
            return -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   366
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   367
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   368
        if (SDL_RenderCopy(data->renderer, data->texture, NULL, NULL) < 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   369
            return -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   370
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   371
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   372
        SDL_RenderPresent(data->renderer);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   373
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   374
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   375
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   376
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   377
static void
8922
dfb6f8611ebe Fixed bug 2556 - add compilation flag -Wshadow
Sam Lantinga <slouken@libsdl.org>
parents: 8906
diff changeset
   378
SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   379
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   380
    SDL_WindowTextureData *data;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   381
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   382
    data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   383
    if (!data) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   384
        return;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   385
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   386
    if (data->texture) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   387
        SDL_DestroyTexture(data->texture);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   388
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   389
    if (data->renderer) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   390
        SDL_DestroyRenderer(data->renderer);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   391
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   392
    SDL_free(data->pixels);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   393
    SDL_free(data);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   394
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   395
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   396
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   397
static int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   398
cmpmodes(const void *A, const void *B)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   399
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   400
    const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   401
    const SDL_DisplayMode *b = (const SDL_DisplayMode *) B;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   402
    if (a == b) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   403
        return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   404
    } else if (a->w != b->w) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   405
        return b->w - a->w;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   406
    } else if (a->h != b->h) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   407
        return b->h - a->h;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   408
    } else if (SDL_BITSPERPIXEL(a->format) != SDL_BITSPERPIXEL(b->format)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   409
        return SDL_BITSPERPIXEL(b->format) - SDL_BITSPERPIXEL(a->format);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   410
    } else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   411
        return SDL_PIXELLAYOUT(b->format) - SDL_PIXELLAYOUT(a->format);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   412
    } else if (a->refresh_rate != b->refresh_rate) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   413
        return b->refresh_rate - a->refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   414
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   415
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   416
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   417
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   418
static int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   419
SDL_UninitializedVideo()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   420
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   421
    return SDL_SetError("Video subsystem has not been initialized");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   422
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   423
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   424
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   425
SDL_GetNumVideoDrivers(void)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   426
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   427
    return SDL_arraysize(bootstrap) - 1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   428
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   429
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   430
const char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   431
SDL_GetVideoDriver(int index)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   432
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   433
    if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   434
        return bootstrap[index]->name;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   435
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   436
    return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   437
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   438
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   439
/*
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   440
 * Initialize the video and event subsystems -- determine native pixel format
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   441
 */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   442
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   443
SDL_VideoInit(const char *driver_name)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   444
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   445
    SDL_VideoDevice *video;
8266
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   446
    const char *hint;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   447
    int index;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   448
    int i;
8266
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   449
    SDL_bool allow_screensaver;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   450
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   451
    /* Check to make sure we don't overwrite '_this' */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   452
    if (_this != NULL) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   453
        SDL_VideoQuit();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   454
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   455
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   456
#if !SDL_TIMERS_DISABLED
8268
3f8410f20405 Fixed bug 2423 - timeBeginPeriod & timeEndPeriod mismatch
Sam Lantinga <slouken@libsdl.org>
parents: 8266
diff changeset
   457
    SDL_TicksInit();
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   458
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   459
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   460
    /* Start the event loop */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   461
    if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0 ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   462
        SDL_KeyboardInit() < 0 ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   463
        SDL_MouseInit() < 0 ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   464
        SDL_TouchInit() < 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   465
        return -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   466
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   467
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   468
    /* Select the proper video driver */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   469
    index = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   470
    video = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   471
    if (driver_name == NULL) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   472
        driver_name = SDL_getenv("SDL_VIDEODRIVER");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   473
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   474
    if (driver_name != NULL) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   475
        for (i = 0; bootstrap[i]; ++i) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   476
            if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
8117
988502081380 Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8112
diff changeset
   477
                if (bootstrap[i]->available()) {
988502081380 Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8112
diff changeset
   478
                    video = bootstrap[i]->create(index);
988502081380 Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8112
diff changeset
   479
                    break;
988502081380 Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8112
diff changeset
   480
                }
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   481
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   482
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   483
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   484
        for (i = 0; bootstrap[i]; ++i) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   485
            if (bootstrap[i]->available()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   486
                video = bootstrap[i]->create(index);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   487
                if (video != NULL) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   488
                    break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   489
                }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   490
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   491
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   492
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   493
    if (video == NULL) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   494
        if (driver_name) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   495
            return SDL_SetError("%s not available", driver_name);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   496
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   497
        return SDL_SetError("No available video device");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   498
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   499
    _this = video;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   500
    _this->name = bootstrap[i]->name;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   501
    _this->next_object_id = 1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   502
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   503
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   504
    /* Set some very sane GL defaults */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   505
    _this->gl_config.driver_loaded = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   506
    _this->gl_config.dll_handle = NULL;
8145
663d7d9de9bf Add SDL_GL_ResetAttributes.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 8117
diff changeset
   507
    SDL_GL_ResetAttributes();
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   508
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   509
    _this->current_glwin_tls = SDL_TLSCreate();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   510
    _this->current_glctx_tls = SDL_TLSCreate();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   511
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   512
    /* Initialize the video subsystem */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   513
    if (_this->VideoInit(_this) < 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   514
        SDL_VideoQuit();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   515
        return -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   516
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   517
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   518
    /* Make sure some displays were added */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   519
    if (_this->num_displays == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   520
        SDL_VideoQuit();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   521
        return SDL_SetError("The video driver did not add any displays");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   522
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   523
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   524
    /* Add the renderer framebuffer emulation if desired */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   525
    if (ShouldUseTextureFramebuffer()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   526
        _this->CreateWindowFramebuffer = SDL_CreateWindowTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   527
        _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   528
        _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   529
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   530
8265
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   531
    /* Disable the screen saver by default. This is a change from <= 2.0.1,
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   532
       but most things using SDL are games or media players; you wouldn't
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   533
       want a screensaver to trigger if you're playing exclusively with a
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   534
       joystick, or passively watching a movie. Things that use SDL but
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   535
       function more like a normal desktop app should explicitly reenable the
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   536
       screensaver. */
8266
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   537
    hint = SDL_GetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER);
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   538
    if (hint) {
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   539
        allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE;
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   540
    } else {
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   541
        allow_screensaver = SDL_FALSE;
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   542
    }
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   543
    if (!allow_screensaver) {
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   544
        SDL_DisableScreenSaver();
d123fc5d02bc Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents: 8265
diff changeset
   545
    }
8265
1ed54c57d6c7 Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8153
diff changeset
   546
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   547
    /* If we don't use a screen keyboard, turn on text input by default,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   548
       otherwise programs that expect to get text events without enabling
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   549
       UNICODE input won't get any events.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   550
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   551
       Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   552
       in SDL 1.2 before you got text input events.  Hmm...
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   553
     */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   554
    if (!SDL_HasScreenKeyboardSupport()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   555
        SDL_StartTextInput();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   556
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   557
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   558
    /* We're ready to go! */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   559
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   560
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   561
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   562
const char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   563
SDL_GetCurrentVideoDriver()
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   564
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   565
    if (!_this) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   566
        SDL_UninitializedVideo();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   567
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   568
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   569
    return _this->name;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   570
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   571
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   572
SDL_VideoDevice *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   573
SDL_GetVideoDevice(void)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   574
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   575
    return _this;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   576
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   577
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   578
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   579
SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   580
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   581
    SDL_VideoDisplay display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   583
    SDL_zero(display);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   584
    if (desktop_mode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   585
        display.desktop_mode = *desktop_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   586
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   587
    display.current_mode = display.desktop_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   588
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   589
    return SDL_AddVideoDisplay(&display);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   590
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   591
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   592
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   593
SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   594
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   595
    SDL_VideoDisplay *displays;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   596
    int index = -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   597
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   598
    displays =
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   599
        SDL_realloc(_this->displays,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   600
                    (_this->num_displays + 1) * sizeof(*displays));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   601
    if (displays) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   602
        index = _this->num_displays++;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   603
        displays[index] = *display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   604
        displays[index].device = _this;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   605
        _this->displays = displays;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   606
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   607
        if (display->name) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   608
            displays[index].name = SDL_strdup(display->name);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   609
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   610
            char name[32];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   611
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   612
            SDL_itoa(index, name, 10);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   613
            displays[index].name = SDL_strdup(name);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   614
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   615
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   616
        SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   617
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   618
    return index;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   619
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   620
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   621
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   622
SDL_GetNumVideoDisplays(void)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   623
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   624
    if (!_this) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   625
        SDL_UninitializedVideo();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   626
        return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   627
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   628
    return _this->num_displays;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   629
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   630
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   631
static int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   632
SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   633
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   634
    int displayIndex;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   635
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   636
    for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   637
        if (display == &_this->displays[displayIndex]) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   638
            return displayIndex;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   639
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   640
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   641
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   642
    /* Couldn't find the display, just use index 0 */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   643
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   644
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   645
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   646
void *
8818
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
   647
SDL_GetDisplayDriverData(int displayIndex)
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   648
{
8818
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
   649
    CHECK_DISPLAY_INDEX(displayIndex, NULL);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   650
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   651
    return _this->displays[displayIndex].driverdata;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   652
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   653
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   654
const char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   655
SDL_GetDisplayName(int displayIndex)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   656
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   657
    CHECK_DISPLAY_INDEX(displayIndex, NULL);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   658
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   659
    return _this->displays[displayIndex].name;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   660
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   661
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   662
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   663
SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   664
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   665
    CHECK_DISPLAY_INDEX(displayIndex, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   666
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   667
    if (rect) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   668
        SDL_VideoDisplay *display = &_this->displays[displayIndex];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   669
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   670
        if (_this->GetDisplayBounds) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   671
            if (_this->GetDisplayBounds(_this, display, rect) == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   672
                return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   673
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   674
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   675
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   676
        /* Assume that the displays are left to right */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   677
        if (displayIndex == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   678
            rect->x = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   679
            rect->y = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   680
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   681
            SDL_GetDisplayBounds(displayIndex-1, rect);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   682
            rect->x += rect->w;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   683
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   684
        rect->w = display->current_mode.w;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   685
        rect->h = display->current_mode.h;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   686
    }
10019
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   687
    return 0;  /* !!! FIXME: should this be an error if (rect==NULL) ? */
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   688
}
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   689
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   690
int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect)
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   691
{
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   692
    CHECK_DISPLAY_INDEX(displayIndex, -1);
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   693
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   694
    if (rect) {
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   695
        SDL_VideoDisplay *display = &_this->displays[displayIndex];
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   696
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   697
        if (_this->GetDisplayUsableBounds) {
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   698
            if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   699
                return 0;
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   700
            }
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   701
        }
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   702
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   703
        /* Oh well, just give the entire display bounds. */
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   704
        return SDL_GetDisplayBounds(displayIndex, rect);
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   705
    }
36f7e8084508 Added SDL_GetDisplayUsableBounds().
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   706
    return 0;  /* !!! FIXME: should this be an error if (rect==NULL) ? */
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   707
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   708
9813
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   709
int
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   710
SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi)
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   711
{
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   712
	SDL_VideoDisplay *display;
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   713
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   714
    CHECK_DISPLAY_INDEX(displayIndex, -1);
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   715
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   716
    display = &_this->displays[displayIndex];
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   717
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   718
	if (_this->GetDisplayDPI) {
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   719
		if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   720
			return 0;
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   721
		}
10166
2393160743ca Fixed missing error message if SDL_GetDisplayDPI() is unsupported.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10056
diff changeset
   722
    } else {
2393160743ca Fixed missing error message if SDL_GetDisplayDPI() is unsupported.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10056
diff changeset
   723
        return SDL_Unsupported();
2393160743ca Fixed missing error message if SDL_GetDisplayDPI() is unsupported.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10056
diff changeset
   724
    }
9813
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   725
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   726
	return -1;
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   727
}
0652406e46c6 Add SDL_GetDisplayDPI routine and implement for Windows.
Alfred Reynolds <alfred@valvesoftware.com>
parents: 9776
diff changeset
   728
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   729
SDL_bool
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   730
SDL_AddDisplayMode(SDL_VideoDisplay * display,  const SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   731
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   732
    SDL_DisplayMode *modes;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   733
    int i, nmodes;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   734
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   735
    /* Make sure we don't already have the mode in the list */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   736
    modes = display->display_modes;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   737
    nmodes = display->num_display_modes;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   738
    for (i = 0; i < nmodes; ++i) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   739
        if (cmpmodes(mode, &modes[i]) == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   740
            return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   741
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   742
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   743
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   744
    /* Go ahead and add the new mode */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   745
    if (nmodes == display->max_display_modes) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   746
        modes =
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   747
            SDL_realloc(modes,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   748
                        (display->max_display_modes + 32) * sizeof(*modes));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   749
        if (!modes) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   750
            return SDL_FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   751
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   752
        display->display_modes = modes;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   753
        display->max_display_modes += 32;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   754
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   755
    modes[nmodes] = *mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   756
    display->num_display_modes++;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   757
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   758
    /* Re-sort video modes */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   759
    SDL_qsort(display->display_modes, display->num_display_modes,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   760
              sizeof(SDL_DisplayMode), cmpmodes);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   761
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   762
    return SDL_TRUE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   763
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   764
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   765
static int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   766
SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   767
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   768
    if (!display->num_display_modes && _this->GetDisplayModes) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   769
        _this->GetDisplayModes(_this, display);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   770
        SDL_qsort(display->display_modes, display->num_display_modes,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   771
                  sizeof(SDL_DisplayMode), cmpmodes);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   772
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   773
    return display->num_display_modes;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   774
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   775
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   776
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   777
SDL_GetNumDisplayModes(int displayIndex)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   778
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   779
    CHECK_DISPLAY_INDEX(displayIndex, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   780
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   781
    return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   782
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   783
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   784
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   785
SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   786
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   787
    SDL_VideoDisplay *display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   788
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   789
    CHECK_DISPLAY_INDEX(displayIndex, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   790
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   791
    display = &_this->displays[displayIndex];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   792
    if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   793
        return SDL_SetError("index must be in the range of 0 - %d",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   794
                            SDL_GetNumDisplayModesForDisplay(display) - 1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   795
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   796
    if (mode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   797
        *mode = display->display_modes[index];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   798
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   799
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   800
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   801
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   802
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   803
SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   804
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   805
    SDL_VideoDisplay *display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   806
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   807
    CHECK_DISPLAY_INDEX(displayIndex, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   808
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   809
    display = &_this->displays[displayIndex];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   810
    if (mode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   811
        *mode = display->desktop_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   812
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   813
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   814
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   815
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   816
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   817
SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   818
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   819
    SDL_VideoDisplay *display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   820
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   821
    CHECK_DISPLAY_INDEX(displayIndex, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   822
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   823
    display = &_this->displays[displayIndex];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   824
    if (mode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   825
        *mode = display->current_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   826
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   827
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   828
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   829
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   830
static SDL_DisplayMode *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   831
SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   832
                                    const SDL_DisplayMode * mode,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   833
                                    SDL_DisplayMode * closest)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   834
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   835
    Uint32 target_format;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   836
    int target_refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   837
    int i;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   838
    SDL_DisplayMode *current, *match;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   839
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   840
    if (!mode || !closest) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   841
        SDL_SetError("Missing desired mode or closest mode parameter");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   842
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   843
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   844
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   845
    /* Default to the desktop format */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   846
    if (mode->format) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   847
        target_format = mode->format;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   848
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   849
        target_format = display->desktop_mode.format;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   850
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   851
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   852
    /* Default to the desktop refresh rate */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   853
    if (mode->refresh_rate) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   854
        target_refresh_rate = mode->refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   855
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   856
        target_refresh_rate = display->desktop_mode.refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   857
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   858
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   859
    match = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   860
    for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   861
        current = &display->display_modes[i];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   862
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   863
        if (current->w && (current->w < mode->w)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   864
            /* Out of sorted modes large enough here */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   865
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   866
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   867
        if (current->h && (current->h < mode->h)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   868
            if (current->w && (current->w == mode->w)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   869
                /* Out of sorted modes large enough here */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   870
                break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   871
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   872
            /* Wider, but not tall enough, due to a different
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   873
               aspect ratio. This mode must be skipped, but closer
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   874
               modes may still follow. */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   875
            continue;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   876
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   877
        if (!match || current->w < match->w || current->h < match->h) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   878
            match = current;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   879
            continue;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   880
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   881
        if (current->format != match->format) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   882
            /* Sorted highest depth to lowest */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   883
            if (current->format == target_format ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   884
                (SDL_BITSPERPIXEL(current->format) >=
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   885
                 SDL_BITSPERPIXEL(target_format)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   886
                 && SDL_PIXELTYPE(current->format) ==
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   887
                 SDL_PIXELTYPE(target_format))) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   888
                match = current;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   889
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   890
            continue;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   891
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   892
        if (current->refresh_rate != match->refresh_rate) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   893
            /* Sorted highest refresh to lowest */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   894
            if (current->refresh_rate >= target_refresh_rate) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   895
                match = current;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   896
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   897
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   898
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   899
    if (match) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   900
        if (match->format) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   901
            closest->format = match->format;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   902
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   903
            closest->format = mode->format;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   904
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   905
        if (match->w && match->h) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   906
            closest->w = match->w;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   907
            closest->h = match->h;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   908
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   909
            closest->w = mode->w;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   910
            closest->h = mode->h;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   911
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   912
        if (match->refresh_rate) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   913
            closest->refresh_rate = match->refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   914
        } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   915
            closest->refresh_rate = mode->refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   916
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   917
        closest->driverdata = match->driverdata;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   918
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   919
        /*
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   920
         * Pick some reasonable defaults if the app and driver don't
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   921
         * care
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   922
         */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   923
        if (!closest->format) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   924
            closest->format = SDL_PIXELFORMAT_RGB888;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   925
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   926
        if (!closest->w) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   927
            closest->w = 640;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   928
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   929
        if (!closest->h) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   930
            closest->h = 480;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   931
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   932
        return closest;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   933
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   934
    return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   935
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   936
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   937
SDL_DisplayMode *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   938
SDL_GetClosestDisplayMode(int displayIndex,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   939
                          const SDL_DisplayMode * mode,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   940
                          SDL_DisplayMode * closest)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   941
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   942
    SDL_VideoDisplay *display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   943
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   944
    CHECK_DISPLAY_INDEX(displayIndex, NULL);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   945
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   946
    display = &_this->displays[displayIndex];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   947
    return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   948
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   949
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   950
static int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   951
SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   952
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   953
    SDL_DisplayMode display_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   954
    SDL_DisplayMode current_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   955
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   956
    if (mode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   957
        display_mode = *mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   958
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   959
        /* Default to the current mode */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   960
        if (!display_mode.format) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   961
            display_mode.format = display->current_mode.format;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   962
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   963
        if (!display_mode.w) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   964
            display_mode.w = display->current_mode.w;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   965
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   966
        if (!display_mode.h) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   967
            display_mode.h = display->current_mode.h;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   968
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   969
        if (!display_mode.refresh_rate) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   970
            display_mode.refresh_rate = display->current_mode.refresh_rate;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   971
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   972
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   973
        /* Get a good video mode, the closest one possible */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   974
        if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   975
            return SDL_SetError("No video mode large enough for %dx%d",
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   976
                                display_mode.w, display_mode.h);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   977
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   978
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   979
        display_mode = display->desktop_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   980
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   981
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   982
    /* See if there's anything left to do */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   983
    current_mode = display->current_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   984
    if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   985
        return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   986
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   987
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   988
    /* Actually change the display mode */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   989
    if (!_this->SetDisplayMode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   990
        return SDL_SetError("Video driver doesn't support changing display mode");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   991
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   992
    if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   993
        return -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   994
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   995
    display->current_mode = display_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   996
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   997
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   998
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
   999
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1000
SDL_GetWindowDisplayIndex(SDL_Window * window)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1001
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1002
    int displayIndex;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1003
    int i, dist;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1004
    int closest = -1;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1005
    int closest_dist = 0x7FFFFFFF;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1006
    SDL_Point center;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1007
    SDL_Point delta;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1008
    SDL_Rect rect;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1009
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1010
    CHECK_WINDOW_MAGIC(window, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1011
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1012
    if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1013
        SDL_WINDOWPOS_ISCENTERED(window->x)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1014
        displayIndex = (window->x & 0xFFFF);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1015
        if (displayIndex >= _this->num_displays) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1016
            displayIndex = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1017
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1018
        return displayIndex;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1019
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1020
    if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1021
        SDL_WINDOWPOS_ISCENTERED(window->y)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1022
        displayIndex = (window->y & 0xFFFF);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1023
        if (displayIndex >= _this->num_displays) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1024
            displayIndex = 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1025
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1026
        return displayIndex;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1027
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1028
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1029
    /* Find the display containing the window */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1030
    for (i = 0; i < _this->num_displays; ++i) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1031
        SDL_VideoDisplay *display = &_this->displays[i];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1032
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1033
        if (display->fullscreen_window == window) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1034
            return i;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1035
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1036
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1037
    center.x = window->x + window->w / 2;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1038
    center.y = window->y + window->h / 2;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1039
    for (i = 0; i < _this->num_displays; ++i) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1040
        SDL_GetDisplayBounds(i, &rect);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1041
        if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1042
            return i;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1043
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1044
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1045
        delta.x = center.x - (rect.x + rect.w / 2);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1046
        delta.y = center.y - (rect.y + rect.h / 2);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1047
        dist = (delta.x*delta.x + delta.y*delta.y);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1048
        if (dist < closest_dist) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1049
            closest = i;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1050
            closest_dist = dist;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1051
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1052
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1053
    if (closest < 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1054
        SDL_SetError("Couldn't find any displays");
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1055
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1056
    return closest;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1057
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1058
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1059
SDL_VideoDisplay *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1060
SDL_GetDisplayForWindow(SDL_Window *window)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1061
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1062
    int displayIndex = SDL_GetWindowDisplayIndex(window);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1063
    if (displayIndex >= 0) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1064
        return &_this->displays[displayIndex];
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1065
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1066
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1067
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1068
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1069
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1070
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1071
SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1072
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1073
    CHECK_WINDOW_MAGIC(window, -1);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1074
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1075
    if (mode) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1076
        window->fullscreen_mode = *mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1077
    } else {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1078
        SDL_zero(window->fullscreen_mode);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1079
    }
8818
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1080
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1081
    if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1082
        SDL_DisplayMode fullscreen_mode;
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1083
        if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1084
            SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1085
        }
3b075068bf2e When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents: 8783
diff changeset
  1086
    }
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1087
    return 0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1088
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1089
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1090
int
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1091
SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1092
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1093
    SDL_DisplayMode fullscreen_mode;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1094
    SDL_VideoDisplay *display;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8543
diff changeset
  1095
8818
3b075068bf2e When the window fullscreen mode changes, update the display resolution
S&