author  Sam Lantinga <slouken@libsdl.org> 
Sun, 18 Jun 2006 13:47:19 +0000  
branch  SDL1.3 
changeset 1686  8d7fecceb9ef 
parent 1685  66267c6a0b12 
child 1687  d36048e8e302 
permissions  rwrr 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

1 
/* 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

2 
SDL  Simple DirectMedia Layer 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

3 
Copyright (C) 19972006 Sam Lantinga 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

4 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

5 
This library is free software; you can redistribute it and/or 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

6 
modify it under the terms of the GNU Lesser General Public 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

7 
License as published by the Free Software Foundation; either 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

8 
version 2.1 of the License, or (at your option) any later version. 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

9 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

10 
This library is distributed in the hope that it will be useful, 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

11 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

12 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

13 
Lesser General Public License for more details. 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

14 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

15 
You should have received a copy of the GNU Lesser General Public 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

16 
License along with this library; if not, write to the Free Software 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

17 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 021101301 USA 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

18 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

19 
Sam Lantinga 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

20 
slouken@libsdl.org 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

21 
*/ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

22 
#include "SDL_config.h" 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

23 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

24 
/* This file contains functions for backwards compatibility with SDL 1.2 */ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

25 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

26 
#include "SDL.h" 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

27 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

28 
#include "video/SDL_pixels_c.h" 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

29 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

30 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

31 
static SDL_WindowID SDL_VideoWindow; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

32 
static SDL_TextureID SDL_VideoTexture; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

33 
static SDL_Surface *SDL_VideoSurface; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

34 
static SDL_Surface *SDL_ShadowSurface; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

35 
static SDL_Surface *SDL_PublicSurface; 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

36 
static char *wm_title; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

37 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

38 
char * 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

39 
SDL_AudioDriverName(char *namebuf, int maxlen) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

40 
{ 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

41 
const char *name = SDL_GetCurrentAudioDriver(); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

42 
if (name) { 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

43 
SDL_strlcpy(namebuf, name, maxlen); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

44 
return namebuf; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

45 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

46 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

47 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

48 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

49 
char * 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

50 
SDL_VideoDriverName(char *namebuf, int maxlen) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

51 
{ 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

52 
const char *name = SDL_GetCurrentVideoDriver(); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

53 
if (name) { 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

54 
SDL_strlcpy(namebuf, name, maxlen); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

55 
return namebuf; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

56 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

57 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

58 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

59 

1670  60 
const SDL_VideoInfo * 
61 
SDL_GetVideoInfo(void) 

62 
{ 

63 
static SDL_VideoInfo info; 

64 

65 
/* Memory leak, compatibility code, who cares? */ 

66 
if (!info.vfmt && SDL_GetDesktopDisplayMode()) { 

67 
int bpp; 

68 
Uint32 Rmask, Gmask, Bmask, Amask; 

69 

70 
SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()>format, &bpp, 

71 
&Rmask, &Gmask, &Bmask, &Amask); 

72 
info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); 

73 
} 

74 
return &info; 

75 
} 

76 

1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

77 
int 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

78 
SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

79 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

80 
int i, actual_bpp = 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

81 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

82 
if (!SDL_GetVideoDevice()) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

83 
return 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

84 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

85 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

86 
if (!(flags & SDL_FULLSCREEN)) { 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

87 
return SDL_BITSPERPIXEL(SDL_GetDesktopDisplayMode()>format); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

88 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

89 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

90 
for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { 
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

91 
const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

92 
if (!mode>w  !mode>h  (width == mode>w && height == mode>h)) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

93 
if (!mode>format) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

94 
return bpp; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

95 
} 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

96 
if (SDL_BITSPERPIXEL(mode>format) >= bpp) { 
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

97 
actual_bpp = SDL_BITSPERPIXEL(mode>format); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

98 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

99 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

100 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

101 
return actual_bpp; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

102 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

103 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

104 
SDL_Rect ** 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

105 
SDL_ListModes(SDL_PixelFormat * format, Uint32 flags) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

106 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

107 
int i, nmodes; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

108 
SDL_Rect **modes; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

109 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

110 
if (!SDL_GetVideoDevice()) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

111 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

112 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

113 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

114 
if (!(flags & SDL_FULLSCREEN)) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

115 
return (SDL_Rect **) (1); 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

116 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

117 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

118 
/* Memory leak, but this is a compatibility function, who cares? */ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

119 
nmodes = 0; 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

120 
for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { 
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

121 
const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

122 
if (!mode>w  !mode>h) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

123 
return (SDL_Rect **) (1); 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

124 
} 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

125 
if (SDL_BITSPERPIXEL(mode>format) != format>BitsPerPixel) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

126 
continue; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

127 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

128 
if (nmodes > 0 && modes[nmodes  1]>w == mode>w 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

129 
&& modes[nmodes  1]>h == mode>h) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

130 
continue; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

131 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

132 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

133 
modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes)); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

134 
if (!modes) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

135 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

136 
} 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

137 
modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

138 
if (!modes[nmodes]) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

139 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

140 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

141 
modes[nmodes]>x = 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

142 
modes[nmodes]>y = 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

143 
modes[nmodes]>w = mode>w; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

144 
modes[nmodes]>h = mode>h; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

145 
++nmodes; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

146 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

147 
if (modes) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

148 
modes[nmodes] = NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

149 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

150 
return modes; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

151 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

152 

1686
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

153 
static int (*orig_eventfilter) (SDL_Event * event); 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

154 

9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

155 
static int 
1686
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

156 
SDL_CompatEventFilter(SDL_Event * event) 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

157 
{ 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

158 
SDL_Event fake; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

159 

9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

160 
switch (event>type) { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

161 
case SDL_WINDOWEVENT: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

162 
switch (event>window.event) { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

163 
case SDL_WINDOWEVENT_RESIZED: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

164 
fake.type = SDL_VIDEORESIZE; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

165 
fake.resize.w = event>window.data1; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

166 
fake.resize.h = event>window.data2; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

167 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

168 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

169 
case SDL_WINDOWEVENT_MINIMIZED: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

170 
fake.type = SDL_ACTIVEEVENT; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

171 
fake.active.gain = 0; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

172 
fake.active.state = SDL_APPACTIVE; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

173 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

174 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

175 
case SDL_WINDOWEVENT_RESTORED: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

176 
fake.type = SDL_ACTIVEEVENT; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

177 
fake.active.gain = 1; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

178 
fake.active.state = SDL_APPACTIVE; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

179 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

180 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

181 
case SDL_WINDOWEVENT_ENTER: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

182 
fake.type = SDL_ACTIVEEVENT; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

183 
fake.active.gain = 1; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

184 
fake.active.state = SDL_APPMOUSEFOCUS; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

185 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

186 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

187 
case SDL_WINDOWEVENT_LEAVE: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

188 
fake.type = SDL_ACTIVEEVENT; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

189 
fake.active.gain = 0; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

190 
fake.active.state = SDL_APPMOUSEFOCUS; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

191 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

192 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

193 
case SDL_WINDOWEVENT_FOCUS_GAINED: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

194 
fake.type = SDL_ACTIVEEVENT; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

195 
fake.active.gain = 1; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

196 
fake.active.state = SDL_APPINPUTFOCUS; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

197 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

198 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

199 
case SDL_WINDOWEVENT_FOCUS_LOST: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

200 
fake.type = SDL_ACTIVEEVENT; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

201 
fake.active.gain = 1; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

202 
fake.active.state = SDL_APPINPUTFOCUS; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

203 
SDL_PushEvent(&fake); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

204 
break; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

205 
} 
1686
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

206 
case SDL_KEYDOWN: 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

207 
case SDL_KEYUP: 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

208 
{ 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

209 
Uint32 unicode = 0; 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

210 
if (event>key.type == SDL_KEYDOWN && event>key.keysym.sym < 256) { 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

211 
int shifted = !!(event>key.keysym.mod & KMOD_SHIFT); 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

212 
int capslock = !!(event>key.keysym.mod & KMOD_CAPS); 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

213 
if ((shifted ^ capslock) != 0) { 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

214 
unicode = SDL_toupper(event>key.keysym.sym); 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

215 
} else { 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

216 
unicode = event>key.keysym.sym; 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

217 
} 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

218 
} 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

219 
if (unicode) { 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

220 
event>key.keysym.unicode = unicode; 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

221 
} 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

222 
break; 
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

223 
} 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

224 
} 
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

225 
if (orig_eventfilter) { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

226 
return orig_eventfilter(event); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

227 
} else { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

228 
return 1; 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

229 
} 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

230 
} 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

231 

396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

232 
static int 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

233 
SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette) 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

234 
{ 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

235 
if (userdata == SDL_ShadowSurface) { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

236 
/* If the shadow palette changed, make the changes visible */ 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

237 
if (!SDL_VideoSurface>format>palette) { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

238 
SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

239 
} 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

240 
} 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

241 
if (userdata == SDL_VideoSurface) { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

242 
return SDL_SetDisplayPalette(palette>colors, 0, palette>ncolors); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

243 
} 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

244 
} 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

245 

1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

246 
SDL_Surface * 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

247 
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

248 
{ 
1686
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset

249 
int (*filter) (SDL_Event * event); 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

250 
const SDL_DisplayMode *desktop_mode; 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

251 
SDL_DisplayMode mode; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

252 
int i; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

253 
Uint32 window_flags; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

254 
Uint32 desktop_format; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

255 
Uint32 desired_format; 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

256 
Uint32 texture_format; 
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

257 
Uint32 surface_flags; 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

258 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

259 
if (!SDL_GetVideoDevice()) { 
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

260 
if (SDL_Init(SDL_INIT_VIDEO  SDL_INIT_NOPARACHUTE) < 0) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

261 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

262 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

263 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

264 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

265 
/* Destroy existing window */ 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

266 
SDL_PublicSurface = NULL; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

267 
if (SDL_ShadowSurface) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

268 
SDL_FreeSurface(SDL_ShadowSurface); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

269 
SDL_ShadowSurface = NULL; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

270 
} 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

271 
if (SDL_VideoSurface) { 
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

272 
SDL_DelPaletteWatch(SDL_VideoSurface>format>palette, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

273 
SDL_VideoPaletteChanged, NULL); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

274 
SDL_FreeSurface(SDL_VideoSurface); 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

275 
SDL_VideoSurface = NULL; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

276 
} 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

277 
SDL_DestroyWindow(SDL_VideoWindow); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

278 

1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

279 
/* Set up the event filter */ 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

280 
filter = SDL_GetEventFilter(); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

281 
if (filter != SDL_CompatEventFilter) { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

282 
orig_eventfilter = filter; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

283 
} 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

284 
SDL_SetEventFilter(SDL_CompatEventFilter); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

285 

1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

286 
/* Create a new window */ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

287 
window_flags = SDL_WINDOW_SHOWN; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

288 
if (flags & SDL_FULLSCREEN) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

289 
window_flags = SDL_WINDOW_FULLSCREEN; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

290 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

291 
if (flags & SDL_OPENGL) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

292 
window_flags = SDL_WINDOW_OPENGL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

293 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

294 
if (flags & SDL_RESIZABLE) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

295 
window_flags = SDL_WINDOW_RESIZABLE; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

296 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

297 
if (flags & SDL_NOFRAME) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

298 
window_flags = SDL_WINDOW_BORDERLESS; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

299 
} 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

300 
SDL_VideoWindow = 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

301 
SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

302 
if (!SDL_VideoWindow) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

303 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

304 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

305 

1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

306 
window_flags = SDL_GetWindowFlags(SDL_VideoWindow); 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

307 
surface_flags = SDL_SCREEN_SURFACE; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

308 
if (window_flags & SDL_WINDOW_FULLSCREEN) { 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

309 
surface_flags = SDL_FULLSCREEN; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

310 
} 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

311 
if (window_flags & SDL_WINDOW_OPENGL) { 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

312 
surface_flags = SDL_OPENGL; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

313 
} 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

314 
if (window_flags & SDL_WINDOW_RESIZABLE) { 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

315 
surface_flags = SDL_RESIZABLE; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

316 
} 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

317 
if (window_flags & SDL_WINDOW_BORDERLESS) { 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

318 
surface_flags = SDL_NOFRAME; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

319 
} 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

320 

1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

321 
/* Set up the desired display mode */ 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

322 
desktop_mode = SDL_GetDesktopDisplayMode(); 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

323 
desktop_format = desktop_mode>format; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

324 
if (desktop_format && ((flags & SDL_ANYFORMAT) 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

325 
 (bpp == SDL_BITSPERPIXEL(desktop_format)))) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

326 
desired_format = desktop_format; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

327 
} else { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

328 
switch (bpp) { 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

329 
case 0: 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

330 
if (desktop_format) { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

331 
desired_format = desktop_format; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

332 
} else { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

333 
desired_format = SDL_PixelFormat_RGB888; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

334 
} 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

335 
break; 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

336 
case 8: 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

337 
desired_format = SDL_PixelFormat_Index8; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

338 
break; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

339 
case 15: 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

340 
desired_format = SDL_PixelFormat_RGB555; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

341 
break; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

342 
case 16: 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

343 
desired_format = SDL_PixelFormat_RGB565; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

344 
break; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

345 
case 24: 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

346 
desired_format = SDL_PixelFormat_RGB24; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

347 
break; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

348 
case 32: 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

349 
desired_format = SDL_PixelFormat_RGB888; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

350 
break; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

351 
default: 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

352 
SDL_SetError("Unsupported bpp in SDL_SetVideoMode()"); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

353 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

354 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

355 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

356 
mode.format = desired_format; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

357 
mode.w = width; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

358 
mode.h = height; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

359 
mode.refresh_rate = 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

360 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

361 
/* Set the desired display mode */ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

362 
if (flags & SDL_FULLSCREEN) { 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

363 
if (!SDL_GetClosestDisplayMode(&mode, &mode)) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

364 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

365 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

366 
} else { 
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

367 
if (desktop_format) { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

368 
mode.format = desktop_format; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

369 
} 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

370 
if (desktop_mode>w && desktop_mode>h) { 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

371 
mode.w = desktop_mode>w; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

372 
mode.h = desktop_mode>h; 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

373 
} 
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset

374 
mode.refresh_rate = desktop_mode>refresh_rate; 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

375 
} 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

376 
if (SDL_SetDisplayMode(&mode) < 0) { 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

377 
return NULL; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

378 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

379 

1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

380 
/* If we're in OpenGL mode, just create a stub surface and we're done! */ 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

381 
if (flags & SDL_OPENGL) { 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

382 
SDL_VideoSurface = 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

383 
SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0); 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

384 
if (!SDL_VideoSurface) { 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

385 
return NULL; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

386 
} 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

387 
SDL_VideoSurface>flags = surface_flags; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

388 
SDL_PublicSurface = SDL_VideoSurface; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

389 
return SDL_PublicSurface; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

390 
} 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

391 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

392 
/* Create a renderer for the window */ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

393 
if (SDL_CreateRenderer(SDL_VideoWindow, 1, 0) < 0) { 
1670  394 
return NULL; 
395 
} 

396 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

397 
/* Create a texture for the screen surface */ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

398 
SDL_VideoTexture = 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

399 
SDL_CreateTexture(desired_format, SDL_TextureAccess_Local, width, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

400 
height); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

401 
if (!SDL_VideoTexture) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

402 
SDL_VideoTexture = 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

403 
SDL_CreateTexture(0, SDL_TextureAccess_Local, width, height); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

404 
} 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

405 
if (!SDL_VideoTexture) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

406 
return NULL; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

407 
} 
1670  408 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

409 
/* Create the screen surface */ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

410 
SDL_VideoSurface = SDL_CreateRGBSurfaceFromTexture(SDL_VideoTexture); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

411 
if (!SDL_VideoSurface) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

412 
return NULL; 
1670  413 
} 
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

414 
SDL_VideoSurface>flags = surface_flags; 
1670  415 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

416 
/* Set a default screen palette */ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

417 
if (SDL_VideoSurface>format>palette) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

418 
SDL_VideoSurface>flags = SDL_HWPALETTE; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

419 
SDL_DitherColors(SDL_VideoSurface>format>palette>colors, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

420 
SDL_VideoSurface>format>BitsPerPixel); 
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

421 
SDL_AddPaletteWatch(SDL_VideoSurface>format>palette, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

422 
SDL_VideoPaletteChanged, NULL); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

423 
SDL_SetPaletteColors(SDL_VideoSurface>format>palette, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

424 
SDL_VideoSurface>format>palette>colors, 0, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

425 
SDL_VideoSurface>format>palette>ncolors); 
1670  426 
} 
427 

428 
/* Create a shadow surface if necessary */ 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

429 
if (((bpp != SDL_VideoSurface>format>BitsPerPixel) 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

430 
&& !(flags & SDL_ANYFORMAT)) 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

431 
 ((SDL_VideoSurface>flags & SDL_HWSURFACE) 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

432 
&& !(flags & SDL_HWSURFACE))) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

433 
if ((bpp == SDL_VideoSurface>format>BitsPerPixel) 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

434 
 (flags & SDL_ANYFORMAT)) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

435 
SDL_ShadowSurface = 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

436 
SDL_CreateRGBSurface(0, width, height, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

437 
SDL_VideoSurface>format>BitsPerPixel, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

438 
SDL_VideoSurface>format>Rmask, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

439 
SDL_VideoSurface>format>Gmask, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

440 
SDL_VideoSurface>format>Bmask, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

441 
SDL_VideoSurface>format>Amask); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

442 
} else { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

443 
SDL_ShadowSurface = 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

444 
SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

445 
} 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

446 
if (!SDL_ShadowSurface) { 
1670  447 
return NULL; 
448 
} 

1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

449 
surface_flags &= ~SDL_SCREEN_SURFACE; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

450 
surface_flags = SDL_SHADOW_SURFACE; 
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

451 
SDL_ShadowSurface>flags = surface_flags; 
1670  452 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

453 
/* 8bit SDL_ShadowSurface surfaces report that they have exclusive palette */ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

454 
if (SDL_ShadowSurface>format>palette) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

455 
SDL_ShadowSurface>flags = SDL_HWPALETTE; 
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

456 
if (SDL_VideoSurface>format>palette) { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

457 
SDL_SetSurfacePalette(SDL_ShadowSurface, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

458 
SDL_VideoSurface>format>palette); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

459 
} else { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

460 
SDL_DitherColors(SDL_ShadowSurface>format>palette>colors, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

461 
SDL_ShadowSurface>format>BitsPerPixel); 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

462 
} 
1670  463 
} 
464 
} 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

465 
SDL_PublicSurface = 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

466 
(SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface); 
1670  467 

468 
/* Clear the surface for display */ 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

469 
SDL_FillRect(SDL_PublicSurface, NULL, 0); 
1670  470 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

471 
/* We're finally done! */ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

472 
return SDL_PublicSurface; 
1670  473 
} 
474 

475 
SDL_Surface * 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

476 
SDL_GetVideoSurface(void) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

477 
{ 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

478 
return SDL_PublicSurface; 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

479 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

480 

1670  481 
SDL_Surface * 
482 
SDL_DisplayFormat(SDL_Surface * surface) 

483 
{ 

484 
Uint32 flags; 

485 

486 
if (!SDL_PublicSurface) { 

487 
SDL_SetError("No video mode has been set"); 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

488 
return NULL; 
1670  489 
} 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

490 

1670  491 
/* Set the flags appropriate for copying to display surface */ 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

492 
flags = SDL_SWSURFACE; 
1670  493 
#ifdef AUTORLE_DISPLAYFORMAT 
494 
flags = (surface>flags & (SDL_SRCCOLORKEY  SDL_SRCALPHA)); 

495 
flags = SDL_RLEACCELOK; 

496 
#else 

497 
flags = 

498 
surface>flags & (SDL_SRCCOLORKEY  SDL_SRCALPHA  SDL_RLEACCELOK); 

499 
#endif 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

500 
return SDL_ConvertSurface(surface, SDL_PublicSurface>format, flags); 
1670  501 
} 
502 

503 
SDL_Surface * 

504 
SDL_DisplayFormatAlpha(SDL_Surface * surface) 

505 
{ 

506 
SDL_PixelFormat *vf; 

507 
SDL_PixelFormat *format; 

508 
SDL_Surface *converted; 

509 
Uint32 flags; 

510 
/* default to ARGB8888 */ 

511 
Uint32 amask = 0xff000000; 

512 
Uint32 rmask = 0x00ff0000; 

513 
Uint32 gmask = 0x0000ff00; 

514 
Uint32 bmask = 0x000000ff; 

515 

516 
if (!SDL_PublicSurface) { 

517 
SDL_SetError("No video mode has been set"); 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

518 
return NULL; 
1670  519 
} 
520 
vf = SDL_PublicSurface>format; 

521 

522 
switch (vf>BytesPerPixel) { 

523 
case 2: 

524 
/* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}. 

525 
For anything else (like ARGB4444) it doesn't matter 

526 
since we have no special code for it anyway */ 

527 
if ((vf>Rmask == 0x1f) && 

528 
(vf>Bmask == 0xf800  vf>Bmask == 0x7c00)) { 

529 
rmask = 0xff; 

530 
bmask = 0xff0000; 

531 
} 

532 
break; 

533 

534 
case 3: 

535 
case 4: 

536 
/* Keep the video format, as long as the high 8 bits are 

537 
unused or alpha */ 

538 
if ((vf>Rmask == 0xff) && (vf>Bmask == 0xff0000)) { 

539 
rmask = 0xff; 

540 
bmask = 0xff0000; 

541 
} 

542 
break; 

543 

544 
default: 

545 
/* We have no other optimised formats right now. When/if a new 

546 
optimised alpha format is written, add the converter here */ 

547 
break; 

548 
} 

549 
format = SDL_AllocFormat(32, rmask, gmask, bmask, amask); 

550 
flags = SDL_PublicSurface>flags & SDL_HWSURFACE; 

551 
flags = surface>flags & (SDL_SRCALPHA  SDL_RLEACCELOK); 

552 
converted = SDL_ConvertSurface(surface, format, flags); 

553 
SDL_FreeFormat(format); 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

554 
return converted; 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

555 
} 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

556 

90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

557 
int 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

558 
SDL_Flip(SDL_Surface * screen) 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

559 
{ 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

560 
SDL_UpdateRect(screen, 0, 0, 0, 0); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

561 
return 0; 
1670  562 
} 
563 

564 
void 

565 
SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) 

