Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
e9689c29
Commit
e9689c29
authored
Feb 10, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be explicit about what display you're querying. The default display is 0.
parent
e0f869b6
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
90 additions
and
166 deletions
+90
-166
SDL_video.h
include/SDL_video.h
+13
-38
SDL_compat.c
src/SDL_compat.c
+13
-19
SDL_sysvideo.h
src/video/SDL_sysvideo.h
+0
-8
SDL_video.c
src/video/SDL_video.c
+51
-83
SDL_x11opengl.c
src/video/x11/SDL_x11opengl.c
+1
-1
common.c
test/common.c
+3
-5
testgl2.c
test/testgl2.c
+1
-1
testime.c
test/testime.c
+5
-6
testvidinfo.c
test/testvidinfo.c
+3
-5
No files found.
include/SDL_video.h
View file @
e9689c29
...
@@ -236,7 +236,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
...
@@ -236,7 +236,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
* \brief Returns the number of available video displays.
* \brief Returns the number of available video displays.
*
*
* \sa SDL_GetDisplayBounds()
* \sa SDL_GetDisplayBounds()
* \sa SDL_SelectVideoDisplay()
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetNumVideoDisplays
(
void
);
extern
DECLSPEC
int
SDLCALL
SDL_GetNumVideoDisplays
(
void
);
...
@@ -248,34 +247,14 @@ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
...
@@ -248,34 +247,14 @@ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
*
*
* \sa SDL_GetNumVideoDisplays()
* \sa SDL_GetNumVideoDisplays()
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetDisplayBounds
(
int
i
ndex
,
SDL_Rect
*
rect
);
extern
DECLSPEC
int
SDLCALL
SDL_GetDisplayBounds
(
int
displayI
ndex
,
SDL_Rect
*
rect
);
/**
/**
* \brief Set the index of the currently selected display.
* \brief Returns the number of available display modes.
*
* \return 0 on success, or -1 if the index is out of range.
*
* \sa SDL_GetNumVideoDisplays()
* \sa SDL_GetCurrentVideoDisplay()
*/
extern
DECLSPEC
int
SDLCALL
SDL_SelectVideoDisplay
(
int
index
);
/**
* \brief Get the index of the currently selected display.
*
* \return The index of the currently selected display.
*
* \sa SDL_GetNumVideoDisplays()
* \sa SDL_SelectVideoDisplay()
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetCurrentVideoDisplay
(
void
);
/**
* \brief Returns the number of available display modes for the current display.
*
*
* \sa SDL_GetDisplayMode()
* \sa SDL_GetDisplayMode()
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetNumDisplayModes
(
void
);
extern
DECLSPEC
int
SDLCALL
SDL_GetNumDisplayModes
(
int
displayIndex
);
/**
/**
* \brief Fill in information about a specific display mode.
* \brief Fill in information about a specific display mode.
...
@@ -288,19 +267,18 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
...
@@ -288,19 +267,18 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
*
*
* \sa SDL_GetNumDisplayModes()
* \sa SDL_GetNumDisplayModes()
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetDisplayMode
(
int
i
ndex
,
extern
DECLSPEC
int
SDLCALL
SDL_GetDisplayMode
(
int
displayIndex
,
int
modeI
ndex
,
SDL_DisplayMode
*
mode
);
SDL_DisplayMode
*
mode
);
/**
/**
* \brief Fill in information about the desktop display mode for the current
* \brief Fill in information about the desktop display mode.
* display.
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetDesktopDisplayMode
(
SDL_DisplayMode
*
mode
);
extern
DECLSPEC
int
SDLCALL
SDL_GetDesktopDisplayMode
(
int
displayIndex
,
SDL_DisplayMode
*
mode
);
/**
/**
* \brief Fill in information about the current display mode.
* \brief Fill in information about the current display mode.
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetCurrentDisplayMode
(
SDL_DisplayMode
*
mode
);
extern
DECLSPEC
int
SDLCALL
SDL_GetCurrentDisplayMode
(
int
displayIndex
,
SDL_DisplayMode
*
mode
);
/**
/**
...
@@ -323,16 +301,13 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode);
...
@@ -323,16 +301,13 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode);
* \sa SDL_GetNumDisplayModes()
* \sa SDL_GetNumDisplayModes()
* \sa SDL_GetDisplayMode()
* \sa SDL_GetDisplayMode()
*/
*/
extern
DECLSPEC
SDL_DisplayMode
*
SDLCALL
SDL_GetClosestDisplayMode
(
const
extern
DECLSPEC
SDL_DisplayMode
*
SDLCALL
SDL_GetClosestDisplayMode
(
int
displayIndex
,
const
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
);
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
);
/**
/**
* \brief Set the display mode used when a fullscreen window is visible
* \brief Set the display mode used when a fullscreen window is visible.
* on the currently selected display. By default the window's
*
* dimensions and the desktop format and refresh rate are used.
* By default the window's dimensions and the desktop format and refresh rate
* are used.
*
*
* \param mode The mode to use, or NULL for the default mode.
* \param mode The mode to use, or NULL for the default mode.
*
*
...
@@ -347,7 +322,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
...
@@ -347,7 +322,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
/**
/**
* \brief Fill in information about the display mode used when a fullscreen
* \brief Fill in information about the display mode used when a fullscreen
* window is visible
on the currently selected display
.
* window is visible.
*
*
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_SetWindowFullscreen()
* \sa SDL_SetWindowFullscreen()
...
...
src/SDL_compat.c
View file @
e9689c29
...
@@ -71,15 +71,17 @@ SDL_VideoDriverName(char *namebuf, int maxlen)
...
@@ -71,15 +71,17 @@ SDL_VideoDriverName(char *namebuf, int maxlen)
return
NULL
;
return
NULL
;
}
}
static
void
static
int
Selec
tVideoDisplay
()
Ge
tVideoDisplay
()
{
{
const
char
*
variable
=
SDL_getenv
(
"SDL_VIDEO_FULLSCREEN_DISPLAY"
);
const
char
*
variable
=
SDL_getenv
(
"SDL_VIDEO_FULLSCREEN_DISPLAY"
);
if
(
!
variable
)
{
if
(
!
variable
)
{
variable
=
SDL_getenv
(
"SDL_VIDEO_FULLSCREEN_HEAD"
);
variable
=
SDL_getenv
(
"SDL_VIDEO_FULLSCREEN_HEAD"
);
}
}
if
(
variable
)
{
if
(
variable
)
{
SDL_SelectVideoDisplay
(
SDL_atoi
(
variable
));
SDL_atoi
(
variable
);
}
else
{
return
0
;
}
}
}
}
...
@@ -89,10 +91,8 @@ SDL_GetVideoInfo(void)
...
@@ -89,10 +91,8 @@ SDL_GetVideoInfo(void)
static
SDL_VideoInfo
info
;
static
SDL_VideoInfo
info
;
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
SelectVideoDisplay
();
/* Memory leak, compatibility code, who cares? */
/* Memory leak, compatibility code, who cares? */
if
(
!
info
.
vfmt
&&
SDL_GetDesktopDisplayMode
(
&
mode
)
==
0
)
{
if
(
!
info
.
vfmt
&&
SDL_GetDesktopDisplayMode
(
GetVideoDisplay
(),
&
mode
)
==
0
)
{
int
bpp
;
int
bpp
;
Uint32
Rmask
,
Gmask
,
Bmask
,
Amask
;
Uint32
Rmask
,
Gmask
,
Bmask
,
Amask
;
...
@@ -114,17 +114,15 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
...
@@ -114,17 +114,15 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
return
0
;
return
0
;
}
}
SelectVideoDisplay
();
if
(
!
(
flags
&
SDL_FULLSCREEN
))
{
if
(
!
(
flags
&
SDL_FULLSCREEN
))
{
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
SDL_GetDesktopDisplayMode
(
&
mode
);
SDL_GetDesktopDisplayMode
(
GetVideoDisplay
(),
&
mode
);
return
SDL_BITSPERPIXEL
(
mode
.
format
);
return
SDL_BITSPERPIXEL
(
mode
.
format
);
}
}
for
(
i
=
0
;
i
<
SDL_GetNumDisplayModes
();
++
i
)
{
for
(
i
=
0
;
i
<
SDL_GetNumDisplayModes
(
GetVideoDisplay
()
);
++
i
)
{
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
SDL_GetDisplayMode
(
i
,
&
mode
);
SDL_GetDisplayMode
(
GetVideoDisplay
(),
i
,
&
mode
);
if
(
!
mode
.
w
||
!
mode
.
h
||
(
width
==
mode
.
w
&&
height
==
mode
.
h
))
{
if
(
!
mode
.
w
||
!
mode
.
h
||
(
width
==
mode
.
w
&&
height
==
mode
.
h
))
{
if
(
!
mode
.
format
)
{
if
(
!
mode
.
format
)
{
return
bpp
;
return
bpp
;
...
@@ -147,8 +145,6 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
...
@@ -147,8 +145,6 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
return
NULL
;
return
NULL
;
}
}
SelectVideoDisplay
();
if
(
!
(
flags
&
SDL_FULLSCREEN
))
{
if
(
!
(
flags
&
SDL_FULLSCREEN
))
{
return
(
SDL_Rect
**
)
(
-
1
);
return
(
SDL_Rect
**
)
(
-
1
);
}
}
...
@@ -160,11 +156,11 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
...
@@ -160,11 +156,11 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
/* Memory leak, but this is a compatibility function, who cares? */
/* Memory leak, but this is a compatibility function, who cares? */
nmodes
=
0
;
nmodes
=
0
;
modes
=
NULL
;
modes
=
NULL
;
for
(
i
=
0
;
i
<
SDL_GetNumDisplayModes
();
++
i
)
{
for
(
i
=
0
;
i
<
SDL_GetNumDisplayModes
(
GetVideoDisplay
()
);
++
i
)
{
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
int
bpp
;
int
bpp
;
SDL_GetDisplayMode
(
i
,
&
mode
);
SDL_GetDisplayMode
(
GetVideoDisplay
(),
i
,
&
mode
);
if
(
!
mode
.
w
||
!
mode
.
h
)
{
if
(
!
mode
.
w
||
!
mode
.
h
)
{
return
(
SDL_Rect
**
)
(
-
1
);
return
(
SDL_Rect
**
)
(
-
1
);
}
}
...
@@ -342,7 +338,7 @@ GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
...
@@ -342,7 +338,7 @@ GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
}
}
if
(
center
)
{
if
(
center
)
{
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
SDL_GetDesktopDisplayMode
(
&
mode
);
SDL_GetDesktopDisplayMode
(
GetVideoDisplay
(),
&
mode
);
*
x
=
(
mode
.
w
-
w
)
/
2
;
*
x
=
(
mode
.
w
-
w
)
/
2
;
*
y
=
(
mode
.
h
-
h
)
/
2
;
*
y
=
(
mode
.
h
-
h
)
/
2
;
}
}
...
@@ -453,9 +449,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
...
@@ -453,9 +449,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
}
}
}
}
SelectVideoDisplay
();
SDL_GetDesktopDisplayMode
(
GetVideoDisplay
(),
&
desktop_mode
);
SDL_GetDesktopDisplayMode
(
&
desktop_mode
);
if
(
width
==
0
)
{
if
(
width
==
0
)
{
width
=
desktop_mode
.
w
;
width
=
desktop_mode
.
w
;
...
...
src/video/SDL_sysvideo.h
View file @
e9689c29
...
@@ -322,18 +322,10 @@ extern VideoBootStrap Android_bootstrap;
...
@@ -322,18 +322,10 @@ extern VideoBootStrap Android_bootstrap;
extern
VideoBootStrap
DUMMY_bootstrap
;
extern
VideoBootStrap
DUMMY_bootstrap
;
#endif
#endif
#define SDL_CurrentDisplay (&_this->displays[_this->current_display])
extern
SDL_VideoDevice
*
SDL_GetVideoDevice
(
void
);
extern
SDL_VideoDevice
*
SDL_GetVideoDevice
(
void
);
extern
int
SDL_AddBasicVideoDisplay
(
const
SDL_DisplayMode
*
desktop_mode
);
extern
int
SDL_AddBasicVideoDisplay
(
const
SDL_DisplayMode
*
desktop_mode
);
extern
int
SDL_AddVideoDisplay
(
const
SDL_VideoDisplay
*
display
);
extern
int
SDL_AddVideoDisplay
(
const
SDL_VideoDisplay
*
display
);
extern
SDL_bool
SDL_AddDisplayMode
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
);
extern
SDL_bool
SDL_AddDisplayMode
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
);
extern
int
SDL_GetNumDisplayModesForDisplay
(
SDL_VideoDisplay
*
display
);
extern
int
SDL_GetDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
int
index
,
SDL_DisplayMode
*
mode
);
extern
int
SDL_GetDesktopDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
extern
int
SDL_GetCurrentDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
extern
SDL_DisplayMode
*
SDL_GetClosestDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
);
extern
int
SDL_SetDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
);
extern
int
SDL_RecreateWindow
(
SDL_Window
*
window
,
Uint32
flags
);
extern
int
SDL_RecreateWindow
(
SDL_Window
*
window
,
Uint32
flags
);
...
...
src/video/SDL_video.c
View file @
e9689c29
...
@@ -96,6 +96,17 @@ static SDL_VideoDevice *_this = NULL;
...
@@ -96,6 +96,17 @@ static SDL_VideoDevice *_this = NULL;
return retval; \
return retval; \
}
}
#define CHECK_DISPLAY_INDEX(displayIndex, retval) \
if (!_this) { \
SDL_UninitializedVideo(); \
return retval; \
} \
if (displayIndex < 0 || displayIndex >= _this->num_displays) { \
SDL_SetError("displayIndex must be in the range 0 - %d", \
_this->num_displays - 1); \
return retval; \
}
/* Various local functions */
/* Various local functions */
static
void
SDL_UpdateWindowGrab
(
SDL_Window
*
window
);
static
void
SDL_UpdateWindowGrab
(
SDL_Window
*
window
);
...
@@ -581,19 +592,12 @@ SDL_GetNumVideoDisplays(void)
...
@@ -581,19 +592,12 @@ SDL_GetNumVideoDisplays(void)
}
}
int
int
SDL_GetDisplayBounds
(
int
i
ndex
,
SDL_Rect
*
rect
)
SDL_GetDisplayBounds
(
int
displayI
ndex
,
SDL_Rect
*
rect
)
{
{
if
(
!
_this
)
{
CHECK_DISPLAY_INDEX
(
displayIndex
,
-
1
);
SDL_UninitializedVideo
();
return
-
1
;
}
if
(
index
<
0
||
index
>=
_this
->
num_displays
)
{
SDL_SetError
(
"index must be in the range 0 - %d"
,
_this
->
num_displays
-
1
);
return
-
1
;
}
if
(
rect
)
{
if
(
rect
)
{
SDL_VideoDisplay
*
display
=
&
_this
->
displays
[
i
ndex
];
SDL_VideoDisplay
*
display
=
&
_this
->
displays
[
displayI
ndex
];
if
(
_this
->
GetDisplayBounds
)
{
if
(
_this
->
GetDisplayBounds
)
{
if
(
_this
->
GetDisplayBounds
(
_this
,
display
,
rect
)
<
0
)
{
if
(
_this
->
GetDisplayBounds
(
_this
,
display
,
rect
)
<
0
)
{
...
@@ -601,11 +605,11 @@ SDL_GetDisplayBounds(int index, SDL_Rect * rect)
...
@@ -601,11 +605,11 @@ SDL_GetDisplayBounds(int index, SDL_Rect * rect)
}
}
}
else
{
}
else
{
/* Assume that the displays are left to right */
/* Assume that the displays are left to right */
if
(
i
ndex
==
0
)
{
if
(
displayI
ndex
==
0
)
{
rect
->
x
=
0
;
rect
->
x
=
0
;
rect
->
y
=
0
;
rect
->
y
=
0
;
}
else
{
}
else
{
SDL_GetDisplayBounds
(
i
ndex
-
1
,
rect
);
SDL_GetDisplayBounds
(
displayI
ndex
-
1
,
rect
);
rect
->
x
+=
rect
->
w
;
rect
->
x
+=
rect
->
w
;
}
}
rect
->
w
=
display
->
desktop_mode
.
w
;
rect
->
w
=
display
->
desktop_mode
.
w
;
...
@@ -615,32 +619,6 @@ SDL_GetDisplayBounds(int index, SDL_Rect * rect)
...
@@ -615,32 +619,6 @@ SDL_GetDisplayBounds(int index, SDL_Rect * rect)
return
0
;
return
0
;
}
}
int
SDL_SelectVideoDisplay
(
int
index
)
{
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
(
-
1
);
}
if
(
index
<
0
||
index
>=
_this
->
num_displays
)
{
SDL_SetError
(
"index must be in the range 0 - %d"
,
_this
->
num_displays
-
1
);
return
-
1
;
}
_this
->
current_display
=
index
;
return
0
;
}
int
SDL_GetCurrentVideoDisplay
(
void
)
{
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
(
-
1
);
}
return
_this
->
current_display
;
}
SDL_bool
SDL_bool
SDL_AddDisplayMode
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
)
SDL_AddDisplayMode
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
)
{
{
...
@@ -677,7 +655,7 @@ SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
...
@@ -677,7 +655,7 @@ SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
return
SDL_TRUE
;
return
SDL_TRUE
;
}
}
int
static
int
SDL_GetNumDisplayModesForDisplay
(
SDL_VideoDisplay
*
display
)
SDL_GetNumDisplayModesForDisplay
(
SDL_VideoDisplay
*
display
)
{
{
if
(
!
display
->
num_display_modes
&&
_this
->
GetDisplayModes
)
{
if
(
!
display
->
num_display_modes
&&
_this
->
GetDisplayModes
)
{
...
@@ -689,17 +667,21 @@ SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
...
@@ -689,17 +667,21 @@ SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
}
}
int
int
SDL_GetNumDisplayModes
()
SDL_GetNumDisplayModes
(
int
displayIndex
)
{
{
if
(
_this
)
{
CHECK_DISPLAY_INDEX
(
displayIndex
,
-
1
);
return
SDL_GetNumDisplayModesForDisplay
(
SDL_CurrentDisplay
);
}
return
SDL_GetNumDisplayModesForDisplay
(
&
_this
->
displays
[
displayIndex
]);
return
0
;
}
}
int
int
SDL_GetDisplayMode
ForDisplay
(
SDL_VideoDisplay
*
display
,
int
index
,
SDL_DisplayMode
*
mode
)
SDL_GetDisplayMode
(
int
displayIndex
,
int
index
,
SDL_DisplayMode
*
mode
)
{
{
SDL_VideoDisplay
*
display
;
CHECK_DISPLAY_INDEX
(
displayIndex
,
-
1
);
display
=
&
_this
->
displays
[
displayIndex
];
if
(
index
<
0
||
index
>=
SDL_GetNumDisplayModesForDisplay
(
display
))
{
if
(
index
<
0
||
index
>=
SDL_GetNumDisplayModesForDisplay
(
display
))
{
SDL_SetError
(
"index must be in the range of 0 - %d"
,
SDL_SetError
(
"index must be in the range of 0 - %d"
,
SDL_GetNumDisplayModesForDisplay
(
display
)
-
1
);
SDL_GetNumDisplayModesForDisplay
(
display
)
-
1
);
...
@@ -712,14 +694,13 @@ SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayM
...
@@ -712,14 +694,13 @@ SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayM
}
}
int
int
SDL_GetD
isplayMode
(
int
i
ndex
,
SDL_DisplayMode
*
mode
)
SDL_GetD
esktopDisplayMode
(
int
displayI
ndex
,
SDL_DisplayMode
*
mode
)
{
{
return
SDL_GetDisplayModeForDisplay
(
SDL_CurrentDisplay
,
index
,
mode
);
SDL_VideoDisplay
*
display
;
}
int
CHECK_DISPLAY_INDEX
(
displayIndex
,
-
1
);
SDL_GetDesktopDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
)
{
display
=
&
_this
->
displays
[
displayIndex
];
if
(
mode
)
{
if
(
mode
)
{
*
mode
=
display
->
desktop_mode
;
*
mode
=
display
->
desktop_mode
;
}
}
...
@@ -727,35 +708,20 @@ SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode
...
@@ -727,35 +708,20 @@ SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode
}
}
int
int
SDL_Get
DesktopDisplayMode
(
SDL_DisplayMode
*
mode
)
SDL_Get
CurrentDisplayMode
(
int
displayIndex
,
SDL_DisplayMode
*
mode
)
{
{
if
(
!
_this
)
{
SDL_VideoDisplay
*
display
;
SDL_UninitializedVideo
();
return
-
1
;
}
return
SDL_GetDesktopDisplayModeForDisplay
(
SDL_CurrentDisplay
,
mode
);
}
int
CHECK_DISPLAY_INDEX
(
displayIndex
,
-
1
);
SDL_GetCurrentDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
)
{
display
=
&
_this
->
displays
[
displayIndex
];
if
(
mode
)
{
if
(
mode
)
{
*
mode
=
display
->
current_mode
;
*
mode
=
display
->
current_mode
;
}
}
return
0
;
return
0
;
}
}
int
static
SDL_DisplayMode
*
SDL_GetCurrentDisplayMode
(
SDL_DisplayMode
*
mode
)
{
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
-
1
;
}
return
SDL_GetCurrentDisplayModeForDisplay
(
SDL_CurrentDisplay
,
mode
);
}
SDL_DisplayMode
*
SDL_GetClosestDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_GetClosestDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
,
const
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
)
SDL_DisplayMode
*
closest
)
...
@@ -863,14 +829,16 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
...
@@ -863,14 +829,16 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
}
}
SDL_DisplayMode
*
SDL_DisplayMode
*
SDL_GetClosestDisplayMode
(
const
SDL_DisplayMode
*
mode
,
SDL_GetClosestDisplayMode
(
int
displayIndex
,
const
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
)
SDL_DisplayMode
*
closest
)
{
{
if
(
!
_this
)
{
SDL_VideoDisplay
*
display
;
SDL_UninitializedVideo
();
return
NULL
;
CHECK_DISPLAY_INDEX
(
displayIndex
,
NULL
);
}
return
SDL_GetClosestDisplayModeForDisplay
(
SDL_CurrentDisplay
,
mode
,
closest
);
display
=
&
_this
->
displays
[
displayIndex
];
return
SDL_GetClosestDisplayModeForDisplay
(
display
,
mode
,
closest
);
}
}
int
int
...
@@ -907,7 +875,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
...
@@ -907,7 +875,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
}
}
/* See if there's anything left to do */
/* See if there's anything left to do */
SDL_GetCurrentDisplayModeForDisplay
(
display
,
&
current_mode
)
;
current_mode
=
display
->
current_mode
;
if
(
SDL_memcmp
(
&
display_mode
,
&
current_mode
,
sizeof
(
display_mode
))
==
0
)
{
if
(
SDL_memcmp
(
&
display_mode
,
&
current_mode
,
sizeof
(
display_mode
))
==
0
)
{
return
0
;
return
0
;
}
}
...
@@ -1054,7 +1022,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
...
@@ -1054,7 +1022,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
}
SDL_GL_LoadLibrary
(
NULL
);
SDL_GL_LoadLibrary
(
NULL
);
}
}
display
=
SDL_CurrentDisplay
;
display
=
&
_this
->
displays
[
0
];
/* FIXME */
window
=
(
SDL_Window
*
)
SDL_calloc
(
1
,
sizeof
(
*
window
));
window
=
(
SDL_Window
*
)
SDL_calloc
(
1
,
sizeof
(
*
window
));
window
->
magic
=
&
_this
->
window_magic
;
window
->
magic
=
&
_this
->
window_magic
;
window
->
id
=
_this
->
next_object_id
++
;
window
->
id
=
_this
->
next_object_id
++
;
...
@@ -1102,7 +1070,7 @@ SDL_CreateWindowFrom(const void *data)
...
@@ -1102,7 +1070,7 @@ SDL_CreateWindowFrom(const void *data)
SDL_UninitializedVideo
();
SDL_UninitializedVideo
();
return
NULL
;
return
NULL
;
}
}
display
=
SDL_CurrentDisplay
;
display
=
&
_this
->
displays
[
0
];
/* FIXME */
window
=
(
SDL_Window
*
)
SDL_calloc
(
1
,
sizeof
(
*
window
));
window
=
(
SDL_Window
*
)
SDL_calloc
(
1
,
sizeof
(
*
window
));
window
->
magic
=
&
_this
->
window_magic
;
window
->
magic
=
&
_this
->
window_magic
;
window
->
id
=
_this
->
next_object_id
++
;
window
->
id
=
_this
->
next_object_id
++
;
...
@@ -1676,7 +1644,7 @@ SDL_GetFocusWindow(void)
...
@@ -1676,7 +1644,7 @@ SDL_GetFocusWindow(void)
if
(
!
_this
)
{
if
(
!
_this
)
{
return
NULL
;
return
NULL
;
}
}
display
=
SDL_CurrentDisplay
;
display
=
&
_this
->
displays
[
0
];
/* FIXME */
for
(
window
=
display
->
windows
;
window
;
window
=
window
->
next
)
{
for
(
window
=
display
->
windows
;
window
;
window
=
window
->
next
)
{
if
(
window
->
flags
&
SDL_WINDOW_INPUT_FOCUS
)
{
if
(
window
->
flags
&
SDL_WINDOW_INPUT_FOCUS
)
{
return
window
;
return
window
;
...
...
src/video/x11/SDL_x11opengl.c
View file @
e9689c29
...
@@ -220,7 +220,7 @@ static void
...
@@ -220,7 +220,7 @@ static void
X11_GL_InitExtensions
(
_THIS
)
X11_GL_InitExtensions
(
_THIS
)
{
{
Display
*
display
=
((
SDL_VideoData
*
)
_this
->
driverdata
)
->
display
;
Display
*
display
=
((
SDL_VideoData
*
)
_this
->
driverdata
)
->
display
;
int
screen
=
((
SDL_DisplayData
*
)
SDL_CurrentDisplay
->
driverdata
)
->
screen
;
int
screen
=
DefaultScreen
(
display
)
;
XVisualInfo
*
vinfo
;
XVisualInfo
*
vinfo
;
XSetWindowAttributes
xattr
;
XSetWindowAttributes
xattr
;
Window
w
;
Window
w
;
...
...
test/common.c
View file @
e9689c29
...
@@ -594,9 +594,8 @@ CommonInit(CommonState * state)
...
@@ -594,9 +594,8 @@ CommonInit(CommonState * state)
fprintf
(
stderr
,
"Number of displays: %d
\n
"
,
n
);
fprintf
(
stderr
,
"Number of displays: %d
\n
"
,
n
);
for
(
i
=
0
;
i
<
n
;
++
i
)
{
for
(
i
=
0
;
i
<
n
;
++
i
)
{
fprintf
(
stderr
,
"Display %d:
\n
"
,
i
);
fprintf
(
stderr
,
"Display %d:
\n
"
,
i
);
SDL_SelectVideoDisplay
(
i
);
SDL_GetDesktopDisplayMode
(
&
mode
);
SDL_GetDesktopDisplayMode
(
i
,
&
mode
);
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
&
Gmask
,
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
&
Gmask
,
&
Bmask
,
&
Amask
);
&
Bmask
,
&
Amask
);
fprintf
(
stderr
,
fprintf
(
stderr
,
...
@@ -612,13 +611,13 @@ CommonInit(CommonState * state)
...
@@ -612,13 +611,13 @@ CommonInit(CommonState * state)
}
}
/* Print available fullscreen video modes */
/* Print available fullscreen video modes */
m
=
SDL_GetNumDisplayModes
();
m
=
SDL_GetNumDisplayModes
(
i
);
if
(
m
==
0
)
{
if
(
m
==
0
)
{
fprintf
(
stderr
,
"No available fullscreen video modes
\n
"
);
fprintf
(
stderr
,
"No available fullscreen video modes
\n
"
);
}
else
{
}
else
{
fprintf
(
stderr
,
" Fullscreen video modes:
\n
"
);
fprintf
(
stderr
,
" Fullscreen video modes:
\n
"
);
for
(
j
=
0
;
j
<
m
;
++
j
)
{
for
(
j
=
0
;
j
<
m
;
++
j
)
{
SDL_GetDisplayMode
(
j
,
&
mode
);
SDL_GetDisplayMode
(
i
,
j
,
&
mode
);
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
&
Gmask
,
&
Bmask
,
&
Amask
);
&
Gmask
,
&
Bmask
,
&
Amask
);
fprintf
(
stderr
,
fprintf
(
stderr
,
...
@@ -642,7 +641,6 @@ CommonInit(CommonState * state)
...
@@ -642,7 +641,6 @@ CommonInit(CommonState * state)
}
}
}
}
SDL_SelectVideoDisplay
(
state
->
display
);
if
(
state
->
verbose
&
VERBOSE_RENDER
)
{
if
(
state
->
verbose
&
VERBOSE_RENDER
)
{
SDL_RendererInfo
info
;
SDL_RendererInfo
info
;
...
...
test/testgl2.c
View file @
e9689c29
...
@@ -234,7 +234,7 @@ main(int argc, char *argv[])
...
@@ -234,7 +234,7 @@ main(int argc, char *argv[])
SDL_GL_SetSwapInterval
(
0
);
SDL_GL_SetSwapInterval
(
0
);
}
}
SDL_GetCurrentDisplayMode
(
&
mode
);
SDL_GetCurrentDisplayMode
(
0
,
&
mode
);
printf
(
"Screen BPP: %d
\n
"
,
SDL_BITSPERPIXEL
(
mode
.
format
));
printf
(
"Screen BPP: %d
\n
"
,
SDL_BITSPERPIXEL
(
mode
.
format
));
printf
(
"
\n
"
);
printf
(
"
\n
"
);
printf
(
"Vendor : %s
\n
"
,
glGetString
(
GL_VENDOR
));
printf
(
"Vendor : %s
\n
"
,
glGetString
(
GL_VENDOR
));
...
...
test/testime.c
View file @
e9689c29
...
@@ -122,12 +122,9 @@ void InitVideo(int argc, char *argv[])
...
@@ -122,12 +122,9 @@ void InitVideo(int argc, char *argv[])
if
(
fullscreen
)
if
(
fullscreen
)
{
{
SDL_DisplayMode
mode
;
/* Use the desktop mode */
SDL_GetDesktopDisplayMode
(
&
mode
);
width
=
0
;
height
=
0
;
width
=
mode
.
w
;
height
=
mode
.
h
;
fprintf
(
stderr
,
"%dx%d
\n
"
,
width
,
height
);
flags
|=
SDL_FULLSCREEN
;
flags
|=
SDL_FULLSCREEN
;
}
}
...
@@ -375,3 +372,5 @@ int main(int argc, char *argv[])
...
@@ -375,3 +372,5 @@ int main(int argc, char *argv[])
CleanupVideo
();
CleanupVideo
();
return
0
;
return
0
;
}
}
/* vi: set ts=4 sw=4 expandtab: */
test/testvidinfo.c
View file @
e9689c29
...
@@ -455,9 +455,7 @@ main(int argc, char *argv[])
...
@@ -455,9 +455,7 @@ main(int argc, char *argv[])
printf
(
"Display %d: %dx%d at %d,%d
\n
"
,
d
,
printf
(
"Display %d: %dx%d at %d,%d
\n
"
,
d
,
bounds
.
w
,
bounds
.
h
,
bounds
.
x
,
bounds
.
y
);
bounds
.
w
,
bounds
.
h
,
bounds
.
x
,
bounds
.
y
);
SDL_SelectVideoDisplay
(
d
);
SDL_GetDesktopDisplayMode
(
d
,
&
mode
);
SDL_GetDesktopDisplayMode
(
&
mode
);
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
&
Gmask
,
&
Bmask
,
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
&
Gmask
,
&
Bmask
,
&
Amask
);
&
Amask
);
printf
(
" Current mode: %dx%d@%dHz, %d bits-per-pixel
\n
"
,
mode
.
w
,
printf
(
" Current mode: %dx%d@%dHz, %d bits-per-pixel
\n
"
,
mode
.
w
,
...
@@ -471,13 +469,13 @@ main(int argc, char *argv[])
...
@@ -471,13 +469,13 @@ main(int argc, char *argv[])
}
}
/* Print available fullscreen video modes */
/* Print available fullscreen video modes */
nmodes
=
SDL_GetNumDisplayModes
();
nmodes
=
SDL_GetNumDisplayModes
(
d
);
if
(
nmodes
==
0
)
{
if
(
nmodes
==
0
)
{
printf
(
"No available fullscreen video modes
\n
"
);
printf
(
"No available fullscreen video modes
\n
"
);
}
else
{
}
else
{
printf
(
" Fullscreen video modes:
\n
"
);
printf
(
" Fullscreen video modes:
\n
"
);
for
(
i
=
0
;
i
<
nmodes
;
++
i
)
{
for
(
i
=
0
;
i
<
nmodes
;
++
i
)
{
SDL_GetDisplayMode
(
i
,
&
mode
);
SDL_GetDisplayMode
(
d
,
i
,
&
mode
);
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
SDL_PixelFormatEnumToMasks
(
mode
.
format
,
&
bpp
,
&
Rmask
,
&
Gmask
,
&
Bmask
,
&
Amask
);
&
Gmask
,
&
Bmask
,
&
Amask
);
printf
(
" Mode %d: %dx%d@%dHz, %d bits-per-pixel
\n
"
,
i
,
printf
(
" Mode %d: %dx%d@%dHz, %d bits-per-pixel
\n
"
,
i
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment