mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Updates SDL to 2.0.5
This commit is contained in:
parent
00a4a21e3f
commit
1e671bfc7a
274 changed files with 11502 additions and 4656 deletions
|
|
@ -55,6 +55,10 @@
|
|||
#undef CreateWindow
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
/* Available video drivers */
|
||||
static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
|
@ -177,7 +181,7 @@ ShouldUseTextureFramebuffer()
|
|||
/* See if the user or application wants a specific behavior */
|
||||
hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint) {
|
||||
if (*hint == '0') {
|
||||
if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
|
|
@ -254,6 +258,8 @@ SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * f
|
|||
|
||||
/* Check to see if there's a specific driver requested */
|
||||
if (hint && *hint != '0' && *hint != '1' &&
|
||||
SDL_strcasecmp(hint, "true") != 0 &&
|
||||
SDL_strcasecmp(hint, "false") != 0 &&
|
||||
SDL_strcasecmp(hint, "software") != 0) {
|
||||
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
|
||||
SDL_RendererInfo info;
|
||||
|
|
@ -443,10 +449,8 @@ int
|
|||
SDL_VideoInit(const char *driver_name)
|
||||
{
|
||||
SDL_VideoDevice *video;
|
||||
const char *hint;
|
||||
int index;
|
||||
int i;
|
||||
SDL_bool allow_screensaver;
|
||||
|
||||
/* Check to make sure we don't overwrite '_this' */
|
||||
if (_this != NULL) {
|
||||
|
|
@ -534,13 +538,7 @@ SDL_VideoInit(const char *driver_name)
|
|||
joystick, or passively watching a movie. Things that use SDL but
|
||||
function more like a normal desktop app should explicitly reenable the
|
||||
screensaver. */
|
||||
hint = SDL_GetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER);
|
||||
if (hint) {
|
||||
allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE;
|
||||
} else {
|
||||
allow_screensaver = SDL_FALSE;
|
||||
}
|
||||
if (!allow_screensaver) {
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, SDL_FALSE)) {
|
||||
SDL_DisableScreenSaver();
|
||||
}
|
||||
|
||||
|
|
@ -684,7 +682,26 @@ SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect)
|
|||
rect->w = display->current_mode.w;
|
||||
rect->h = display->current_mode.h;
|
||||
}
|
||||
return 0;
|
||||
return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
|
||||
}
|
||||
|
||||
int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect)
|
||||
{
|
||||
CHECK_DISPLAY_INDEX(displayIndex, -1);
|
||||
|
||||
if (rect) {
|
||||
SDL_VideoDisplay *display = &_this->displays[displayIndex];
|
||||
|
||||
if (_this->GetDisplayUsableBounds) {
|
||||
if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Oh well, just give the entire display bounds. */
|
||||
return SDL_GetDisplayBounds(displayIndex, rect);
|
||||
}
|
||||
return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -700,7 +717,9 @@ SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi)
|
|||
if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1285,16 +1304,11 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
|||
}
|
||||
|
||||
#define CREATE_FLAGS \
|
||||
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI)
|
||||
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP)
|
||||
|
||||
static void
|
||||
SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
window->windowed.x = window->x;
|
||||
window->windowed.y = window->y;
|
||||
window->windowed.w = window->w;
|
||||
window->windowed.h = window->h;
|
||||
|
||||
if (flags & SDL_WINDOW_MAXIMIZED) {
|
||||
SDL_MaximizeWindow(window);
|
||||
}
|
||||
|
|
@ -1316,7 +1330,6 @@ SDL_Window *
|
|||
SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
{
|
||||
SDL_Window *window;
|
||||
const char *hint;
|
||||
|
||||
if (!_this) {
|
||||
/* Initialize the video system if needed */
|
||||
|
|
@ -1325,6 +1338,11 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
}
|
||||
}
|
||||
|
||||
if ( (((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1 ) {
|
||||
SDL_SetError("Conflicting window flags specified");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Some platforms can't create zero-sized windows */
|
||||
if (w < 1) {
|
||||
w = 1;
|
||||
|
|
@ -1341,7 +1359,9 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
|
||||
/* Some platforms have OpenGL enabled by default */
|
||||
#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
if (SDL_strcmp(_this->name, "dummy") != 0) {
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
#endif
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
if (!_this->GL_CreateContext) {
|
||||
|
|
@ -1357,8 +1377,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
* SDL_WINDOW_ALLOW_HIGHDPI flag.
|
||||
*/
|
||||
if (flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED);
|
||||
if (hint && SDL_atoi(hint) > 0) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_FALSE)) {
|
||||
flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
}
|
||||
}
|
||||
|
|
@ -1389,8 +1408,28 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
window->y = bounds.y + (bounds.h - h) / 2;
|
||||
}
|
||||
}
|
||||
window->windowed.x = window->x;
|
||||
window->windowed.y = window->y;
|
||||
window->windowed.w = window->w;
|
||||
window->windowed.h = window->h;
|
||||
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
int displayIndex;
|
||||
SDL_Rect bounds;
|
||||
|
||||
displayIndex = SDL_GetIndexOfDisplay(display);
|
||||
SDL_GetDisplayBounds(displayIndex, &bounds);
|
||||
|
||||
window->x = bounds.x;
|
||||
window->y = bounds.y;
|
||||
window->w = bounds.w;
|
||||
window->h = bounds.h;
|
||||
}
|
||||
|
||||
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
|
||||
window->last_fullscreen_flags = window->flags;
|
||||
window->opacity = 1.0f;
|
||||
window->brightness = 1.0f;
|
||||
window->next = _this->windows;
|
||||
window->is_destroying = SDL_FALSE;
|
||||
|
|
@ -1451,6 +1490,7 @@ SDL_CreateWindowFrom(const void *data)
|
|||
window->flags = SDL_WINDOW_FOREIGN;
|
||||
window->last_fullscreen_flags = window->flags;
|
||||
window->is_destroying = SDL_FALSE;
|
||||
window->opacity = 1.0f;
|
||||
window->brightness = 1.0f;
|
||||
window->next = _this->windows;
|
||||
if (_this->windows) {
|
||||
|
|
@ -1795,6 +1835,24 @@ SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window,);
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
const int want = (resizable != SDL_FALSE); /* normalize the flag. */
|
||||
const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
|
||||
if ((want != have) && (_this->SetWindowResizable)) {
|
||||
if (want) {
|
||||
window->flags |= SDL_WINDOW_RESIZABLE;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_RESIZABLE;
|
||||
}
|
||||
_this->SetWindowResizable(_this, window, (SDL_bool) want);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||
{
|
||||
|
|
@ -1883,6 +1941,28 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, int *right)
|
||||
{
|
||||
int dummy = 0;
|
||||
|
||||
if (!top) { top = &dummy; }
|
||||
if (!left) { left = &dummy; }
|
||||
if (!right) { right = &dummy; }
|
||||
if (!bottom) { bottom = &dummy; }
|
||||
|
||||
/* Always initialize, so applications don't have to care */
|
||||
*top = *left = *bottom = *right = 0;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!_this->GetWindowBordersSize) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
return _this->GetWindowBordersSize(_this, window, top, left, bottom, right);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
||||
{
|
||||
|
|
@ -2144,6 +2224,68 @@ SDL_GetWindowBrightness(SDL_Window * window)
|
|||
return window->brightness;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetWindowOpacity(SDL_Window * window, float opacity)
|
||||
{
|
||||
int retval;
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!_this->SetWindowOpacity) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (opacity < 0.0f) {
|
||||
opacity = 0.0f;
|
||||
} else if (opacity > 1.0f) {
|
||||
opacity = 1.0f;
|
||||
}
|
||||
|
||||
retval = _this->SetWindowOpacity(_this, window, opacity);
|
||||
if (retval == 0) {
|
||||
window->opacity = opacity;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (out_opacity) {
|
||||
*out_opacity = window->opacity;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(modal_window, -1);
|
||||
CHECK_WINDOW_MAGIC(parent_window, -1);
|
||||
|
||||
if (!_this->SetWindowModalFor) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
return _this->SetWindowModalFor(_this, modal_window, parent_window);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetWindowInputFocus(SDL_Window * window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!_this->SetWindowInputFocus) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
return _this->SetWindowInputFocus(_this, window);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red,
|
||||
const Uint16 * green,
|
||||
|
|
@ -2359,8 +2501,6 @@ SDL_OnWindowFocusGained(SDL_Window * window)
|
|||
static SDL_bool
|
||||
ShouldMinimizeOnFocusLoss(SDL_Window * window)
|
||||
{
|
||||
const char *hint;
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
|
@ -2371,16 +2511,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
|
|||
}
|
||||
#endif
|
||||
|
||||
hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
|
||||
if (hint) {
|
||||
if (*hint == '0') {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -3596,6 +3727,16 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
int
|
||||
SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
/* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
|
||||
/* Web browsers don't (currently) have an API for a custom message box
|
||||
that can block, but for the most common case (SDL_ShowSimpleMessageBox),
|
||||
we can use the standard Javascript alert() function. */
|
||||
EM_ASM_({
|
||||
alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
|
||||
}, title, message);
|
||||
return 0;
|
||||
#else
|
||||
SDL_MessageBoxData data;
|
||||
SDL_MessageBoxButtonData button;
|
||||
|
||||
|
|
@ -3613,20 +3754,13 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S
|
|||
button.text = "OK";
|
||||
|
||||
return SDL_ShowMessageBox(&data, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_ShouldAllowTopmost(void)
|
||||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST);
|
||||
if (hint) {
|
||||
if (*hint == '0') {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_TRUE;
|
||||
return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue