Commit Graph

55 Commits

Author SHA1 Message Date
Alex Szpakowski
2e4248ed44 Address a compiler warning. 2017-08-15 18:29:47 -03:00
Sam Lantinga
aebe17d34f Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__
Martin Gerhardy

just for easier debugging issues in the own code...

SDL_CreateRenderer should maybe also use this macro

Ryan C. Gordon

I'll go one better: it should have an SDL_assert().
2017-08-14 16:34:54 -07:00
Sam Lantinga
059d9e4627 Fixed bug 2950 - wrong axes values are set on joystick initialization
Edward Rudd

Device: Logitech Rumble Gamepad F510 in Xinput mode.

Upon opening the joystick the values of the axes are queried via PollAllValues are not actually set on the device all the time.

This can easily be seen in the testjoystick or testgamecontroller test programs,as the testjoystick shows all axes in the center until one 'tickles' the triggers., and the testgamecontroller will show the triggers as 'on' until on 'tickles' the triggers.

Upon further research the culprit is the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint. In the default value events are ignored until there is an active window, Thus in cases where the joystick system is initialized and controllers opened before the initial window is created & focuses, the initial values will be incorrect.

Here is my current workaround in the game I'm working on porting..

SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_GameController* gamepad = SDL_GameControllerOpen(index);
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
2017-08-12 17:41:59 -07:00
Sam Lantinga
4a9c6f0a14 Fixed bug 3173 - SDL_GL_GetAttribute overwrites error code from SDL_GL_GetProcAddress
Yann Dirson

When SDL_GL_GetProcAddress returns in error, the cause of the error is overwritten
in GL_GL_GetAttribute, reporting to the user "Failed getting OpenGL glGetString entry point", whereas the original "OpenGL library not loaded" never makes it
to the user.

Pushed a fix to:
f94cb13708


Note that the "OpenGL library not loaded" error looks like no root cause either,
and I'm still puzzled by the code path used: I'm forcing opengles2 renderer on
the x11 video driver on a rpi2, as in https://bugzilla.libsdl.org/3169, and although I now know that I must force the use of the RPI video driver instead
of the x11 one, I suspect even more accurate info can be given to user.
2017-08-12 15:55:54 -07:00
Sam Lantinga
cc5ceb1165 Temporary hack to fix bug 3725 - Call made to glGetString before context creation
This breaks bugs 2570, 3145
2017-08-04 13:06:56 -07:00
Sam Lantinga
56363ebf61 Fixed bug 3690 - SDL2 KMS/DRM render context support
Manuel

The attached patch adds support for KMS/DRM context graphics.

It builds with no problem on X86_64 GNU/Linux systems, provided the needed libraries are present, and on ARM GNU/Linux systems that have KMS/DRM support and a GLES2 implementation.
Tested on Raspberry Pi: KMS/DRM is what the Raspberry Pi will use as default in the near future, once the propietary DispmanX API by Broadcom is overtaken by open graphics stack, it's possible to boot current Raspbian system in KMS mode by adding "dtoverlay=vc4-kms-v3d" to config.txt on Raspbian's boot partition.
X86 systems use KMS right away in every current GNU/Linux system.

Simple build instructions:

$./autogen.sh
$./configure --enable-video-kmsdrm
$make
2017-08-02 10:22:48 -07:00
Sam Lantinga
e10a98d2ad Fixed bug 3720 - SDL_GL_GetAttribute doesn't check for initialized video driver
Simon Hug

SDL_GL_GetAttribute doesn't check if a video driver has been initialized and will access the SDL_VideoDevice pointer, which is NULL at that point.

I think all of the attributes require an initialized driver, so a simple NULL check should fix it. Patch is attached.
2017-07-31 12:57:15 -07:00
Alex Szpakowski
01050d4ed1 iOS: Use modern replacements for deprecated functions, when available. 2017-07-15 17:41:58 -03:00
Ryan C. Gordon
22241ed0b0 Support for QNX 7.0 (thanks, Elad!).
Fixes Bugzilla #3686.
2017-07-01 17:50:47 -04:00
Sam Lantinga
ccf0566ca4 SDL - add SDL_WINDOW_VULKAN and make Android_CreateWindow only create an EGLSurface when SDL_WINDOW_VULKAN is not present. This makes it so the ANativeWindow* can be used with vkCreateAndroidSurfaceKHR, otherwise it will fail because having both an EGLSurface and VkSurfaceKHR attached to a window is not allowed according to the Vulkan spec:
"In particular, only one VkSurfaceKHR can exist at a time for a given window. Similarly, a native window cannot be used by both a VkSurfaceKHR and EGLSurface simultaneously"

CR: SamL
2017-05-16 06:30:39 -07:00
Philipp Wiesemann
ce01128adf Fixed warnings about shadowed global variable.
Found by buildbot.
2017-05-12 23:01:04 +02:00
Sam Lantinga
8b7ae35356 Fixed build error on Linux 2017-05-09 03:19:58 -07:00
Sam Lantinga
9ac3bb7011 Added support for mixing Qt and SDL on iOS
You should call SDL_SetMainReady(), and then customize the QIOSApplicationDelegate like this, in your application code:

