author  Sam Lantinga <slouken@libsdl.org> 
Wed, 15 Oct 2014 09:14:09 0700  
changeset 9163  d05b5b2775ae 
parent 9135  6cd8e6b54f4d 
child 9164  494876610c49 
permissions  rwrr 
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 
8149
681eb46b8ac4
Fixed bug 2374  Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents:
8145
diff
changeset

3 
Copyright (C) 19972014 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 'asis', 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 highlevel 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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

49 
/* On Windows, windows.h defines CreateWindow */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

50 
#ifdef CreateWindow 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

51 
#undef CreateWindow 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

52 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

53 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

54 
/* Available video drivers */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

55 
static VideoBootStrap *bootstrap[] = { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

56 
#if SDL_VIDEO_DRIVER_COCOA 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

57 
&COCOA_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

58 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

59 
#if SDL_VIDEO_DRIVER_X11 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

60 
&X11_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

61 
#endif 
8153
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
8149
diff
changeset

62 
#if SDL_VIDEO_DRIVER_MIR 
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
8149
diff
changeset

63 
&MIR_bootstrap, 
3e43c73ac79b
Added Mir video target (thanks, Brandon!).
Ryan C. Gordon <icculus@icculus.org>
parents:
8149
diff
changeset

64 
#endif 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

65 
#if SDL_VIDEO_DRIVER_DIRECTFB 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

66 
&DirectFB_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

67 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

68 
#if SDL_VIDEO_DRIVER_WINDOWS 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

69 
&WINDOWS_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

70 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

71 
#if SDL_VIDEO_DRIVER_WINRT 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

72 
&WINRT_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

73 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

74 
#if SDL_VIDEO_DRIVER_HAIKU 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

75 
&HAIKU_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

76 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

77 
#if SDL_VIDEO_DRIVER_PANDORA 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

78 
&PND_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

79 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

80 
#if SDL_VIDEO_DRIVER_UIKIT 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

81 
&UIKIT_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

82 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

83 
#if SDL_VIDEO_DRIVER_ANDROID 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

84 
&Android_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

85 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

86 
#if SDL_VIDEO_DRIVER_PSP 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

87 
&PSP_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

88 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

89 
#if SDL_VIDEO_DRIVER_RPI 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

90 
&RPI_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

91 
#endif 
8117
988502081380
Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8112
diff
changeset

92 
#if SDL_VIDEO_DRIVER_WAYLAND 
988502081380
Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8112
diff
changeset

93 
&Wayland_bootstrap, 
988502081380
Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8112
diff
changeset

94 
#endif 
8833
ae720d61d14d
Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8823
diff
changeset

95 
#if SDL_VIDEO_DRIVER_NACL 
ae720d61d14d
Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8823
diff
changeset

96 
&NACL_bootstrap, 
ae720d61d14d
Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8823
diff
changeset

97 
#endif 
9127
a8c38ed1a674
Freescale i.MX6 video driver
mastermind <denis.barkar@gmail.com>
parents:
9037
diff
changeset

98 
#if SDL_VIDEO_DRIVER_MX6 
a8c38ed1a674
Freescale i.MX6 video driver
mastermind <denis.barkar@gmail.com>
parents:
9037
diff
changeset

99 
&MX6_bootstrap, 
a8c38ed1a674
Freescale i.MX6 video driver
mastermind <denis.barkar@gmail.com>
parents:
9037
diff
changeset

100 
#endif 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

101 
#if SDL_VIDEO_DRIVER_DUMMY 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

102 
&DUMMY_bootstrap, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

103 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

104 
NULL 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

105 
}; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

106 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

107 
static SDL_VideoDevice *_this = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

108 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

109 
#define CHECK_WINDOW_MAGIC(window, retval) \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