566 
{ 

567 
if (screen) { 

568 
SDL_Rect rect; 

569 

570 
/* Perform some checking */ 

571 
if (w == 0) 

572 
w = screen>w; 

573 
if (h == 0) 

574 
h = screen>h; 

575 
if ((int) (x + w) > screen>w) 

576 
return; 

577 
if ((int) (y + h) > screen>h) 

578 
return; 

579 

580 
/* Fill the rectangle */ 

581 
rect.x = (Sint16) x; 

582 
rect.y = (Sint16) y; 

583 
rect.w = (Uint16) w; 

584 
rect.h = (Uint16) h; 

585 
SDL_UpdateRects(screen, 1, &rect); 

586 
} 

587 
} 

588 
void 

589 
SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects) 

590 
{ 

591 
int i; 

592 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

593 
if (screen == SDL_ShadowSurface) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

594 
for (i = 0; i < numrects; ++i) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

595 
SDL_LowerBlit(SDL_ShadowSurface, &rects[i], SDL_VideoSurface, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

596 
&rects[i]); 
1670  597 
} 
598 

599 
/* Fall through to video surface update */ 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

600 
screen = SDL_VideoSurface; 
1670  601 
} 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

602 
if (screen == SDL_VideoSurface) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

603 
for (i = 0; i < numrects; ++i) { 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

604 
SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i], 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

605 
SDL_TextureBlendMode_None, 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

606 
SDL_TextureScaleMode_None); 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

607 
} 
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

608 
SDL_RenderPresent(); 
1670  609 
} 
610 
} 

611 

1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

612 
void 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

613 
SDL_WM_SetCaption(const char *title, const char *icon) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

614 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

615 
if (wm_title) { 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

616 
SDL_free(wm_title); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

617 
} else { 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

618 
wm_title = SDL_strdup(title); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

619 
} 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

620 
SDL_SetWindowTitle(SDL_VideoWindow, wm_title); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

621 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

622 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

623 
void 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

624 
SDL_WM_GetCaption(char **title, char **icon) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

625 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

626 
if (title) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

627 
*title = wm_title; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

628 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

629 
if (icon) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

630 
*icon = ""; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

631 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

632 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

633 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

634 
void 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

635 
SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

636 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

637 
/* FIXME */ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

638 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

639 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

640 
int 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

641 
SDL_WM_IconifyWindow(void) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

