Commit graph

2507 commits

Author SHA1 Message Date
Ryan C. Gordon
09d6ed6d88 Fixed compiler warning. 2013-07-11 12:26:18 -04:00
Ryan C. Gordon
ad5f0c68a5 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.

--HG--
extra : rebase_source : db951d96e685e17a4d71fe2aa3d65043661ccccc
2013-07-11 12:17:13 -04:00
Sam Lantinga
8d546288b9 Catch out of memory errors creating a window 2013-07-10 22:13:19 -07:00
Sam Lantinga
5b03803ab3 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
Jørgen P. Tjernø
ab91b4ce14 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ø
ea36ba4f4e 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
Sam Lantinga
435103b3d9 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
Sam Lantinga
6255f7f9a8 Backed out changeset c8b16b3a3c9b 2013-07-07 14:08:07 -07:00
Sam Lantinga
274d4eeec2 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
235df7949e Added surface conversion support for ARGB2101010 formats 2013-07-07 12:34:21 -07:00
Sam Lantinga
becaf62d10 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
c9acdd87a7 Added 8-bit RGB source surface support to NtoN blitters 2013-07-06 21:17:09 -07:00
Sam Lantinga
185f93a7a9 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
David Gow
4921d1b526 Remove full-desktop Xinerama mode when using XRandR 2013-06-25 21:36:36 +08:00
Sam Lantinga
156a8638f0 Make it possible to use SDL events separately from the video subsystem. 2013-07-06 12:28:57 -07:00
Sam Lantinga
2015d5faa6 Fixed potential problem with postFinishLaunch being overridden by the application.
Vittorio Giovara

I find that the calling point in SDL_uikitappdelegate.m is dangerous as the -(void) postFinishLaunch method can be overridden when subclassing.
Could this be moved in inside the init or in the didFinishLaunchingWithOptions method which are always called even when subclassed?
2013-07-06 00:32:20 -07:00
Sam Lantinga
cfd541e89c Removed the inline functions from SDL_stdinc.h
Having the SDL functions inline is causing build issues, and in the case of malloc(), etc. causing malloc/free mismatches, if the application build environment differs from the SDL build environment.

In the interest of safety and consistency, the functions will always be in the SDL library and will only be redirected to the C library there, if they are available.

See the following threads on the SDL mailing list for the gruesome details:
* SDL_stdinc.h inlines problematic when application not compiled in exact same feature environment
* Error compiling program against SDL2 with -std=c++11 g++ flag
2013-07-05 23:57:19 -07:00
Ryan C. Gordon
65a277c322 Don't set the same GL context twice on Mac OS X (thanks, Alex!).
Fixes Bugzilla #1939.
2013-07-05 01:18:18 -04:00
Sam Lantinga
8cf62ac298 Merged 2013-06-28 20:46:11 -07:00
Sam Lantinga
9293678409 Fixed bug 1916 - SDL_Keysym contains a deprecated field for unicode which may be removed.
Philipp Wiesemann

SDL_Keysym contains a deprecated field for unicode which may be removed for SDL 2.0 release.

As far as I can tell the field is not set on all "major" platforms and therefore will not be useful for most users. Its existence in a public header therefore becomes (in my opinion) only confusing.
2013-06-18 00:39:47 -07:00
Sam Lantinga
de9566518f Fixed some Visual Studio analyze warnings 2013-06-15 02:46:32 -07:00
Sam Lantinga
f26e1bc175 Fixed bug 1897 - CPU spike on Windows with WM_EVENT and OpenGL
buckyballreaction

On some Windows systems, when switching from fullscreen to windowed mode in my game, the CPU will spike and the application never shows the window again.

See the part of the e-mail thread here:

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2013-June/088626.html

I change the window by calling:

SDL_SetWindowFullscreen(gScreenInfo.sdlWindow, SDL_FALSE);
SDL_SetWindowSize(gScreenInfo.sdlWindow, sdlWindowWidth, sdlWindowHeight);

which you can see in our source:

https://code.google.com/p/bitfighter/source/browse/zap/VideoSystem.cpp#377

Then all of a sudden the application gets stuck in WIN_PumpEvents() in SDL_windowsevents.c.  I turned on WMMSG_DEBUG and found that there was an endless stream of WM_EVENT messages.  I also found that where WM_PAINT is being handled in the callback WIN_WindowProc(), ValidateRect is somehow not clearing, or it is persisting, the WM_EVENT message like it's supposed to (according to the docs).

