Commit Graph

10682 Commits

Author SHA1 Message Date
Sam Lantinga
2172f538cc Fixed bug 1946 - OpenGL contexts in threads
The SDL OpenGL context code is now properly thread aware.  There are two new functions which return the current OpenGL window and context for the current thread.

There are still places in the cocoa driver where the OpenGL context needs to be updated when the view changes.  These will need a different solution and still use the last globally set context to avoid changing behavior.
2013-07-11 22:59:20 -07:00
Ryan C. Gordon
81d61485aa Fixed off-by-one error in SDL_ConvertStereo().
Fixes Bugzilla #561.
2013-07-12 01:26:43 -04:00
Sam Lantinga
ce81311ab7 Check the parameters to SDL_UpdateTexture() 2013-07-11 22:04:16 -07:00
Sam Lantinga
c0f6172cfe Fixed bug 1958 - Cocoa SwapWindow doesn't swap the specified window
Ryan C. Gordon

We have this in Cocoa_GL_SwapWindow()...

    /* FIXME: Do we need to get the context for the window? */
    [[NSOpenGLContext currentContext] flushBuffer];

...which means if the current GL context is not the one in (window), we swap a different one than requested.

Right now, we don't store information about which context is assigned to which window, and the OS doesn't give you a way to retrieve it from an NSView. We would have to track this per-window during SDL_GL_MakeCurrent() (and SDL_GL_CreateContext) calls.
2013-07-11 21:51:09 -07:00
Ryan C. Gordon
0d20116ec9 Whoops, missed a part of that last commit.
Actually fixes Bugzilla #1857.
2013-07-11 23:59:09 -04:00
Ryan C. Gordon
0cbdae6cb5 Explicitly write silence to the audio device while it is paused.
This is what SDL 1.2 did; we'll do this properly (add a method for the target
 driver to pause) when I rewrite all this code after the official 2.0 release.

Fixes Bugzilla #1857.
2013-07-11 23:53:00 -04:00
Ryan C. Gordon
71117d7c74 Attempt to fix a compiler warning on Haiku.
(if this works...Haiku generates no warnings. I know, right?!?)
2013-07-11 23:17:52 -04:00
Ryan C. Gordon
b2dfae24bf Fixed compiler warnings on Haiku. 2013-07-11 12:44:03 -04:00
Ryan C. Gordon
35232f9450 Removed some unused variables. 2013-07-11 12:27:39 -04:00
Ryan C. Gordon
cd189f403d Fixed compiler warning. 2013-07-11 12:26:18 -04:00
Ryan C. Gordon
2bc9edb3c8 Cleaned up WGL_ACCELERATION_ARB usage.
We now do FULL or NO accel based on the app's preference. If the app didn't
 specify, we do FULL then fall back to NO.

(Not specifying anything--a true "don't care" scenario--breaks some ATI
 drivers, so we try to keep to the spirit of it while forcing a specific
 state.)

Previously, it would always do FULL, and try NO if it failed and the app
 had requested NO or DONTCARE.

This is a transplant of hg changesets a04171d6fa11 and d0b7c45e982e from the
 SDL-1.2 branch.

Fixes Bugzilla #1254.
2013-07-11 12:17:13 -04:00
Ryan C. Gordon
5d512ae70e Added src/thread/pthread/SDL_systls.c to the CMake scripts. 2013-07-11 01:09:45 -04:00
Sam Lantinga
3bb816105c Catch out of memory errors creating a window 2013-07-10 22:13:19 -07:00
Sam Lantinga
b635831bba Fixed compile 2013-07-10 22:06:11 -07:00
Sam Lantinga
1dfa68f250 Fixed bug 1949 - Pulseaudio 32 bit audio formats support
Matt Scheirer

Pulse has supported (since version 0.8, at least) 32 bit audio formats that are now becoming available in SDL2. This patch adds those format conversions to the switch clause in the pulseaudio backend.
2013-07-10 22:01:24 -07:00
Sam Lantinga
51ca99aaa2 Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Nitz