/* Additional support for applications mixing Qt and SDL */
@interface QIOSApplicationDelegate : UIResponder <UIApplicationDelegate>
@end

extern "C"
{
void SDL_OnApplicationWillResignActive();
void SDL_OnApplicationDidEnterBackground();
void SDL_OnApplicationWillEnterForeground();
void SDL_OnApplicationDidBecomeActive();
}

@interface QIOSApplicationDelegate (SDL)

- (void)applicationWillResignActive:(UIApplication*)application;
- (void)applicationDidEnterBackground:(UIApplication*)application;
- (void)applicationWillEnterForeground:(UIApplication*)application;
- (void)applicationDidBecomeActive:(UIApplication*)application;

@end

@implementation QIOSApplicationDelegate (SDL)

- (void)applicationWillResignActive:(UIApplication*)application
{
    SDL_OnApplicationWillResignActive();
}

- (void)applicationDidEnterBackground:(UIApplication*)application
{
    SDL_OnApplicationDidEnterBackground();
}

- (void)applicationWillEnterForeground:(UIApplication*)application
{
    SDL_OnApplicationWillEnterForeground();
}

- (void)applicationDidBecomeActive:(UIApplication*)application
{
    SDL_OnApplicationDidBecomeActive();
}

@end // QIOSApplicationDelegate
2017-05-09 10:10:42 -07:00
Ryan C. Gordon
6aa17426a6 video: Don't compile isAtLeastGL3() if we don't have OpenGL support _at all_. 2017-03-03 16:38:45 -05:00
Brandon Schaefer
94a69443c7 mistake: Revert the files that I did not mean to commit 2017-03-01 15:05:54 -08:00
Brandon Schaefer
7bbb13ea59 * Some refactoring and bug fixes. Thanks Micha? Kuchta! 2017-03-01 14:50:59 -08:00
Sam Lantinga
da30992d47 Fixed bug 3577 - Can't set minimal size (message box appears instead) if maximal size wasn't declared (i.e. unlimited) 2017-02-02 00:41:58 -08:00
Sam Lantinga
0090a33805 Return an error if trying to set a window minimum size larger than the maximum size, or vice versa 2017-01-27 21:16:38 -08:00
Philipp Wiesemann
800a9e84f4 Fixed compiler warning about returning a value in a void function. 2017-01-21 22:00:56 +01:00
Sam Lantinga
a52d48c5ab Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11
Mark Callow

The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile:

- Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can
  say to use the OpenGL ES driver & EGL rather than the Open GL
  driver. (For bug #2570)
- Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum
  OpenGL ES version supported by the OpenGL driver (for bug #3145)
- Modifies the test that determines whether to use the OpenGL
  driver or the real OpenGL ES driver to take into account the
  hint, the requested and supported ES version and whether ES 1.X
  is being requested. (For bug #2570 & bug #3145)
- Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds
  the test to the VisualC projects.

With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
2017-01-10 08:54:33 -08:00
Ryan C. Gordon
13f2e54295 x11: make the X11 target work on macOS with Xquartz. 2017-01-07 19:55:29 -05:00
Ryan C. Gordon
9d04205263 x11: deal with xrandr display size in millimeters being zero.
Xquartz on macOS reports a zero size, which leads to a division by zero here.
2017-01-04 09:33:47 -05:00
Sam Lantinga
45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
7f2068daca Fixed bug 3541 - DisplayIndex out of bounds in SDL_SetWindowPosition
Intellectual Kitty

In SDL_video.c, on line #1756, in SDL_SetWindowPosition (from today's distribution, 12-31-2016, https://hg.libsdl.org/SDL/shortlog/bf19e0c84483):

        if (displayIndex > _this->num_displays) {

should be:

        if (displayIndex >= _this->num_displays) {
2016-12-31 10:30:07 -08:00
Sam Lantinga
8414c3d4ae Fixed ABI, don't change the return type of SDL_GL_SwapWindow() 2016-12-11 12:01:44 -08:00
Sam Lantinga
6211668e9f Fixed creating a renderer on the dummy driver on Mac OS X 2016-12-11 12:01:01 -08:00
Sam Lantinga
cb5a0b0f6a Fixed crash when creating a dummy window on Mac OS X 2016-12-11 11:45:33 -08:00
Sam Lantinga
524bf3c282 Fixed bug 3513 - SDL_GL_SwapWindow does not return error status
Return an error code from SDL_GL_SwapWindow(), like the other SDL APIs.
2016-12-09 01:47:43 -08:00
Ryan C. Gordon
fb5fd67ccb Fixed all known static analysis bugs, with checker-279 on macOS. 2016-11-24 21:41:09 -05:00
Sam Lantinga
57d01d7d67 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Sam Lantinga
62b9e1c797 Fixed bug 3061 - Selecting the dummy video driver on Mac OS X results in an error
Darren Kulp

The dummy video driver is not available on Mac OS X if SDL_VIDEO_OPENGL is set at library compilation time.

In src/video/SDL_video.c, there is a compile-time check in SDL_CreateWindow() for (SDL_VIDEO_OPENGL && __MACOSX__). When it succeeds, SDL_WINDOW_OPENGL is always requested. Since the dummy video driver does not supply an OpenGL implementation, the error "No OpenGL support in video driver" is supplied to the user, and SDL_CreateWindow() is exited early.
2016-10-07 18:09:09 -07:00
Ryan C. Gordon
4f4c4b629f Added SDL_SetWindowResizable(). (thanks, Ethan!) 2016-09-29 22:52:41 -04:00
Ryan C. Gordon
da1e3d6938 emscripten: special case to make SDL_ShowSimpleMessageBox() work.
Browsers don't have the functionality to fully support the generic
SDL_ShowMessageBox(), but this handles the likely most-common case.

Without this, you'd return immediately with a proper error result and no UI,
but probably no one checks that for SDL_ShowSimpleMessageBox. And if they
did: what would they do to handle this anyhow?

We'd need to lobby for an HTML spec of some sort that allows customizable
message boxes--that block!--to properly support SDL message boxes on
Emscripten, but this is probably Good Enough for now.
2016-09-06 13:13:03 -04:00
Philipp Wiesemann
bf7a76155e Fixed missing error message if SDL_GetDisplayDPI() is unsupported. 2016-05-10 21:14:36 +02:00
Sam Lantinga
67f9fd2bc4 Fixed creating fullscreen windows on Steam Link 2016-01-22 13:12:16 -08:00
Ryan C. Gordon
d4aedf9951 Added SDL_SetWindowModalFor().
This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2015-04-21 09:45:58 -04:00
Ryan C. Gordon
e497e46515 Added SDL_SetWindowInputFocus().
This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:28:56 -05:00
Ryan C. Gordon
3bdaf4c611 Added SDL_SetWindowOpacity() and SDL_GetWindowOpacity().
This is currently implemented for X11, Cocoa, Windows, and DirectFB.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:46:10 -05:00
Ryan C. Gordon
5696e88e6b Added SDL_GetWindowBordersSize().
This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:29:06 -05:00
Ryan C. Gordon
f2defe5e11 Added special window type flags.
Specifically: always on top, skip taskbar, tooltip, utility, and popup menu.

This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 01:30:40 -05:00
Ryan C. Gordon
c3114975db Added SDL_GetDisplayUsableBounds(). 2016-01-04 23:52:40 -05:00
Sam Lantinga
42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Philipp Wiesemann
c41feca5de Fixed a crash if creating accelerated renderer after accessing window surface.
Partially fixes Bugzilla #3196.
2015-12-29 19:13:56 +01:00
Alex Szpakowski
0c463d770b SDL_GL_GetAttribute: If a GL context isn't active, only return failure when the specified attribute needs an active GL context to be queried. 2015-12-10 20:25:34 -04:00
David Ludwig
25abce513d WinRT: added Win10/UWP (Universal Windows Platform) support
"UWP" appears to be Microsoft's new name for WinRT/Windows-Store APIs.

This set of changes updates SDL's WinRT backends to support the Win10 flavor
of WinRT.  It has been tested on Win10 on a desktop.  In theory, it should
also support Win10 on other devices (phone, Xbox One, etc.), however further
patches may be necessary.

This adds:
- a set of MSVC 2015 project files, for use in creating UWP apps
- modifications to various pieces of SDL, in order to compile via MSVC 2015 +
  the Win10 API set
- enables SDL_Window resizing and programmatic-fullscreen toggling, when using
  the WinRT backend
- WinRT README updates
2015-11-29 19:33:11 -05:00
David Ludwig
623898f70b WinRT: lots of display and windowing related fixes
This change-set fixes a lot of windowing related bugs, especially with
regards to Windows 8.x apps running on Windows 10 (which was the driver for
this work).  The primary fixes include:
* listed display modes were wrong, especially when launching apps into a
  non-fullscreen space
* reported window flags were often wrong, especially on Windows 10
* fullscreen/windowed mode switches weren't failing (they are not
  programmatically possible in Win 8.x apps).
2015-11-26 00:41:39 -05:00
Sam Lantinga
ebfb2ecb68 don't toggle SDL fullscreen state on OSX if we're destroying the window 2015-11-09 08:55:01 -08:00
Sam Lantinga
eeddb7c534 more SDL fullscreen state tracking fixes, don't update fullscreen flags on failure to change fullscreen state 2015-11-09 08:54:56 -08:00
Sam Lantinga
792354d6f0 SDL OSX implementation must account for the fact that going fullscreen can fail. improve the logic around retrying, make a few attempts before failing. 2015-11-09 08:54:49 -08:00