author  Edward Rudd <urkle@outoforder.cc> 
Thu, 19 Feb 2015 19:40:58 0500  
changeset 9363  c9a4d606f6db 
parent 9278  8900afb78a19 
child 9412  8b1436ce1028 
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 
9164
494876610c49
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents:
9163
diff
changeset

65 
#if SDL_VIDEO_DRIVER_WAYLAND 
494876610c49
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents:
9163
diff
changeset

66 
&Wayland_bootstrap, 
494876610c49
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents:
9163
diff
changeset

67 
#endif 
494876610c49
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents:
9163
diff
changeset

68 
#if SDL_VIDEO_DRIVER_VIVANTE 
494876610c49
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents:
9163
diff
changeset

69 
&VIVANTE_bootstrap, 
494876610c49
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
Sam Lantinga <slouken@libsdl.org>
parents:
9163
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

100 
#endif 
9278
8900afb78a19
Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
9164
diff
changeset

101 
#if SDL_VIDEO_DRIVER_EMSCRIPTEN 
8900afb78a19
Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
9164
diff
changeset

102 
&Emscripten_bootstrap, 
8900afb78a19
Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents:
9164
diff
changeset

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

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

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

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

107 
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 

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

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

111 

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

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

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

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

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

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

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

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

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

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

121 

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

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

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

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

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

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

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

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

129 
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

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

131 
return retval; \ 
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 

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

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

135 

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

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

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

138 
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

139 
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

140 
#endif 
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 

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

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

144 

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

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

146 

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

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

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

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

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

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

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

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

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

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

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

159 

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

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

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

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

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

164 

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

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

166 
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

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

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

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

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

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

172 

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

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

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

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

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

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

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

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

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

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

182 

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

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

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

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

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

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

188 

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

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

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

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

192 

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

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

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

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

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

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

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

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

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

201 

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

202 
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

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

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

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

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

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

208 

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

209 
glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

231 

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

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

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

234 
optimized for the current platform. 
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 
return SDL_FALSE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

238 
} 
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 
static int 
8922
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

241 
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

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

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

244 

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

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

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

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

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

249 
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

250 

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

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

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

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

254 
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

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

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

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

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

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

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

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

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

263 

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

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

265 
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

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

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

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

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

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

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

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

277 
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

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

279 

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

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

281 
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

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

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

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

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

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

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

290 

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

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

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

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

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

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

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

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

298 

8922
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 
SDL_RendererInfo info; 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

301 
Uint32 i; 
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 
if (SDL_GetRendererInfo(data>renderer, &info) < 0) { 
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

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

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

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

309 

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

310 
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

311 
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

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

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

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

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

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

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

318 

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

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

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

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

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

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

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

325 

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

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

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

328 
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

329 
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

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

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

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

335 
*pitch = data>pitch; 
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 
/* 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

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

341 
} 
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 
static int 
8922
dfb6f8611ebe
Fixed bug 2556  add compilation flag Wshadow
Sam Lantinga <slouken@libsdl.org>
parents:
8906
diff
changeset

344 
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

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

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

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

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

349 

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

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

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

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

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

354 

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

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

356 
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

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

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

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

360 
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

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

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

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

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

367 

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

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

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

372 

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

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

374 
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

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

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

377 

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

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

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

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

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

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

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

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

391 

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

392 

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

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

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

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

396 
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

397 
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

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

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

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

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

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

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

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

405 
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

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

407 
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

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

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

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

415 
SDL_UninitializedVideo() 
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 
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

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

421 
SDL_GetNumVideoDrivers(void) 
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 
return SDL_arraysize(bootstrap)  1; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

427 
SDL_GetVideoDriver(int index) 
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 
if (index >= 0 && index < SDL_GetNumVideoDrivers()) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

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

446 

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

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

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

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

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

451 

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

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

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

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

455 

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

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

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

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

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

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

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

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

463 

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

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

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

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

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

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

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

472 
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

473 
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

474 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

491 
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

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

493 
return SDL_SetError("No available video device"); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

498 

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

499 

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

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

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

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

503 
SDL_GL_ResetAttributes(); 
8582
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 
_this>current_glwin_tls = SDL_TLSCreate(); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

507 

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

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

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

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

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

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

513 

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

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

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

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

517 
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

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

519 

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

520 
/* Add the renderer framebuffer emulation if desired */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

526 

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

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

528 
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

529 
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

530 
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

531 
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

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

533 
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

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

535 
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

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

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

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

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

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

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

542 

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

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

544 
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

545 
UNICODE input won't get any events. 
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 
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

548 
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

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

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

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

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

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

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

557 

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

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

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

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

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

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

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

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

569 
SDL_GetVideoDevice(void) 
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 
return _this; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

578 

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

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

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

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

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

583 
display.current_mode = display.desktop_mode; 
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 
return SDL_AddVideoDisplay(&display); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

587 

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

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

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

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

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

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

593 

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

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

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

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

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

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

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

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

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

602 

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

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

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

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

606 
char name[32]; 
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 
SDL_itoa(index, name, 10); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

609 
displays[index].name = SDL_strdup(name); 
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 
} else { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

631 

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

632 
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

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

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

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

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

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

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

641 

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

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

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

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

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

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

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

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

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

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

657 

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

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

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

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

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

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

665 

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

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

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

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

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

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

671 

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

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

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

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

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

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

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

678 
rect>x += rect>w; 
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 
rect>w = display>current_mode.w; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

687 
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

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

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

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

691 

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

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

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

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

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

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

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

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

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

700 

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

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

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

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

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

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

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

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

710 
display>max_display_modes += 32; 
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 
modes[nmodes] = *mode; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

714 

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

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

716 
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

717 
sizeof(SDL_DisplayMode), cmpmodes); 
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 
return SDL_TRUE; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