110 
if (!_this) { \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

111 
SDL_UninitializedVideo(); \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

112 
return retval; \ 
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 
if (!window  window>magic != &_this>window_magic) { \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

115 
SDL_SetError("Invalid window"); \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

116 
return retval; \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

117 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

118 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

119 
#define CHECK_DISPLAY_INDEX(displayIndex, retval) \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

120 
if (!_this) { \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

121 
SDL_UninitializedVideo(); \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

122 
return retval; \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

123 
} \ 
8651
b1cb565609dc
Static analysis fix: let clang know _this>displays isn't NULL.
Ryan C. Gordon <icculus@icculus.org>
parents:
8616
diff
changeset

124 
SDL_assert(_this>displays != NULL); \ 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

125 
if (displayIndex < 0  displayIndex >= _this>num_displays) { \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

126 
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

127 
_this>num_displays  1); \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

128 
return retval; \ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

129 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

130 

8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

131 
#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

132 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

133 
#ifdef __MACOSX__ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

134 
/* Support for Mac OS X fullscreen spaces */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

135 
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

136 
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

137 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

138 

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 
/* 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

141 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

142 
#define SDL_WINDOWTEXTUREDATA "_SDL_WindowTextureData" 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

143 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

144 
typedef struct { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

145 
SDL_Renderer *renderer; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

146 
SDL_Texture *texture; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

147 
void *pixels; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

148 
int pitch; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

149 
int bytes_per_pixel; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

150 
} SDL_WindowTextureData; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

151 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

152 
static SDL_bool 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

153 
ShouldUseTextureFramebuffer() 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

154 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

155 
const char *hint; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

156 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

157 
/* 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

158 
if (!_this>CreateWindowFramebuffer) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

159 
return SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

160 
} 
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 
/* 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

163 
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

164 
*/ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

165 
hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

166 
if (hint && SDL_strcasecmp(hint, "software") == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

167 
return SDL_FALSE; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

170 
/* 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

171 
hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

172 
if (hint) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

173 
if (*hint == '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 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

176 
return SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

177 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

178 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

179 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

180 
/* Each platform has different performance characteristics */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

181 
#if defined(__WIN32__) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

182 
/* 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

183 
*/ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

184 
return SDL_FALSE; 
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 
#elif defined(__MACOSX__) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

187 
/* 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

188 
return SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

189 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

190 
#elif defined(__LINUX__) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

191 
/* Properly configured OpenGL drivers are faster than MITSHM */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

192 
#if SDL_VIDEO_OPENGL 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

193 
/* 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

194 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

195 
SDL_Window *window; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

196 
SDL_GLContext context; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

197 
SDL_bool hasAcceleratedOpenGL = SDL_FALSE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

198 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

199 
window = SDL_CreateWindow("OpenGL test", 32, 32, 32, 32, SDL_WINDOW_OPENGLSDL_WINDOW_HIDDEN); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

200 
if (window) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

201 
context = SDL_GL_CreateContext(window); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

202 
if (context) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

203 
const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

204 
const char *vendor = NULL; 
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 
glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

207 
if (glGetStringFunc) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

208 
vendor = (const char *) glGetStringFunc(GL_VENDOR); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

209 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

210 
/* Add more vendors here at will... */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

211 
if (vendor && 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

212 
(SDL_strstr(vendor, "ATI Technologies")  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

213 
SDL_strstr(vendor, "NVIDIA"))) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

214 
hasAcceleratedOpenGL = SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

215 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

216 
SDL_GL_DeleteContext(context); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

217 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

218 
SDL_DestroyWindow(window); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

219 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

220 
return hasAcceleratedOpenGL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

221 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

222 
#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

223 
/* Let's be optimistic about this! */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

224 
return SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

225 
#else 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

226 
return SDL_FALSE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

227 
#endif 
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 
#else 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

230 
/* 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

231 
optimized for the current platform. 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

232 
*/ 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

237 
static int 
8922
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

238 
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

239 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

240 
SDL_WindowTextureData *data; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

241 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

242 
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

243 
if (!data) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

244 
SDL_Renderer *renderer = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

245 
int i; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

246 
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

247 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

248 
/* 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

249 
if (hint && *hint != '0' && *hint != '1' && 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

250 
SDL_strcasecmp(hint, "software") != 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

251 
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

252 
SDL_RendererInfo info; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

253 
SDL_GetRenderDriverInfo(i, &info); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

254 
if (SDL_strcasecmp(info.name, hint) == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

255 
renderer = SDL_CreateRenderer(window, i, 0); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

256 
break; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

257 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

258 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

259 
} 
8833
ae720d61d14d
Chrome's Native Client backend implementation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8823
diff
changeset

260 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

261 
if (!renderer) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

262 
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

263 
SDL_RendererInfo info; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

264 
SDL_GetRenderDriverInfo(i, &info); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

265 
if (SDL_strcmp(info.name, "software") != 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

266 
renderer = SDL_CreateRenderer(window, i, 0); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

267 
if (renderer) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

268 
break; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

269 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

270 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

271 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

272 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

273 
if (!renderer) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

274 
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

275 
} 
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 
/* 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

278 
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

279 
if (!data) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

280 
SDL_DestroyRenderer(renderer); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

281 
return SDL_OutOfMemory(); 
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 
SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

284 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

285 
data>renderer = renderer; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

286 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

287 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

288 
/* Free any old texture and pixel data */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

289 
if (data>texture) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

290 
SDL_DestroyTexture(data>texture); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

291 
data>texture = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

292 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

293 
SDL_free(data>pixels); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

294 
data>pixels = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

295 

8922
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

296 
{ 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

297 
SDL_RendererInfo info; 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

298 
Uint32 i; 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

299 

dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

300 
if (SDL_GetRendererInfo(data>renderer, &info) < 0) { 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

301 
return 1; 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

302 
} 
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 
/* 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

305 
*format = info.texture_formats[0]; 
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 
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

308 
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

309 
!SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) { 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

310 
*format = info.texture_formats[i]; 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

311 
break; 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

312 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

313 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

314 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

315 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

316 
data>texture = SDL_CreateTexture(data>renderer, *format, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

317 
SDL_TEXTUREACCESS_STREAMING, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

318 
window>w, window>h); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

319 
if (!data>texture) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

320 
return 1; 
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 
/* Create framebuffer data */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

324 
data>bytes_per_pixel = SDL_BYTESPERPIXEL(*format); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

325 
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

326 
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

327 
if (!data>pixels) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

328 
return SDL_OutOfMemory(); 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

331 
*pixels = data>pixels; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

332 
*pitch = data>pitch; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

333 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

334 
/* Make sure we're not doublescaling the viewport */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

335 
SDL_RenderSetViewport(data>renderer, NULL); 
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 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

338 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

339 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

340 
static int 
8922
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

341 
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

342 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

343 
SDL_WindowTextureData *data; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

344 
SDL_Rect rect; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

345 
void *src; 
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 
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

348 
if (!data  !data>texture) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

349 
return SDL_SetError("No window texture data"); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

350 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

351 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

352 
/* 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

353 
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

354 
src = (void *)((Uint8 *)data>pixels + 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

355 
rect.y * data>pitch + 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

356 
rect.x * data>bytes_per_pixel); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

357 
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

358 
return 1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

359 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

360 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

361 
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

362 
return 1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

363 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

364 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

365 
SDL_RenderPresent(data>renderer); 
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 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

368 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

369 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

370 
static void 
8922
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

371 
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

372 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

373 
SDL_WindowTextureData *data; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

374 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

375 
data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

376 
if (!data) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

377 
return; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

378 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

379 
if (data>texture) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

380 
SDL_DestroyTexture(data>texture); 
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 
if (data>renderer) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

383 
SDL_DestroyRenderer(data>renderer); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

384 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

385 
SDL_free(data>pixels); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

386 
SDL_free(data); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

387 
} 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

390 
static int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

391 
cmpmodes(const void *A, const void *B) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

392 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

393 
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

394 
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

395 
if (a == b) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

396 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

397 
} else if (a>w != b>w) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

398 
return b>w  a>w; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

399 
} else if (a>h != b>h) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

400 
return b>h  a>h; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

401 
} 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

402 
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

403 
} 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

404 
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

405 
} 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

406 
return b>refresh_rate  a>refresh_rate; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

407 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

408 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

409 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

410 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

411 
static int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

412 
SDL_UninitializedVideo() 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

413 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

414 
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

415 
} 
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 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

418 
SDL_GetNumVideoDrivers(void) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

419 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

420 
return SDL_arraysize(bootstrap)  1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

421 
} 
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 
const char * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

424 
SDL_GetVideoDriver(int index) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

425 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

426 
if (index >= 0 && index < SDL_GetNumVideoDrivers()) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

427 
return bootstrap[index]>name; 
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 
return NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

430 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

431 

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 
* 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

434 
*/ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

435 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

436 
SDL_VideoInit(const char *driver_name) 
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 
SDL_VideoDevice *video; 
8266
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

439 
const char *hint; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

440 
int index; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

441 
int i; 
8266
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

442 
SDL_bool allow_screensaver; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

443 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

444 
/* 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

445 
if (_this != NULL) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

446 
SDL_VideoQuit(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

447 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

448 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

449 
#if !SDL_TIMERS_DISABLED 
8268
3f8410f20405
Fixed bug 2423  timeBeginPeriod & timeEndPeriod mismatch
Sam Lantinga <slouken@libsdl.org>
parents:
8266
diff
changeset

450 
SDL_TicksInit(); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

451 
#endif 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

452 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

453 
/* Start the event loop */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

454 
if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

455 
SDL_KeyboardInit() < 0  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

456 
SDL_MouseInit() < 0  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

457 
SDL_TouchInit() < 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

458 
return 1; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

461 
/* Select the proper video driver */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

462 
index = 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

463 
video = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

464 
if (driver_name == NULL) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

465 
driver_name = SDL_getenv("SDL_VIDEODRIVER"); 
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 
if (driver_name != NULL) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

468 
for (i = 0; bootstrap[i]; ++i) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

469 
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

470 
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

471 
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

472 
break; 
988502081380
Move Wayland driver above dummy, check for driver availability before creation
Gabriel Jacobo <gabomdq@gmail.com>
parents:
8112
diff
changeset

473 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

474 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

475 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

476 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

477 
for (i = 0; bootstrap[i]; ++i) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

478 
if (bootstrap[i]>available()) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

479 
video = bootstrap[i]>create(index); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

480 
if (video != NULL) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

481 
break; 
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 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

484 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

485 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

486 
if (video == NULL) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

487 
if (driver_name) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

488 
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

489 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

490 
return SDL_SetError("No available video device"); 
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 
_this = video; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

493 
_this>name = bootstrap[i]>name; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

494 
_this>next_object_id = 1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

495 

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 
/* Set some very sane GL defaults */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

498 
_this>gl_config.driver_loaded = 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

499 
_this>gl_config.dll_handle = NULL; 
8145
663d7d9de9bf
Add SDL_GL_ResetAttributes.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
8117
diff
changeset

500 
SDL_GL_ResetAttributes(); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

501 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

502 
_this>current_glwin_tls = SDL_TLSCreate(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

503 
_this>current_glctx_tls = SDL_TLSCreate(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

504 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

505 
/* Initialize the video subsystem */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

506 
if (_this>VideoInit(_this) < 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

507 
SDL_VideoQuit(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

508 
return 1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

509 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

510 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

511 
/* Make sure some displays were added */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

512 
if (_this>num_displays == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

513 
SDL_VideoQuit(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

514 
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

515 
} 
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 
/* Add the renderer framebuffer emulation if desired */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

518 
if (ShouldUseTextureFramebuffer()) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

519 
_this>CreateWindowFramebuffer = SDL_CreateWindowTexture; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

520 
_this>UpdateWindowFramebuffer = SDL_UpdateWindowTexture; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

521 
_this>DestroyWindowFramebuffer = SDL_DestroyWindowTexture; 
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 

8265
1ed54c57d6c7
Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset

524 
/* 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

525 
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

526 
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

527 
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

528 
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

529 
screensaver. */ 
8266
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

530 
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

531 
if (hint) { 
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

532 
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

533 
} else { 
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

534 
allow_screensaver = SDL_FALSE; 
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

535 
} 
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

536 
if (!allow_screensaver) { 
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

537 
SDL_DisableScreenSaver(); 
d123fc5d02bc
Added a hint to enable the screensaver by default
Sam Lantinga <slouken@libsdl.org>
parents:
8265
diff
changeset

538 
} 
8265
1ed54c57d6c7
Disable the screensaver by default.
Ryan C. Gordon <icculus@icculus.org>
parents:
8153
diff
changeset

539 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

540 
/* 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

541 
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

542 
UNICODE input won't get any events. 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

543 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

544 
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

545 
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

546 
*/ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

547 
if (!SDL_HasScreenKeyboardSupport()) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

548 
SDL_StartTextInput(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

549 
} 
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 
/* We're ready to go! */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

552 
return 0; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

555 
const char * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

556 
SDL_GetCurrentVideoDriver() 
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 
if (!_this) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

559 
SDL_UninitializedVideo(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

560 
return NULL; 
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 
return _this>name; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

563 
} 
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 
SDL_VideoDevice * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

566 
SDL_GetVideoDevice(void) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

567 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

568 
return _this; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

569 
} 
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 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

572 
SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

573 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

574 
SDL_VideoDisplay display; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

575 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

576 
SDL_zero(display); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

577 
if (desktop_mode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

578 
display.desktop_mode = *desktop_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

579 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

580 
display.current_mode = display.desktop_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

581 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

582 
return SDL_AddVideoDisplay(&display); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

583 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

584 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

585 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

586 
SDL_AddVideoDisplay(const SDL_VideoDisplay * display) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

587 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

588 
SDL_VideoDisplay *displays; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

589 
int index = 1; 
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 
displays = 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

592 
SDL_realloc(_this>displays, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

593 
(_this>num_displays + 1) * sizeof(*displays)); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

594 
if (displays) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

595 
index = _this>num_displays++; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

596 
displays[index] = *display; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

597 
displays[index].device = _this; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

598 
_this>displays = displays; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

599 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

600 
if (display>name) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

601 
displays[index].name = SDL_strdup(display>name); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

602 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

603 
char name[32]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

604 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

605 
SDL_itoa(index, name, 10); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

606 
displays[index].name = SDL_strdup(name); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

607 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

608 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

609 
SDL_OutOfMemory(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

610 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

611 
return index; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

612 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

613 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

614 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

615 
SDL_GetNumVideoDisplays(void) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

616 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

617 
if (!_this) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

618 
SDL_UninitializedVideo(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

619 
return 0; 
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 
return _this>num_displays; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

622 
} 
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 
static int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

625 
SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

626 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

627 
int displayIndex; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

628 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

629 
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

630 
if (display == &_this>displays[displayIndex]) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

631 
return displayIndex; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

632 
} 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

635 
/* 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

636 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

637 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

638 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

639 
void * 
8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

640 
SDL_GetDisplayDriverData(int displayIndex) 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

641 
{ 
8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

642 
CHECK_DISPLAY_INDEX(displayIndex, NULL); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

643 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

644 
return _this>displays[displayIndex].driverdata; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

647 
const char * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

648 
SDL_GetDisplayName(int displayIndex) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

649 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

650 
CHECK_DISPLAY_INDEX(displayIndex, NULL); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

651 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

652 
return _this>displays[displayIndex].name; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

655 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

656 
SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

657 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

658 
CHECK_DISPLAY_INDEX(displayIndex, 1); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

659 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

660 
if (rect) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

661 
SDL_VideoDisplay *display = &_this>displays[displayIndex]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

662 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

663 
if (_this>GetDisplayBounds) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

664 
if (_this>GetDisplayBounds(_this, display, rect) == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

665 
return 0; 
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 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

668 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

669 
/* 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

670 
if (displayIndex == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

671 
rect>x = 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

672 
rect>y = 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

673 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

674 
SDL_GetDisplayBounds(displayIndex1, rect); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

675 
rect>x += rect>w; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

676 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

677 
rect>w = display>current_mode.w; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

678 
rect>h = display>current_mode.h; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

679 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

680 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

681 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

682 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

683 
SDL_bool 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

684 
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

685 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

686 
SDL_DisplayMode *modes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

687 
int i, nmodes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

688 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

689 
/* 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

690 
modes = display>display_modes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

691 
nmodes = display>num_display_modes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

692 
for (i = 0; i < nmodes; ++i) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

693 
if (cmpmodes(mode, &modes[i]) == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

694 
return SDL_FALSE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

695 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

696 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

697 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

698 
/* Go ahead and add the new mode */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

699 
if (nmodes == display>max_display_modes) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

700 
modes = 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

701 
SDL_realloc(modes, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

702 
(display>max_display_modes + 32) * sizeof(*modes)); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

703 
if (!modes) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

704 
return SDL_FALSE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

705 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

706 
display>display_modes = modes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

707 
display>max_display_modes += 32; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

708 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

709 
modes[nmodes] = *mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

710 
display>num_display_modes++; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

711 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

712 
/* Resort video modes */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

713 
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

714 
sizeof(SDL_DisplayMode), cmpmodes); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

715 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

716 
return SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

717 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

718 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

719 
static int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

720 
SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

721 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

722 
if (!display>num_display_modes && _this>GetDisplayModes) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

723 
_this>GetDisplayModes(_this, display); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

724 
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

725 
sizeof(SDL_DisplayMode), cmpmodes); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

726 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

727 
return display>num_display_modes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

728 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

729 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

730 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

731 
SDL_GetNumDisplayModes(int displayIndex) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

732 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

733 
CHECK_DISPLAY_INDEX(displayIndex, 1); 
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 
return SDL_GetNumDisplayModesForDisplay(&_this>displays[displayIndex]); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

736 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

737 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

738 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

739 
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

740 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

741 
SDL_VideoDisplay *display; 
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 
CHECK_DISPLAY_INDEX(displayIndex, 1); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

744 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

745 
display = &_this>displays[displayIndex]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

746 
if (index < 0  index >= SDL_GetNumDisplayModesForDisplay(display)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

747 
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

748 
SDL_GetNumDisplayModesForDisplay(display)  1); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

749 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

750 
if (mode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

751 
*mode = display>display_modes[index]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

752 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

753 
return 0; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

756 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

757 
SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

758 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

759 
SDL_VideoDisplay *display; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

760 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

761 
CHECK_DISPLAY_INDEX(displayIndex, 1); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

762 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

763 
display = &_this>displays[displayIndex]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

764 
if (mode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

765 
*mode = display>desktop_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

766 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

767 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

768 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

769 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

770 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

771 
SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode) 
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 
SDL_VideoDisplay *display; 
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 
CHECK_DISPLAY_INDEX(displayIndex, 1); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

776 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

777 
display = &_this>displays[displayIndex]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

778 
if (mode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

779 
*mode = display>current_mode; 
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 0; 
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 
static SDL_DisplayMode * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

785 
SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

786 
const SDL_DisplayMode * mode, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

787 
SDL_DisplayMode * closest) 
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 
Uint32 target_format; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

790 
int target_refresh_rate; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

791 
int i; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

792 
SDL_DisplayMode *current, *match; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

793 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

794 
if (!mode  !closest) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

795 
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

796 
return NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

797 
} 
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 
/* Default to the desktop format */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

800 
if (mode>format) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

801 
target_format = mode>format; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

802 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

803 
target_format = display>desktop_mode.format; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

806 
/* Default to the desktop refresh rate */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

807 
if (mode>refresh_rate) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

808 
target_refresh_rate = mode>refresh_rate; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

809 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

810 
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

811 
} 
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 
match = NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

814 
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

815 
current = &display>display_modes[i]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

816 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

817 
if (current>w && (current>w < mode>w)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

818 
/* Out of sorted modes large enough here */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

819 
break; 
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 
if (current>h && (current>h < mode>h)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

822 
if (current>w && (current>w == mode>w)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

823 
/* Out of sorted modes large enough here */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

824 
break; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

825 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

826 
/* 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

827 
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

828 
modes may still follow. */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

829 
continue; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

830 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

831 
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

832 
match = current; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

833 
continue; 
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 
if (current>format != match>format) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

836 
/* Sorted highest depth to lowest */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

837 
if (current>format == target_format  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

838 
(SDL_BITSPERPIXEL(current>format) >= 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

839 
SDL_BITSPERPIXEL(target_format) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

840 
&& SDL_PIXELTYPE(current>format) == 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

841 
SDL_PIXELTYPE(target_format))) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

842 
match = current; 
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 
continue; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

845 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

846 
if (current>refresh_rate != match>refresh_rate) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

847 
/* Sorted highest refresh to lowest */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

848 
if (current>refresh_rate >= target_refresh_rate) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

849 
match = current; 
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 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

853 
if (match) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

854 
if (match>format) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

855 
closest>format = match>format; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

856 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

857 
closest>format = mode>format; 
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 
if (match>w && match>h) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

860 
closest>w = match>w; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

861 
closest>h = match>h; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

862 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

863 
closest>w = mode>w; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

864 
closest>h = mode>h; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

865 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

866 
if (match>refresh_rate) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

867 
closest>refresh_rate = match>refresh_rate; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

868 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

869 
closest>refresh_rate = mode>refresh_rate; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

870 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

871 
closest>driverdata = match>driverdata; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

872 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

873 
/* 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

874 
* 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

875 
* care 
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 (!closest>format) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

878 
closest>format = SDL_PIXELFORMAT_RGB888; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

879 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

880 
if (!closest>w) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

881 
closest>w = 640; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

882 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

883 
if (!closest>h) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

884 
closest>h = 480; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

885 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

886 
return closest; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

887 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

888 
return NULL; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

891 
SDL_DisplayMode * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

892 
SDL_GetClosestDisplayMode(int displayIndex, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

893 
const SDL_DisplayMode * mode, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

894 
SDL_DisplayMode * closest) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

895 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

896 
SDL_VideoDisplay *display; 
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 
CHECK_DISPLAY_INDEX(displayIndex, NULL); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

899 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

900 
display = &_this>displays[displayIndex]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

901 
return SDL_GetClosestDisplayModeForDisplay(display, mode, closest); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

902 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

903 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

904 
static int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

905 
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

906 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

907 
SDL_DisplayMode display_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

908 
SDL_DisplayMode current_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

909 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

910 
if (mode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

911 
display_mode = *mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

912 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

913 
/* Default to the current mode */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

914 
if (!display_mode.format) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

915 
display_mode.format = display>current_mode.format; 
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 
if (!display_mode.w) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

918 
display_mode.w = display>current_mode.w; 
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 
if (!display_mode.h) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

921 
display_mode.h = display>current_mode.h; 
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 (!display_mode.refresh_rate) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

924 
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

925 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

926 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

927 
/* 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

928 
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

929 
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

930 
display_mode.w, display_mode.h); 
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 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

933 
display_mode = display>desktop_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

934 
} 
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 
/* 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

937 
current_mode = display>current_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

938 
if (SDL_memcmp(&display_mode, ¤t_mode, sizeof(display_mode)) == 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

939 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

940 
} 
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 
/* Actually change the display mode */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

943 
if (!_this>SetDisplayMode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

944 
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

945 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

946 
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

947 
return 1; 
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 
display>current_mode = display_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

950 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

951 
} 
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 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

954 
SDL_GetWindowDisplayIndex(SDL_Window * window) 
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 
int displayIndex; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

957 
int i, dist; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

958 
int closest = 1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

959 
int closest_dist = 0x7FFFFFFF; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

960 
SDL_Point center; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

961 
SDL_Point delta; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

962 
SDL_Rect rect; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

963 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

964 
CHECK_WINDOW_MAGIC(window, 1); 
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 (SDL_WINDOWPOS_ISUNDEFINED(window>x)  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

967 
SDL_WINDOWPOS_ISCENTERED(window>x)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

968 
displayIndex = (window>x & 0xFFFF); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

969 
if (displayIndex >= _this>num_displays) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

970 
displayIndex = 0; 
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 
return displayIndex; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

973 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

974 
if (SDL_WINDOWPOS_ISUNDEFINED(window>y)  
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

975 
SDL_WINDOWPOS_ISCENTERED(window>y)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

976 
displayIndex = (window>y & 0xFFFF); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

977 
if (displayIndex >= _this>num_displays) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

978 
displayIndex = 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

979 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

980 
return displayIndex; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

983 
/* Find the display containing the window */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

984 
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

985 
SDL_VideoDisplay *display = &_this>displays[i]; 
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 
if (display>fullscreen_window == window) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

988 
return i; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

989 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

990 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

991 
center.x = window>x + window>w / 2; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

992 
center.y = window>y + window>h / 2; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

993 
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

994 
SDL_GetDisplayBounds(i, &rect); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

995 
if (SDL_EnclosePoints(¢er, 1, &rect, NULL)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

996 
return i; 
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 
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

1000 
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

1001 
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

1002 
if (dist < closest_dist) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1003 
closest = i; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1004 
closest_dist = dist; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1005 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1006 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1007 
if (closest < 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1008 
SDL_SetError("Couldn't find any displays"); 
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 
return closest; 
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 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1013 
SDL_VideoDisplay * 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1014 
SDL_GetDisplayForWindow(SDL_Window *window) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1015 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1016 
int displayIndex = SDL_GetWindowDisplayIndex(window); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1017 
if (displayIndex >= 0) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1018 
return &_this>displays[displayIndex]; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1019 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1020 
return NULL; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1021 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1022 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1023 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1024 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1025 
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

1026 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1027 
CHECK_WINDOW_MAGIC(window, 1); 
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 
if (mode) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1030 
window>fullscreen_mode = *mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1031 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1032 
SDL_zero(window>fullscreen_mode); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1033 
} 
8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1034 

3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1035 
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

1036 
SDL_DisplayMode fullscreen_mode; 
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1037 
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

1038 
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

1039 
} 
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1040 
} 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1041 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1042 
} 
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 
int 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1045 
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

1046 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1047 
SDL_DisplayMode fullscreen_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1048 
SDL_VideoDisplay *display; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1049 

8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1050 
CHECK_WINDOW_MAGIC(window, 1); 
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1051 

8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1052 
if (!mode) { 
8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1053 
return SDL_InvalidParamError("mode"); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1054 
} 
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 
fullscreen_mode = window>fullscreen_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1057 
if (!fullscreen_mode.w) { 
8823
15a1b4b8e20a
Setting the window size changes the fullscreen display mode, unless a window display mode has been set.
Sam Lantinga <slouken@libsdl.org>
parents:
8820
diff
changeset

1058 
fullscreen_mode.w = window>windowed.w; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1059 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1060 
if (!fullscreen_mode.h) { 
8823
15a1b4b8e20a
Setting the window size changes the fullscreen display mode, unless a window display mode has been set.
Sam Lantinga <slouken@libsdl.org>
parents:
8820
diff
changeset

1061 
fullscreen_mode.h = window>windowed.h; 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1062 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1063 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1064 
display = SDL_GetDisplayForWindow(window); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1065 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1066 
/* if in desktop size mode, just return the size of the desktop */ 
8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1067 
if ((window>flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1068 
fullscreen_mode = display>desktop_mode; 
8818
3b075068bf2e
When the window fullscreen mode changes, update the display resolution
Sam Lantinga <slouken@libsdl.org>
parents:
8783
diff
changeset

1069 
} else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window), 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1070 
&fullscreen_mode, 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1071 
&fullscreen_mode)) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1072 
return SDL_SetError("Couldn't find display mode match"); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1073 
} 
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 
*mode = fullscreen_mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1077 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1078 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1079 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1080 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1081 
Uint32 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1082 
SDL_GetWindowPixelFormat(SDL_Window * window) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1083 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1084 
SDL_VideoDisplay *display; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1085 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1086 
CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1087 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1088 
display = SDL_GetDisplayForWindow(window); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1089 
return display>current_mode.format; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1090 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1091 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1092 
static void 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1093 
SDL_RestoreMousePosition(SDL_Window *window) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1094 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1095 
int x, y; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1096 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1097 
if (window == SDL_GetMouseFocus()) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1098 
SDL_GetMouseState(&x, &y); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1099 
SDL_WarpMouseInWindow(window, x, y); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1100 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1101 
} 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1102 

c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1103 
static void 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1104 
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1105 
{ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1106 
SDL_VideoDisplay *display; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1107 
SDL_Window *other; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1108 

8823
15a1b4b8e20a
Setting the window size changes the fullscreen display mode, unless a window display mode has been set.
Sam Lantinga <slouken@libsdl.org>
parents:
8820
diff
changeset

1109 
CHECK_WINDOW_MAGIC(window,); 
8582
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

1110 

9037
e9d67ac0c6f8
SDL  fix reentrancy into SDL_UpdateFullscreenMode under OSX. During HideWindow we get a RESTORED event which then turns fullscreen back on causing a hang in Cocoa_SetWindowFullscreenSpace waiting for the fullscreen transition to finish.
Alfred Reynolds <alfred@valvesoftware.com> 