In Function X11_DispatchEvent(_THIS), case SelectionNotify :
static void
X11_DispatchEvent(_THIS)
{
 // Some Code
  case SelectionNotify: {
  //Some Code
  SDL_bool expect_lf = SDL_FALSE;
                    char *start = NULL; // Initialised with NULL
                    char *scan = (char*)p.data;
                    char *fn;
                    char *uri;
                    int length = 0;
                    while (p.count--) {
                        if (!expect_lf) {
                            if (*scan==0x0D) {
                                expect_lf = SDL_TRUE;
                            } else if(start == NULL) {
                                start = scan;
                                length = 0;
                            }
                            length++;
                        } else {
                            if (*scan==0x0A && length>0) {
                                uri = malloc(length--);

                                memcpy(uri, start, length); // Problem is Here, start is still NULL if control comes to else statement without initialising the start pointer, which is wrong

                                uri[length] = 0;
                                fn = X11_URIToLocal(uri);
                                if (fn) SDL_SendDropFile(fn);
                                free(uri);
                            }
                            expect_lf = SDL_FALSE;
                            start = NULL;
                        }
                        scan++;
                    }
                }
As shown above how start pointer remains NULL, Patch for this issue would be:
                            if (*scan==0x0D) {
                                expect_lf = SDL_TRUE;
                            }
                            if(start == NULL) {
                                start = scan;
                                length = 0;
                            }
Just replace else if statement with if.
2013-07-10 21:57:31 -07:00
Ryan C. Gordon
4542d508d5 Added src/thread/windows/SDL_systls.c to CMakeLists.txt (thanks, Charles!).
Fixes Bugzilla #1955.
2013-07-10 23:43:35 -04:00
Sam Lantinga
7889fcdc7d Added PowerPC and ARM versions of the memory barrier functions. 2013-07-10 20:17:20 -07:00
Sam Lantinga
f5306d72d0 Added release/acquire memory barriers to the atomic API
* Added a destructor to clean up TLS memory at thread shutdown
* Refactored the TLS code to have platform independent code and a small platform dependent core with a fallback to generic code if platform dependent functions fail.
* Fixed recursion issues with SDL_GetErrBuf()
2013-07-10 18:31:17 -07:00
Sam Lantinga
5a15888731 Fixed Haiku build 2013-07-10 02:37:57 -07:00
Sam Lantinga
9c0dea8e15 Implemented an API for thread-local storage: SDL_TLSCreate(), SDL_TLSSet(), SDL_TLSGet() 2013-07-10 02:32:04 -07:00
Jørgen P. Tjernø
2866a61f70 SDL_GL_MakeCurrent: Only no-op redundant calls on *same* thread.
This ensures that we only no-op redundant calls if they're made on the
same thread as the last MakeCurrent with those arguments. This should
maek SDL behave better with multithreaded environments.
2013-07-09 12:58:54 -07:00
Jørgen P. Tjernø
87ab2c5325 Mac: Remove dead FULLSCREEN_TOGGLEABLE code.
This code was written almost 2 years ago, and the flag hasn't been
changed since. Cleaning up the code by removing the conditional blocks,
so that they behave the same way they have for the past two years.

FULLSCREEN_TOGGLEABLE used to cause us to use
-[NSOpenGLContext setFullScreen] and a pixel format with
NSOpenGLPFAFullScreen.
2013-07-09 12:57:12 -07:00
Gabriel Jacobo
9bc1b31fd3 Removing video/uikit/*.c from configure's iOS sources
Unexplicable computer sciences phenomenon: Instead of returning an empty set,
*.c in an folder with no .c files produces the "*.c" string to be added as
a source. I'm sorry future generations, we are doing the best we can :)
2013-07-09 13:54:29 -03:00
Ryan C. Gordon
910e8a8155 Backout hg changset 898992405fa7; lots of things still use SDL_types.h. :/
Will remove this again at some point in the future, though.
2013-07-09 11:57:32 -04:00
Sam Lantinga
7be0e70524 Made the SDL_memset4() comment even clearer so we don't accidentally replace it with memset() in the future. 2013-07-09 08:01:40 -07:00
Sam Lantinga
09997d0e9f Backed out commit 898992405fa7 because memset() does a byte fill and SDL_memset4() does a uint32 fill and this change breaks SDL_FillRect() 2013-07-09 07:13:58 -07:00
Gabriel Jacobo
93274d6d53 Adds Input Focus handling on Android to improve pausing/resuming behavior
Ref: http://android-developers.blogspot.com/2011/11/making-android-games-that-play-nice.html
2013-07-09 10:25:16 -03:00
Ryan C. Gordon
173b1e9280 Removed deprecated SDL_types.h header.
Fixes Bugzilla #1945.
2013-07-08 23:37:00 -04:00
Ryan C. Gordon
fca053548a Replaced SDL_memset4() implementation with a call to SDL_memset().
The implementation was slower than the C runtime on Mac OS X, Linux, and
 Windows...quite a bit slower when using the C fallback instead of the inline
 asm, too.

Fixes Bugzilla #1755.
2013-07-08 23:22:36 -04:00
Edward Rudd
5d3f154808 change fsaa argument for testgl to accept a # of samples for FSAA 2013-07-08 17:51:17 -04:00
Ryan C. Gordon
0e46f3f31f Disable OSS and BSD audio targets on OpenBSD. 2013-07-08 13:26:59 -04:00
Sam Lantinga
f98fac9047 Make sure that srcdir has a full pathname so source indexing works. 2013-07-08 09:21:54 -07:00
Sam Lantinga
2cf1b4170a Fixed bug 1943 - Wrong handling of legacy 32bpp BMP files
Kang Seonghoon

While BMP format supports alpha channel, it is enabled only when the header is at least 56 bytes long (BITMAPV3INFOHEADER and later). For very common 40-byte-long header (BITMAPINFOHEADER) 32bpp format should be interpreted as BGRX format, but currently SDL interprets them as BGRA format and causes a significant compatibility problem as many 32bpp files use a padding byte of 0 ("transparent" in BGRA interpretation).

---

I fixed this by checking to see if the alpha channel is all 0, and if so, setting it opaque.
2013-07-07 18:23:04 -07:00
Ryan C. Gordon
26b9082a9a sndio dynamic loading fix. 2013-07-07 20:06:08 -04:00
Sam Lantinga
7b71990fe2 Backed out changeset c8b16b3a3c9b 2013-07-07 14:08:07 -07:00
Sam Lantinga
889b6aadc4 Fixed bug 1943 - Wrong handling of legacy 32bpp BMP files
Kang Seonghoon

While BMP format supports alpha channel, it is enabled only when the header is at least 56 bytes long (BITMAPV3INFOHEADER and later). For very common 40-byte-long header (BITMAPINFOHEADER) 32bpp format should be interpreted as BGRX format, but currently SDL interprets them as BGRA format and causes a significant compatibility problem as many 32bpp files use a padding byte of 0 ("transparent" in BGRA interpretation).
2013-07-07 12:53:21 -07:00
Sam Lantinga
35c747cd4d Added automated test to validate conversion between all supported formats. 2013-07-07 12:34:26 -07:00
Sam Lantinga
6403bbcc7e Added surface conversion support for ARGB2101010 formats 2013-07-07 12:34:21 -07:00
Sam Lantinga
08f84f6b06 Fixed converting ARGB2101010 surfaces to 8-bit surfaces
It's not like this is very useful, but it fixes a crash in this case.
2013-07-07 10:31:01 -07:00
Sam Lantinga
0c64161715 Updated configure with the sndio audio backend 2013-07-07 10:15:10 -07:00
Philipp Wiesemann
6f27bb0714 Corrected name of constant in header file comment. 2013-07-07 16:15:21 +02:00
Philipp Wiesemann
1f5019fb44 Changed include directive to standard header. 2013-07-07 16:13:17 +02:00
Philipp Wiesemann
ac7859a2dc Fixed SDL_RWread() returning -1 as unsigned instead of 0 if error on Android.
Found by Cppcheck (pointed out check of unsigned < 0 which was left in place).
2013-07-07 16:11:29 +02:00
Ryan C. Gordon
6174013522 Added an SDL2 OpenBSD sndio(7) audio target. 2013-07-07 02:03:07 -04:00
Ryan C. Gordon
69f525600a Disk audio target was using this->hidden->mixlen before we set it. 2013-07-07 02:04:19 -04:00
Ryan C. Gordon
b4e38d394c Minor ALSA tweaks (include-once macro name, len for memset() more clear). 2013-07-07 02:03:50 -04:00
Sam Lantinga
580e8a54b0 Added 8-bit RGB source surface support to NtoN blitters 2013-07-06 21:17:09 -07:00
Sam Lantinga
caff7e8153 Fixed bug 1923 - Crash with SDL_SetColorKey
Sylvain

1/ Load an Image XPM with IMG_ReadXPMFromArray()
2/ Try to set a ColorKey on it.

I notice that :
- the SDL_Surface that is created from XPM has a palette !
- the colorkey is a RBG.

it crashes (SIGSEGV) inside the SDL_SetColorKey function:
"surface->format->palette->colors[surface->map->info.colorkey].a"
2013-07-06 20:29:40 -07:00
Sam Lantinga
8425cf5d1a Fixed bug 1911 - enable HAVE_GCC_ATOMICS for android platform 2013-07-06 12:39:56 -07:00