727 
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

728 
sizeof(SDL_DisplayMode), cmpmodes); 
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 
return display>num_display_modes; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

732 

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

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

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

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

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

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

742 
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

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

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

745 

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

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

747 

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

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

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

750 
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

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

754 
*mode = display>display_modes[index]; 
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 
return 0; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

758 

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

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

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

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

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

763 

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

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

765 

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

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

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

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

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

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

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

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

777 

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

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

779 

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

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

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

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

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

786 

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

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

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

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

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

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

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

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

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

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

796 

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

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

798 
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

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

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

801 

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

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

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

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

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

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

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

808 

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

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

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

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

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

813 
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

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

815 

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

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

817 
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

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

819 

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

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

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

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

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

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

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

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

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

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

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

830 
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

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

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

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

834 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

872 
closest>refresh_rate = mode>refresh_rate; 
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 
closest>driverdata = match>driverdata; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

875 

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

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

881 
closest>format = SDL_PIXELFORMAT_RGB888; 
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>w) { 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

893 

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

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

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

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

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

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

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

900 

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

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

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

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

908 
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

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

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

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

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

915 

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

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

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

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

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

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

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

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

927 
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

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

929 

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

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

931 
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

932 
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

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

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

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

938 

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

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

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

941 
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

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

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

944 

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

945 
/* Actually change the display mode */ 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

947 
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

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

949 
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

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

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

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

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

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

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

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

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

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

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

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

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

966 

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

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

968 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

985 

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

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

987 
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

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

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

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

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

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

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

996 
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

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

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

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

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

1001 

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

1002 
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

1003 
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

1004 
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

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

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

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

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

1011 
SDL_SetError("Couldn't find any displays"); 
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 
return closest; 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

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

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

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

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

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

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

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

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

1026 

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

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

1028 
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

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

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

1031 

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

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

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

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

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

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

1037 

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

1038 
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

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

1040 
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

1041 
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

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

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

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

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

1048 
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

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

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

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

1052 

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

1053 
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

1054 

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

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

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

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

1058 

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

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

1060 
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

1061 
fullscreen_mode.w = window>windowed.w; 
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 
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

1064 
fullscreen_mode.h = window>windowed.h; 
8582
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 

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

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

1068 

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

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

1070 
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

1071 
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

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

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

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

1075 
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

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

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

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

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

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

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

1088 

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

1089 
CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN); 
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 
display = SDL_GetDisplayForWindow(window); 
c3e9a2b93517
Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents:
8543
diff
changeset

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

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

1096 
SDL_RestoreMousePosition(SDL_Window *window) 