642 
{ 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

643 
SDL_MinimizeWindow(SDL_VideoWindow); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

644 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

645 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

646 
int 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

647 
SDL_WM_ToggleFullScreen(SDL_Surface * surface) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

648 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

649 
return 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

650 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

651 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

652 
SDL_GrabMode 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

653 
SDL_WM_GrabInput(SDL_GrabMode mode) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

654 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

655 
if (mode != SDL_GRAB_QUERY) { 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

656 
SDL_SetWindowGrab(SDL_VideoWindow, mode); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

657 
} 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

658 
return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

659 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

660 

1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset

661 
void 
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset

662 
SDL_WarpMouse(Uint16 x, Uint16 y) 
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset

663 
{ 
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset

664 
SDL_WarpMouseInWindow(SDL_VideoWindow, x, y); 
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset

665 
} 
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset

666 

1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

667 
Uint8 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

668 
SDL_GetAppState(void) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

669 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

670 
Uint8 state = 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

671 
Uint32 flags = 0; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

672 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

673 
flags = SDL_GetWindowFlags(SDL_VideoWindow); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

674 
if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

675 
state = SDL_APPACTIVE; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

676 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

677 
if (flags & SDL_WINDOW_KEYBOARD_FOCUS) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

678 
state = SDL_APPINPUTFOCUS; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

679 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

680 
if (flags & SDL_WINDOW_MOUSE_FOCUS) { 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

681 
state = SDL_APPMOUSEFOCUS; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

682 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

683 
return state; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

684 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

685 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

686 
const SDL_version * 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

687 
SDL_Linked_Version(void) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

688 
{ 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

689 
static SDL_version version; 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

690 
SDL_VERSION(&version); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

691 
return &version; 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

692 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

693 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

694 
int 
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset

695 
SDL_SetPalette(SDL_Surface * surface, int flags, const SDL_Color * colors, 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

696 
int firstcolor, int ncolors) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

697 
{ 
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

698 
SDL_SetColors(surface, colors, firstcolor, ncolors); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

699 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

700 

1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

701 
int 
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

702 
SDL_SetColors(SDL_Surface * surface, const SDL_Color * colors, int firstcolor, 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

703 
int ncolors) 
1670  704 
{ 
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

705 
if (SDL_SetPaletteColors 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

706 
(surface>format>palette, colors, firstcolor, ncolors) == 0) { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

707 
return 1; 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

708 
} else { 
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset

709 
return 0; 
1670  710 
} 
711 
} 

712 

713 
int 

1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset

714 
SDL_GetWMInfo(SDL_SysWMinfo * info) 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

715 
{ 
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

716 
return SDL_GetWindowWMInfo(SDL_VideoWindow, info); 
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

717 
} 
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

718 

1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset

719 
#if 0 
1670  720 
void 
721 
SDL_MoveCursor(int x, int y) 

722 
{ 

723 
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 

724 

725 
/* Erase and update the current mouse position */ 

726 
if (SHOULD_DRAWCURSOR(SDL_cursorstate)) { 

727 
/* Erase and redraw mouse cursor in new position */ 

728 
SDL_LockCursor(); 

729 
SDL_EraseCursor(SDL_VideoSurface); 

730 
SDL_cursor>area.x = (x  SDL_cursor>hot_x); 

731 
SDL_cursor>area.y = (y  SDL_cursor>hot_y); 

732 
SDL_DrawCursor(SDL_VideoSurface); 

733 
SDL_UnlockCursor(); 

734 
} else if (_this>MoveWMCursor) { 

735 
_this>MoveWMCursor(_this, x, y); 

736 
} 

737 
} 

738 

739 
/* Keep track of the current cursor colors */ 

740 
static int palette_changed = 1; 

741 
static Uint8 pixels8[2]; 

742 

743 
void 

744 
SDL_CursorPaletteChanged(void) 

745 
{ 

746 
palette_changed = 1; 

747 
} 

748 

749 
void 

750 
SDL_MouseRect(SDL_Rect * area) 

751 
{ 

752 
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 

753 
int clip_diff; 

754 

755 
*area = SDL_cursor>area; 

756 
if (area>x < 0) { 

757 
area>w += area>x; 

758 
area>x = 0; 

759 
} 

760 
if (area>y < 0) { 

761 
area>h += area>y; 

762 
area>y = 0; 

763 
} 

764 
clip_diff = (area>x + area>w)  SDL_VideoSurface>w; 

765 
if (clip_diff > 0) { 

766 
area>w = area>w < clip_diff ? 0 : area>w  clip_diff; 

767 
} 

768 
clip_diff = (area>y + area>h)  SDL_VideoSurface>h; 

769 
if (clip_diff > 0) { 

770 
area>h = area>h < clip_diff ? 0 : area>h  clip_diff; 

771 
} 

772 
} 

773 

774 
static void 

775 
SDL_DrawCursorFast(SDL_Surface * screen, SDL_Rect * area) 

776 
{ 

777 
const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 }; 

778 
int i, w, h; 

779 
Uint8 *data, datab; 

780 
Uint8 *mask, maskb; 

781 

782 
data = SDL_cursor>data + area>y * SDL_cursor>area.w / 8; 

783 
mask = SDL_cursor>mask + area>y * SDL_cursor>area.w / 8; 

784 
switch (screen>format>BytesPerPixel) { 

785 

786 
case 1: 

787 
{ 

788 
Uint8 *dst; 

789 
int dstskip; 

790 

791 
if (palette_changed) { 

792 
pixels8[0] = 

793 
(Uint8) SDL_MapRGB(screen>format, 255, 255, 255); 

794 
pixels8[1] = (Uint8) SDL_MapRGB(screen>format, 0, 0, 0); 

795 
palette_changed = 0; 

796 
} 

797 
dst = (Uint8 *) screen>pixels + 

798 
(SDL_cursor>area.y + area>y) * screen>pitch + 

799 
SDL_cursor>area.x; 

800 
dstskip = screen>pitch  area>w; 

801 

802 
for (h = area>h; h; h) { 

803 
for (w = area>w / 8; w; w) { 

804 
maskb = *mask++; 

805 
datab = *data++; 

806 
for (i = 0; i < 8; ++i) { 

807 
if (maskb & 0x80) { 

808 
*dst = pixels8[datab >> 7]; 

809 
} 

810 
maskb <<= 1; 

811 
datab <<= 1; 

812 
dst++; 

813 
} 

814 
} 

815 
dst += dstskip; 

816 
} 

817 
} 

818 
break; 

819 

820 
case 2: 

821 
{ 

822 
Uint16 *dst; 

823 
int dstskip; 

824 

825 
dst = (Uint16 *) screen>pixels + 

826 
(SDL_cursor>area.y + area>y) * screen>pitch / 2 + 

827 
SDL_cursor>area.x; 

828 
dstskip = (screen>pitch / 2)  area>w; 

829 

830 
for (h = area>h; h; h) { 

831 
for (w = area>w / 8; w; w) { 

832 
maskb = *mask++; 

833 
datab = *data++; 

834 
for (i = 0; i < 8; ++i) { 

835 
if (maskb & 0x80) { 

836 
*dst = (Uint16) pixels[datab >> 7]; 

837 
} 

838 
maskb <<= 1; 

839 
datab <<= 1; 

840 
dst++; 

841 
} 

842 
} 

843 
dst += dstskip; 

844 
} 

845 
} 

846 
break; 

847 

848 
case 3: 

849 
{ 

850 
Uint8 *dst; 

851 
int dstskip; 

852 

853 
dst = (Uint8 *) screen>pixels + 

854 
(SDL_cursor>area.y + area>y) * screen>pitch + 

855 
SDL_cursor>area.x * 3; 

856 
dstskip = screen>pitch  area>w * 3; 

857 

858 
for (h = area>h; h; h) { 

859 
for (w = area>w / 8; w; w) { 

860 
maskb = *mask++; 

861 
datab = *data++; 

862 
for (i = 0; i < 8; ++i) { 

863 
if (maskb & 0x80) { 

864 
SDL_memset(dst, pixels[datab >> 7], 3); 

865 
} 

866 
maskb <<= 1; 

867 
datab <<= 1; 

868 
dst += 3; 

869 
} 

870 
} 

871 
dst += dstskip; 

872 
} 

873 
} 

874 
break; 

875 

876 
case 4: 

877 
{ 

878 
Uint32 *dst; 

879 
int dstskip; 

880 

881 
dst = (Uint32 *) screen>pixels + 

882 
(SDL_cursor>area.y + area>y) * screen>pitch / 4 + 

883 
SDL_cursor>area.x; 

884 
dstskip = (screen>pitch / 4)  area>w; 

885 

886 
for (h = area>h; h; h) { 

887 
for (w = area>w / 8; w; w) { 

888 
maskb = *mask++; 

889 
datab = *data++; 

890 
for (i = 0; i < 8; ++i) { 

891 
if (maskb & 0x80) { 

892 
*dst = pixels[datab >> 7]; 

893 
} 

894 
maskb <<= 1; 

895 
datab <<= 1; 

896 
dst++; 

897 
} 

898 
} 

899 
dst += dstskip; 

900 
} 

901 
} 

902 
break; 

903 
} 

904 
} 

905 

906 
static void 

907 
SDL_DrawCursorSlow(SDL_Surface * screen, SDL_Rect * area) 

908 
{ 

909 
const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 }; 

910 
int h; 

911 
int x, minx, maxx; 

912 
Uint8 *data, datab = 0; 

913 
Uint8 *mask, maskb = 0; 

914 
Uint8 *dst; 

915 
int dstbpp, dstskip; 

916 

917 
data = SDL_cursor>data + area>y * SDL_cursor>area.w / 8; 

918 
mask = SDL_cursor>mask + area>y * SDL_cursor>area.w / 8; 

919 
dstbpp = screen>format>BytesPerPixel; 

920 
dst = (Uint8 *) screen>pixels + 

921 
(SDL_cursor>area.y + area>y) * screen>pitch + 

922 
SDL_cursor>area.x * dstbpp; 

923 
dstskip = screen>pitch  SDL_cursor>area.w * dstbpp; 

924 

925 
minx = area>x; 

926 
maxx = area>x + area>w; 

927 
if (screen>format>BytesPerPixel == 1) { 

928 
if (palette_changed) { 

929 
pixels8[0] = (Uint8) SDL_MapRGB(screen>format, 255, 255, 255); 

930 
pixels8[1] = (Uint8) SDL_MapRGB(screen>format, 0, 0, 0); 

931 
palette_changed = 0; 

932 
} 

933 
for (h = area>h; h; h) { 

934 
for (x = 0; x < SDL_cursor>area.w; ++x) { 

935 
if ((x % 8) == 0) { 

936 
maskb = *mask++; 

937 
datab = *data++; 

938 
} 

939 
if ((x >= minx) && (x < maxx)) { 

940 
if (maskb & 0x80) { 

941 
SDL_memset(dst, pixels8[datab >> 7], dstbpp); 

942 
} 

943 
} 

944 
maskb <<= 1; 

945 
datab <<= 1; 

946 
dst += dstbpp; 

947 
} 

948 
dst += dstskip; 

949 
} 

950 
} else { 

951 
for (h = area>h; h; h) { 

952 
for (x = 0; x < SDL_cursor>area.w; ++x) { 

953 
if ((x % 8) == 0) { 

954 
maskb = *mask++; 

955 
datab = *data++; 

956 
} 

957 
if ((x >= minx) && (x < maxx)) { 

958 
if (maskb & 0x80) { 

959 
SDL_memset(dst, pixels[datab >> 7], dstbpp); 

960 
} 

961 
} 

962 
maskb <<= 1; 

963 
datab <<= 1; 

964 
dst += dstbpp; 

965 
} 

966 
dst += dstskip; 

967 
} 

968 
} 

969 
} 

970 

971 
/* This handles the ugly work of converting the saved cursor background from 

972 
the pixel format of the shadow surface to that of the video surface. 

973 
This is only necessary when blitting from a shadow surface of a different 

974 
pixel format than the video surface, and using a software rendered cursor. 

975 
*/ 

976 
static void 

977 
SDL_ConvertCursorSave(SDL_Surface * screen, int w, int h) 

978 
{ 

979 
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 

980 
SDL_BlitInfo info; 

981 
SDL_loblit RunBlit; 

982 

983 
/* Make sure we can steal the blit mapping */ 

984 
if (screen>map>dst != SDL_VideoSurface) { 

985 
return; 

986 
} 

987 

988 
/* Set up the blit information */ 

989 
info.s_pixels = SDL_cursor>save[1]; 

990 
info.s_width = w; 

991 
info.s_height = h; 

992 
info.s_skip = 0; 

993 
info.d_pixels = SDL_cursor>save[0]; 

994 
info.d_width = w; 

995 
info.d_height = h; 

996 
info.d_skip = 0; 

997 
info.aux_data = screen>map>sw_data>aux_data; 

998 
info.src = screen>format; 

999 
info.table = screen>map>table; 

1000 
info.dst = SDL_VideoSurface>format; 

1001 
RunBlit = screen>map>sw_data>blit; 

1002 

1003 
/* Run the actual software blit */ 

1004 
RunBlit(&info); 

1005 
} 

1006 

1007 
void 

1008 
SDL_DrawCursorNoLock(SDL_Surface * screen) 

1009 
{ 

1010 
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 

1011 
SDL_Rect area; 

1012 

1013 
/* Get the mouse rectangle, clipped to the screen */ 

1014 
SDL_MouseRect(&area); 

1015 
if ((area.w == 0)  (area.h == 0)) { 

1016 
return; 

1017 
} 

1018 

1019 
/* Copy mouse background */ 

1020 
{ 

1021 
int w, h, screenbpp; 

1022 
Uint8 *src, *dst; 

1023 

1024 
/* Set up the copy pointers */ 

1025 
screenbpp = screen>format>BytesPerPixel; 

1026 
if ((screen == SDL_VideoSurface)  

1027 
FORMAT_EQUAL(screen>format, SDL_VideoSurface>format)) { 

1028 
dst = SDL_cursor>save[0]; 

1029 
} else { 

1030 
dst = SDL_cursor>save[1]; 

1031 
} 

1032 
src = (Uint8 *) screen>pixels + area.y * screen>pitch + 

1033 
area.x * screenbpp; 

1034 

1035 
/* Perform the copy */ 

1036 
w = area.w * screenbpp; 

1037 
h = area.h; 

1038 
while (h) { 

1039 
SDL_memcpy(dst, src, w); 

1040 
dst += w; 

1041 
src += screen>pitch; 

1042 
} 

1043 
} 

1044 

1045 
/* Draw the mouse cursor */ 

1046 
area.x = SDL_cursor>area.x; 

1047 
area.y = SDL_cursor>area.y; 

1048 
if ((area.x == 0) && (area.w == SDL_cursor>area.w)) { 

1049 
SDL_DrawCursorFast(screen, &area); 

1050 
} else { 

1051 
SDL_DrawCursorSlow(screen, &area); 

1052 
} 

1053 
} 

1054 

1055 
void 

1056 
SDL_DrawCursor(SDL_Surface * screen) 

1057 
{ 

1058 
/* Lock the screen if necessary */ 

1059 
if (screen == NULL) { 

1060 
return; 

1061 
} 

1062 
if (SDL_MUSTLOCK(screen)) { 

1063 
if (SDL_LockSurface(screen) < 0) { 

1064 
return; 

1065 
} 

1066 
} 

1067 

1068 
SDL_DrawCursorNoLock(screen); 

1069 

1070 
/* Unlock the screen and update if necessary */ 

1071 
if (SDL_MUSTLOCK(screen)) { 

1072 
SDL_UnlockSurface(screen); 

1073 
} 

1074 
if ((screen>flags & SDL_SCREEN_SURFACE) && 

1075 
!(screen>flags & SDL_HWSURFACE)) { 

1076 
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 

1077 
SDL_Window *window; 

1078 
SDL_Rect area; 

1079 

1080 
window = SDL_GetWindowFromSurface(screen); 

1081 
if (!window) { 

1082 
return; 

1083 
} 

1084 

1085 
SDL_MouseRect(&area); 

1086 

1087 
if (_this>UpdateWindowSurface) { 

1088 
_this>UpdateWindowSurface(_this, window, 1, &area); 

1089 
} 

1090 
} 

1091 
} 

1092 

1093 
void 

1094 
SDL_EraseCursorNoLock(SDL_Surface * screen) 

1095 
{ 

1096 
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 

1097 
SDL_Window *window; 

1098 
SDL_Rect area; 

1099 

1100 
/* Get the window associated with the surface */ 

1101 
window = SDL_GetWindowFromSurface(screen); 

1102 
if (!window  !window>surface) { 

1103 
return; 

1104 
} 

1105 

1106 
/* Get the mouse rectangle, clipped to the screen */ 

1107 
SDL_MouseRect(&area); 

1108 
if ((area.w == 0)  (area.h == 0)) { 

1109 
return; 

1110 
} 

1111 

1112 
/* Copy mouse background */ 

1113 
{ 

1114 
int w, h, screenbpp; 

1115 
Uint8 *src, *dst; 

1116 

1117 
/* Set up the copy pointers */ 

1118 
screenbpp = screen>format>BytesPerPixel; 

1119 
if ((screen>flags & SDL_SCREEN_SURFACE)  

1120 
FORMAT_EQUAL(screen>format, window>surface>format)) { 

1121 
src = SDL_cursor>save[0]; 

1122 
} else { 

1123 
src = SDL_cursor>save[1]; 

1124 
} 

1125 
dst = (Uint8 *) screen>pixels + area.y * screen>pitch + 

1126 
area.x * screenbpp; 

1127 

1128 
/* Perform the copy */ 

1129 
w = area.w * screenbpp; 

1130 
h = area.h; 

1131 
while (h) { 

1132 
SDL_memcpy(dst, src, w); 

1133 
src += w; 

1134 
dst += screen>pitch; 

1135 
} 

1136 

1137 
/* Perform pixel conversion on cursor background */ 

1138 
if (src > SDL_cursor>save[1]) { 
