Commit graph

4224 commits

Author SHA1 Message Date
Sam Lantinga
40b7af6399 Fixed incorrect window state if the window is created grabbed. We don't want to activate the window if it isn't shown yet. 2013-08-07 00:10:31 -07:00
Sam Lantinga
73a2e37abb Fixed bug 1848 - SDL_SetWindowSize cannot set sizes larger than desktop resolution in Windows 2013-08-06 22:55:55 -07:00
Sam Lantinga
3f1d72a71c Fixed clobbering viewport when window is resized when using the software renderer. The viewport adjustment is already handled in the top level rendering code. 2013-08-06 22:31:11 -07:00
Sam Lantinga
330f7e1be3 Fixed a number of missing keys in the X11 keyboard mapping. 2013-08-06 18:19:34 -07:00
Sam Lantinga
8005b8d613 Added scancodes for F17, F18, F19 on a Mac keyboard 2013-08-06 12:56:47 -07:00
Ryan C. Gordon
a052fa0ae8 Removed anisotropic option from SDL_HINT_RENDER_SCALE_QUALITY.
Anisotropic filtering is meant to be used for textures at a stark
 angle, not perpendicular to the camera.

--HG--
extra : rebase_source : e01c4da3bae7f1628de7c049f31f1208dbbbb24c
2013-08-06 00:23:04 -04:00
Sam Lantinga
ecbffe9660 Added scancodes for F13-F19 from a Mac USB keyboard 2013-08-05 11:45:51 -07:00
Philipp Wiesemann
7e69cee4c5 Added missing function prototype and changed its signature.
Signature was changed to prevent a header for SDL_GLContext.
2013-08-04 23:38:25 +02:00
Sam Lantinga
073d059fc9 Fixed bug 2008 - error typos in gles2 renderer
Martin Gerhardy

The attached patch fixes some typos in the SDL_SetError calls that are a little bit misleading.
2013-08-04 09:26:45 -07:00
Sam Lantinga
12b0ad39fc Allow C++ code to include SDL_android.h
Alexey Petruchik

Although SDL_android.h is not intended to be included by client code sometimes it needed. For example you need JNIEnv pointer to make JNI calls to modified SDLActivity.java (video playback, facebook integration, in-apps). It seems a bit weird to write:

extern "C" {
#include "SDL_android.h"
}

in my AndroidJNI.cpp file.
2013-08-04 09:23:55 -07:00
Philipp Wiesemann
1e3605c00f Added missing return statement. 2013-08-03 23:40:28 +02:00
Philipp Wiesemann
ea1040111a Fixed calling JNI method in a wrong way.
Method is void and does not return bool.
2013-08-03 23:36:07 +02:00
Gabriel Jacobo
2a6b235190 Fixes bug #1889, allows for GL Context deletion/recreation on Android
Thanks ny00!
2013-08-03 12:54:39 -03:00
Ryan C. Gordon
a99dfca578 Some fixes for SDL_MaximizeWindow().
Fixes Bugzilla #1441.
2013-08-03 02:20:00 -04:00
Ryan C. Gordon
a60814585d Fixed some whitespace.
--HG--
extra : rebase_source : f10a447a25fafe9bc7a56dba0e6ebc74a3804063
2013-08-02 18:25:20 -04:00
Gabriel Jacobo
ab545a05b9 Temporary fix for bug #1639 SDL does not message back closing of screen keyboard
See FIXME notes on patch for details.
2013-08-02 12:38:39 -03:00
Sam Lantinga
8ee3d7a554 Fixed bug 1968 - SDL_RenderCopy stretch loses proportion on viewport boundaries for 3D renderers
driedfruit

SDL_RenderCopy clips dstrect against the viewport. Then it adjusts the
srcrect by "appropriate" amount of pixels. This amount is actually
wrong, quite a lot, because of the rounding errors introduced in the "*
factor / factor" scale.

            real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
            real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;

For example:

I have a 32 x 32 srcrect and a 64 x 64 dstrect. So far the
stretching is done perfectly, by a factor of 2.

Now, consider dstrect being clipped against the viewport, so it becomes
56 x 64. Now, the factor becomes 1.75 ! The adjustment to "srcrect"
can't handle this, cause srcrect is in integers.

And thus we now have incorrect mapping, with dstrect not being in the
right proportion to srcrect.

The problem is most evident when upscaling stuff, like displaying a 8x8
texture with a zoom of 64 or more, and moving it beyond the corners of
the screen. It *looks* really really bad.

Note: RenderCopyEX does no such clipping, and is right to do so. The fix would be to remove any such clipping from RenderCopy too. And then fix the software renderer, because it has the same fault, independently of RenderCopy.

[attached patch]
this leaves Software Renderer buggy, as it does it's own clipping later on
2013-08-01 09:15:36 -07:00
Sam Lantinga
da00f7ef51 Fixed bug 1638 - Blit Alpha surface bug
The DUFFS_LOOP_124() macro was trying to be too clever and wasn't doing the right thing, it was checking n & 4 instead of width.
I'm not sure how we didn't catch this before, but it should be fixed now.
2013-08-01 01:29:07 -07:00
Ryan C. Gordon
72d8cda7bb Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Fixes Bugzilla #1959.
2013-08-01 01:50:02 -04:00
Ryan C. Gordon
3d680115c7 Move the fix for Bugzilla #1395 into WIN_GL_SetupWindow() directly.
It's a cleaner solution.