This may be a hardware issue.  The issue has appeared on three different systems, one of them sporadically:
 - Windows XP SP3 running in VMware 9.0 (without VMWare 3D acceleration, but with the tools and drivers installed), Host: openSUSE 12.3 x86_64, NVidia NVS 3100M
 - Windows XP SP3 64bit running in VirtualBox, Host: Debian Wheezy (stable), Mobility Radeon HD 4100 (this was the sporadic one)
 - Windows 7 64 bit, Radeon 6770
2013-06-06 23:18:36 -07:00
Sam Lantinga
a14efd4af1 Fixed compile errors on iOS 2013-06-05 21:48:53 -07:00
Sam Lantinga
9f08f67e67 The jump hack is no longer used.
Cheers!
2013-06-05 21:47:49 -07:00
Sam Lantinga
eeffdf78ab Need to include SDL_main.h when we call SDL_main() 2013-06-05 21:38:54 -07:00
Sam Lantinga
5a85d1d29a This patch isn't needed because you have the window and can do [nswindow contentView] yourself.
I'm rolling this back so we minimize the things exposed that we have to keep consistent in the API.
2013-06-05 21:31:22 -07:00
Sam Lantinga
47f2eaf415 Added some extra protection to notify the developer if they haven't initialized the application properly.
This will help reduce issues like that reported in bug 1819:

Wouter van Oortmerssen 2013-04-23 20:12:07 EDT
#0  0x01d1e881 in __HALT ()
#1  0x01c58971 in _CFRuntimeCreateInstance ()
#2  0x02e4acc1 in GSFontCreateWithName ()
#3  0x00adc0e1 in UINewFont ()
#4  0x00adc24c in +[UIFont systemFontOfSize:traits:] ()
#5  0x00adc298 in +[UIFont systemFontOfSize:] ()
#6  0x009fb5d9 in +[UITextFieldLabel defaultFont] ()
#7  0x00a8ccd5 in -[UILabel _commonInit] ()
#8  0x00a8ce14 in -[UILabel initWithFrame:] ()
#9  0x00a052eb in -[UITextField createTextLabelWithTextColor:] ()
#10 0x009fbede in -[UITextField initWithFrame:] ()
#11 0x00152ead in -[SDL_uikitview initializeKeyboard] at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitview.m:208
#12 0x0015290c in -[SDL_uikitview initWithFrame:] at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitview.m:50
#13 0x00153b5b in -[SDL_uikitopenglview initWithFrame:scale:retainBacking:rBits:gBits:bBits:aBits:depthBits:stencilBits:majorVersion:] at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitopenglview.m:53
#14 0x001524ff in UIKit_GL_CreateContext at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitopengles.m:114
#15 0x0015078f in SDL_GL_CreateContext at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/SDL_video.c:2666
#16 0x000d8c5c in SDLInit(char const*, vec<int, 2>&) at /Users/aardappel/lobster/dev/xcode/lobster/../../src/sdlsystem.cpp:193
2013-06-05 21:23:59 -07:00
Jørgen P. Tjernø
df3b1a6ed1 Win32: Fix issue with SetCapture & negative values.
This fixes an issue where we were using the wrong macros to extract the position from WM_MOUSEMOVE, so negative values were behaving incorrectly.
These would be generated in multimon situations, or if you use SetCapture.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1175
2013-06-05 12:00:18 -07:00
Jørgen P. Tjernø
c6dd828f1e Win32: Ignore WM_MOUSELEAVE in relative mode.
We get an WM_MOUSELEAVE when we switch to relative mode, even though the cursor is still in the window.
Ignoring this event to not end up with a NULL mouse focus.

This fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1861
2013-06-05 12:00:15 -07:00
Jørgen P. Tjernø
f1fc414daa Mac: Fix incorrect relative jump on focus / start.
We should no longer send huge jumps on relative mode focus changes if
the cursor was moved around, or on initial start.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1836
2013-06-04 14:54:49 -07:00
Jørgen P. Tjernø
95cf57b19f Mac: Hide cursor in relative mode.
This hides the cursor when you SDL_SetRelativeMouseMode, as intended.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1860
2013-06-04 13:53:55 -07:00
Jørgen P. Tjernø
449d63452e - fix misleading hint about minimising on focus loss 2013-06-04 13:47:51 -07:00
Azamat H. Hackimov
1732f61b81 Fix compilation with libX11 >= 1.5.99.902.
These changes fixes bug #1769 for SDL2
(http://bugzilla.libsdl.org/show_bug.cgi?id=1769).
2013-06-02 20:20:18 +06:00
Philipp Wiesemann
64f1ac9002 Fixed implicit function declaration and warning for SDL_Log(). 2013-06-02 14:11:04 +02:00
Philipp Wiesemann
3472d792a9 Fixed implicit function declarations and their warnings.
For the SDL_SetMouseFocus() and SDL_SetKeyboardFocus().
2013-06-01 21:17:43 +02:00
Philipp Wiesemann
6096e60a4b Removed debug output. 2013-06-01 21:11:52 +02:00
Sam Lantinga
07424fd0ca Fixed compiler warning 2013-05-26 11:44:03 -07:00
Edward Rudd
0ce4bb89d8 Only free EventData if it's successfully retrieved.
- straight from http://who-t.blogspot.com/2009/07/xi2-and-xlib-cookies.html
- hopefully fixes random crash on some systems
2013-05-23 18:45:14 -04:00
Ryan C. Gordon
a106589b14 Patched to compile with older glext.h that don't have GL_NUM_EXTENSIONS.
--HG--
extra : rebase_source : e2ece9401f8f324875930d35c61514920732087b
2013-05-22 01:36:37 -04:00
Ryan C. Gordon
077cd8d398 Use glGetStringi() for extension lookup on OpenGL contexts >= version 3.0.
Fixes Bugzilla #1620.

--HG--
extra : rebase_source : 5fa86e8591bfea85e1adf8a495a7b32c3d5dacd5
2013-05-22 01:31:04 -04:00
Sam Lantinga
a1b0f0566b Fixed macro line endings after whitespace was fixed 2013-05-21 22:04:14 -07:00
Sam Lantinga
e2929bcb73 Fixed bug 1534 - SIGSEGV in SDL_ConvertSurface() for certain formats in SDL2
Don't assume that 8 bit formats are indexed.
Thanks to Gabriel Jacobo for research and potential patches.
2013-05-21 22:01:18 -07:00
Ryan C. Gordon
c950178124 Patched to compile on older Mac OS X devtools (thanks, D B!). 2013-05-21 23:02:16 -04:00
Sam Lantinga
44ae527164 Fixed bug 1148 - SDL window white upon first appearing
To be consistent with other platforms, we'll use black as the background color.
2013-05-20 23:30:08 -07:00
Sam Lantinga
97fba74bda Fixed bug 731 - No mechanism to extract the NSView for 3d library 2013-05-20 22:05:49 -07:00
Sam Lantinga
2f9ac5db94 Fixed losing ALT key modifiers on Unity 2013-05-20 12:25:16 -07:00
Sam Lantinga
30a001fdfa Fixed bug 1842 - [patch] SDL_SetWindowPosition sets bad position values when given SDL_WINDOWPOS_CENTERED args
Alex Szpakowski

When calling SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED), the window moves to the correct position but it seems to internally set its x/y position values to the literal value of the SDL_WINDOWPOS_CENTERED define.
This causes all sorts of problems when SDL functions which use the window position (e.g. SDL_SetWindowGrab) are called after the aforementioned SDL_SetWindowPosition call.

Looking at the SDL_SetWindowPosition code, it seems that SDL_SendWindowEvent with the SDL_WINDOWEVENT_MOVED event is called at the end of the function using the literal value of the SDL_WINDOWPOS_CENTERED define, instead of the newly set window->x and window->y values.
SDL_SendWindowEvent then sets the values of window->windowed.x and window->windowed.y to that value (0x2FFF0000, aka 805240832.)

I have attached a patch which changes SDL_SetWindowPosition to make sure SDL_SendWindowEvent is called with the correct coordinate values, if SDL_WINDOWPOS_CENTERED is used (fixes the issue for me.)

Tested with Mac OS 10.8.3.
2013-05-19 22:36:54 -07:00
Sam Lantinga
71d173a062 Fixed black screen on iOS 2013-05-18 14:51:29 -07:00
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Sam Lantinga
2ac8624930 Added mobile application events, with implementations for iOS and Android 2013-05-18 12:48:50 -07:00