--HG--
extra : rebase_source : efd29bea6e39b6aed73f78a0f119b3b4c2bbd498
2013-08-01 00:27:22 -04:00
Sam Lantinga
44c4197243 Documented why we have global and thread-local variables for the GL context. 2013-07-31 21:22:09 -07:00
Ryan C. Gordon
8ed3858721 Windows: Don't lose the existing current GL context in SDL_CreateWindow().
Fixes Bugzilla #1395.
2013-08-01 00:01:57 -04:00
Ryan C. Gordon
15997f221a Workaround some Windows OpenGL drivers mishandling wglMakeCurrent().
You should be able to do wglMakeCurrent(NULL, NULL), according to MSDN, since
the first parameter is ignored if the second is NULL, but this causes problems
on some drivers, so make sure we always have a valid HDC in the first
parameter (and exit early if we already have no current context in the
NULL, NULL case).
2013-07-31 11:00:23 -04:00
Gabriel Jacobo
512f5dfc21 Fix for bug 2001, verify that the AudioTrack is properly initialized
...and fail to initialize the audio backend if it's not!
2013-07-31 10:04:59 -03:00
Sam Lantinga
35628ecbc4 Check for negative source rectangle in SDL_SoftBlit() (thanks John!) 2013-07-30 20:57:26 -07:00
Philipp Wiesemann
058120689b Added support for the two new key codes from Android 4.3. 2013-07-30 23:24:23 +02:00
Sam Lantinga
3334092bdc Fixed compiler warning with gcc 2013-07-30 00:02:45 -07:00
Ryan C. Gordon
9694301e04 Workaround older libpulse that fails in pa_context_new() with a NULL appname.
Newer libpulses do sane defaults if you pass a NULL there. In lieu of a
proper way to specify this in SDL at the moment, this will do.

Fixes Bugzilla #1119.
2013-07-30 01:32:26 -04:00
Ryan C. Gordon
fe98dc3642 These should be __inline__, not inline. 2013-07-30 01:30:32 -04:00
Ryan C. Gordon
b8198f3b2a Attempt to fix compiler warning.
Fixes Bugzilla #1784. (or at least the only part of it that was a real bug.)
2013-07-30 00:17:44 -04:00
Ryan C. Gordon
dd41037670 Backed out hg changeset 7f26fd1df927; docs were wrong, not the code. 2013-07-27 13:13:57 -04:00
Ryan C. Gordon
546bedb836 Added a FIXME discussion to last commit. 2013-07-27 13:09:15 -04:00
Ryan C. Gordon
0c7cb878bd Cocoa: Make the next-highest window gain focus when a window is closing.
(if the closed window wasn't the foreground, this is effectively a no-op.)

--HG--
extra : rebase_source : e87546ce8bcfc1b3e21631b8ef6a1264d3f499d6
2013-07-22 20:55:07 -04:00
Philipp Wiesemann
41edaa9b20 Fixed SDL_HapticOpened() returning -1 instead of 0.
According to header file it should only return 0 or 1.
2013-07-27 14:22:52 +02:00
Philipp Wiesemann
dc646c6468 Removed C++ macro setup in internal header for Android port which is only C now. 2013-07-27 14:06:06 +02:00
Philipp Wiesemann
c2d852cb79 Fixed SDL_HapticRumblePlay() maybe working because of SDL_HapticUpdateEffect(). 2013-07-27 13:52:16 +02:00
Philipp Wiesemann
eab7f43fc2 Corrected SDL_HapticUpdateEffect() returning 0 instead of index of effect.
According to documentation in header and wiki the index should be returned.
This change may break existing programs which assume only 0 means a success.
2013-07-27 13:39:43 +02:00
Sam Lantinga
ff8077550e Fixed variable scoping for Windows build 2013-07-27 03:22:37 -07:00
Sam Lantinga
95b452107c Fixed bug 1272 - Bogus numlock key up/down events being reported on MacOS X
Vern Jensen

The problem is that in certain situations I'm getting THREE keyUp/keyDown events when I push certain keys.

In my event code I added:

case SDL_KEYUP:

printf("SDL KeyScanCode for KEYUP event: %d\n", event->key.keysym.scancode );
…

and

case SDL_KEYDOWN:

printf("SDL KeyScanCode for KEYDOWN event: %d\n", event->key.keysym.scancode );
…

The result of one test run where I push 2 keys and then release them is this:

SDL KeyScanCode for KEYDOWN event: 92   // Pushed keypad 4
SDL KeyScanCode for KEYDOWN event: 83   // Pushed left shift
SDL KeyScanCode for KEYUP event: 83
SDL KeyScanCode for KEYDOWN event: 225
SDL KeyScanCode for KEYUP event: 92     // Released keypad 4
SDL KeyScanCode for KEYDOWN event: 83
SDL KeyScanCode for KEYUP event: 83
SDL KeyScanCode for KEYUP event: 225    // Released left shift

There *should* be only a total of 4 events above… 2 for each key being pushed, and 2 for each being released. But instead some bogus events for numlock being pushed/released are sent from SDL. These events did not occur. I did not push numlock. The value above for numlock is 83. Comments above show when I pushed each key. As you can see, when I push left shift, THREE events are instantly sent to my application, keyDown and then keyUp for numlock, and then the valid event for left shift (the key that was actually pushed).

You could replace keypad 4 with pretty much any keyPad key and it'll still happen. You can also replace it with any arrow key and it'll happen. However, when trying it with normal letter keys on the main keyboard it didn't.

It happens with other modifier keys too, not just left shift.

The order in which the keys are pressed matter. For instance, if I do:

1) keypad 4
2) left shift
3) release left shift
4) release keypad 4

Then at step 2, I get the 3 events above (when there should be only one), but steps 3 and 4 work properly… I don't get extra keyUp/keyDown events for steps 3 or 4. Thereas if the order of steps 3 and 4 are reversed, I get the bogus extra events for numlock.

Also, the problem can occur even when pushing just a single key by itself. If I push left shift, then keypad 4, then release left shift, then release keypad 4, then the following push of left shift will cause the bug. If I continue pushing and releasing left shift though, it won't happen again until I again involve keypad keys.

---

Sam Lantinga

According to the Apple documentation, NSNumericPadKeyMask is set for any arrow or numeric keypad event. Indeed this is what's happening.

I verified that we get the correct events for the numlock key and the mod state gets set correcly, so it should be safe to remove this bogus code.
2013-07-27 03:20:09 -07:00
Sam Lantinga
dae53a0790 Improved error checking in the haptic system, preventing crashes in some cases.
Edgar Simo 2012-05-06 02:33:39 EDT

I recall that driver being buggy back in the day, but looking over the code there's a number of things being done wrong which I've fixed and it should now properly error out instead of crashing. Also make sure you initialize the haptic subsystem before using haptic commands (which I now more explicitly try to enforce).
2013-07-27 02:45:26 -07:00
Sam Lantinga
ec67327c73 Fixed bug 1919 - Window icon disappears as soon as a renderer is created
Sebastian

Setting a window icon works just fine until a renderer is added to the window.
After adding the renderer the icon disappears.

Reproduce by:
- Take the example code from the wiki: http://wiki.libsdl.org/moin.fcg/SDL_SetWindowIcon

- Add the following two lines after  SDL_FreeSurface(surface);
  SDL_Delay(1000);
  SDL_Renderer* ren = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

-compile and run

You will see the window icon correctly at first. After the Delay the Icon will disappear.
2013-07-14 18:17:28 -07:00
Sam Lantinga
f1886b3c36 Fixed bug 1526 - X11 - XUnmapWindow should not be called directly
driedfruit

In X11_HideWindow, we call XUnmapWindow to unmap. According to ICCCN2.0, this should never happen, and XWithdrawWindow should be called instead.

http://www.tronche.com/gui/x/icccm/sec-4.html#s-4.1.4

"The reason for requiring the client to send a synthetic UnmapNotify event is to ensure that the window manager gets some notification of the client's desire to change state, ***even though the window may already be unmapped when the desire is expressed***."

Additionally, this can be observed at http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/Withdraw.c#n65

Failure to comply leads to "MapNotify" event never appearing on non-reparenting WMs after subsequent show-hide-show requests. (I'm currently observing this behavior, thus my bug report).
2013-07-27 00:49:34 -07:00
Sam Lantinga
5623b2c61d Fixed crash and garbled output when converting from F32 to S16 audio. 2013-07-25 18:11:09 -07:00
Philipp Wiesemann
5cdb605a41 Corrected return value to be of correct type. 2013-07-24 22:25:17 +02:00
Philipp Wiesemann
adce8bf505 Corrected internal documentation in source.
The parameter silent is no longer optional.
2013-07-24 22:23:19 +02:00
Philipp Wiesemann
e722fd86e9 Removed unreachable code. 2013-07-24 22:20:03 +02:00
Sam Lantinga
9583071066 Fix for recent GLX error bug
Lee Salzman

I messed up in the patch I sent you regarding gobbling up the GLX error codes signaled when trying to create a context. After reading the spec I realized those error codes are relative to a base error that needs to be queried when setting up the GLX extension...

So I have made a patch that fixes it for a user I had who was still getting the bug with my old patch.

Without this patch my previous one won't work, so it is recommended to merge this...
2013-07-23 19:20:03 -07:00
Sam Lantinga
ccb139c73a A little cleanup on the cleanup, just for consistency. 2013-07-23 19:18:01 -07:00
Jørgen P. Tjernø
aa5f318964 = {{0}} generates a memset() in MSVC, which isn't linked. Whoops! 2013-07-23 17:40:18 -07:00
Jørgen P. Tjernø
8c0d5be080 Fix build errors from last change. 2013-07-23 17:40:16 -07:00