Commit graph

4859 commits

Author SHA1 Message Date
Sam Lantinga
f84b2f8c6d Removed unsupported Watcom files 2012-01-22 17:41:33 -05:00
Sam Lantinga
51019eddd0 BeOS is no longer a going concern. ;) 2012-01-22 17:33:44 -05:00
Sam Lantinga
136979d3b5 Removed unsupported Borland related files 2012-01-22 17:32:50 -05:00
Sam Lantinga
3ad2c65336 Removing some more references to SDL 1.3 2012-01-22 17:26:45 -05:00
Sam Lantinga
d71e0546a9 Updated to SDL 2.0, and SDL 2.0 can now be installed coexisting with SDL 1.2
--HG--
rename : sdl-config.in => sdl2-config.in
rename : sdl.m4 => sdl2.m4
rename : sdl.pc.in => sdl2.pc.in
2012-01-22 17:21:00 -05:00
Sam Lantinga
8d3c63045f You need to create the texture with the SDL_TEXTUREACCESS_TARGET flag. 2012-01-22 01:29:26 -05:00
Sam Lantinga
0458fa488a Renamed SetTargetTexture() to SetRenderTarget() 2012-01-22 01:26:28 -05:00
Sam Lantinga
da686e5bd4 Reorganized the render target code, moving the viewport handling to the general code and adding software implementation. 2012-01-21 22:22:30 -05:00
Sam Lantinga
fb87e98b8a Sorted the source files 2012-01-21 22:14:38 -05:00
Sam Lantinga
f64b376d9a Cleaned up the iOS test project and added testscale and testrendertarget 2012-01-21 22:13:20 -05:00
Sam Lantinga
7eefd495d2 Added testscale and testrendertarget projects 2012-01-21 21:50:28 -05:00
Sam Lantinga
301928014c We've already crashed by this point if we don't have a renderer. The calling code should check this. 2012-01-21 18:30:50 -05:00
Sam Lantinga
d64668508c Added the correct version.rc to the Visual Studio build. 2012-01-21 12:10:14 -05:00
Sam Lantinga
23b96d3406 Added a renderer flag to expose whether a renderer supports render to texture. 2012-01-19 21:06:47 -05:00
Sam Lantinga
320c59b387 Fix for building with Visual Studio 2012-01-19 20:25:09 -05:00
Sam Lantinga
5546f5ad65 Switched back to configure generating SDL_config.h
It was very confusing to have configure generate an SDL_config.h and then not have it be used when building on Mac OS X or Windows.  I'll just have to remember to use SDL_config_windows.h when building official releases that are supposed to be ABI compatible with Visual Studio.

--HG--
rename : include/SDL_config_generated.h.in => include/SDL_config.h.in
2012-01-19 01:55:51 -05:00
Sam Lantinga
a49a88676f Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Thanks guys!
2012-01-18 22:45:49 -05:00
Sam Lantinga
2e70e7f3cb Fixed bug 1372 - OSX Window Maximize/Resize Doesn't Update Window Position
Alex Nankervis 2012-01-15 14:20:01 PST

SDL_cocoawindow.m, windowDidResize needs to also send a window move event.
Depending on the corner you resize a window from, or when maximizing a window,
the window position will change. Discovered this when creating a maximized
window and found that the window position was stuck at the un-maximized
window's value.

Diff with fix attached.
2012-01-18 22:22:54 -05:00
Sam Lantinga
ec7e4ac7a7 Added spaces for the include path 2012-01-16 20:40:10 -05:00
Sam Lantinga
c1a974dae5 Fixed blit mapping problem when surfaces are freed and then newly allocated at the same address.
Tim Angus to SDL

void function( SDL_Surface* surface )
{
 SDL_Surface* anotherSurface =
   SDL_ConvertSurfaceFormat( surface, ... );

 // surface->map->dst is now equal to anotherSurface

 // Do some stuff with anotherSurface

 SDL_FreeSurface( anotherSurface );

 // anotherSurface is now a dead pointer,
 // but surface->map->dst still points to it
}

int main( )
{
 SDL_Surface* surface = CreateAValidSurface( );

 function( surface );
}

At this point blit something from surface. SDL_LowerBlit is called, which checks surface->map->dst against the blit destination. If the pointers happen to match (not that unlikely), the map is decided to be valid and bad things happen.

It seems to me like the whole idea of caching the blit mapping is fundamentally flawed in that the source surface has no knowledge of the lifetime of the destination surface.
2012-01-16 19:46:40 -05:00
Sam Lantinga
d8630c8b10 Fixed configure build 2012-01-16 19:21:07 -05:00
Sam Lantinga
68b32846b8 Fixed bug 1371 - DX joystick axis ordering fix
Alex Nankervis 2012-01-15 11:19:45 PST

DirectX joysticks can enumerate their axis out of order. This results in some
joysticks having vertical/horizontal swapped, for example (vertical axis gets
assigned to axis0). Joysticks that I've tested with this problem: XBOX 360
controller, Logitech Extreme 3D Pro.

Attached is a diff that fixes this by sorting the DX joystick objects by their
data offsets into the DX data structs. This puts the joystick objects into a
standard ordering (X axis -> axis0, Y axis -> axis1, and so on).
2012-01-15 15:48:27 -05:00
Sam Lantinga
6654546b2a Check for sem_timedwait(), which isn't available on some systems (including OpenBSD 2012-01-15 03:34:14 -05:00
Sam Lantinga
9033bb050f Make sure that we use consistent configuration options on platforms like Windows so that command line builds and IDE builds have ABI compatibility.
Make sure we don't clobber SDL_revision.h when building from Mercurial

--HG--
rename : include/SDL_config.h.in => include/SDL_config_generated.h.in
2012-01-14 13:21:19 -05:00
Sam Lantinga
db165a81bc Unofficial builds should have a 0 revision number - if this accidentally gets checked in with a different revision, this file should be reverted to this content. 2012-01-14 13:17:01 -05:00
Sam Lantinga
185bcb6114 Fixed bug 1238 - SDL_SetKeyboardFocus may send events to already destroyed windows
bastien.bouclet@gmail.com 2011-06-26 02:15:36 PDT

SDL_Keyboard::focus does not seem to be reset when the window that has focus is
destroyed, resulting in the following crash :

#0  X11_SetWindowGammaRamp (_this=0x8ed9cb0, window=0x91f25c0, ramp=0x0) at
src/video/x11/SDL_x11window.c:948
#1  0x001bd15e in SDL_OnWindowFocusLost (window=0x91f25c0) at
src/video/SDL_video.c:1900
#2  0x00168a2e in SDL_SendWindowEvent (window=0x91f25c0, windowevent=<value
optimized out>, data1=0, data2=0)
    at src/events/SDL_windowevents.c:157
#3  0x00166454 in SDL_SetKeyboardFocus (window=0x9678a08) at
src/events/SDL_keyboard.c:612
2012-01-14 01:38:11 -05:00
Sam Lantinga
41b2fc0189 Fixed inline assembly warning for PPC
input constraint with a matching output constraint of incompatible type
2012-01-14 00:49:25 -05:00
Sam Lantinga
40c6294290 Fixed bug 1368 - Enabling joystick subsystem cause an infinite loop
morgan.devel@gmail.com 2012-01-13 00:32:23 PST

The android version of SDL_SYS_JoystickUpdate doesn't check if there is
actually new data and always generate the SDL_JOYAXISMOTION event.
Consequently, doing a while(SDL_PollEvent()) will result in an endless loop.

The attached patch fix this issue.

It also scale the incoming values properly in the Sint16 range. The scale from
[-gravity;+gravity] is done directly in the java part because one may want to
map the sensor values with a non-linear method for example.
2012-01-13 20:57:35 -05:00
Sam Lantinga
3fe05cfb55 Better interpolation for the x4 upsampling case 2012-01-12 22:54:09 -05:00
Sam Lantinga
17d38b0d37 Fixed issue where there was a garbage sample at the end of the buffer. 2012-01-12 21:42:35 -05:00
Sam Lantinga
a9eeb84da2 David Carre cpasjuste@gmail.com
I'm playing with SDL on android, and did notice a problem in latest sources ( branch "default" ) :

SDL/src/render/opengles/SDL_glesfuncs.h:10: error: 'glDrawTexiOES' undeclared (first use in this function)
SDL/src/render/opengles/SDL_glesfuncs.h:10: error: (Each undeclared identifier is reported only once

If it can help you win some time here is the fix, applied to the "Android.mk" file :

LOCAL_CFLAGS += -D GL_GLEXT_PROTOTYPES
2012-01-10 21:07:09 -05:00
Sam Lantinga
7083b58688 Fixed bug 1331 - SDL_CreateTextureFromSurface fails for OpenGL + Win XP 64 NVidia 285.58 with GL_INVALID_ENUM
I think this fixes the bug.  I'm not sure why it would fail, and it may have something to do with the version of OpenGL that we initialize and use by default. Regardless, this should take care of the problem.
2012-01-10 21:00:47 -05:00
Sam Lantinga
b628aa46c5 Fixed bug 1366 - SDL_opengles2.h is not installed in "include/SDL" under Linux 2012-01-09 21:11:11 -05:00
Sam Lantinga
fc8603b5d6 Fixed structure alignment mismatch between Visual Studio and gcc on 64-bit architectures. 2012-01-09 07:07:43 -05:00
Sam Lantinga
5d1613d59e Don't hardcode output paths, Visual Studio does the right thing. 2012-01-09 04:53:58 -05:00
Sam Lantinga
93b05747f5 Removing test projects for Visual Studio 2005 2012-01-09 04:39:55 -05:00
Sam Lantinga
765e15d7b9 I can't test Visual Studio 2005 configurations anymore, and I don't think anyone is using it for production games. 2012-01-09 04:38:34 -05:00
Sam Lantinga
2b67a2d209 Futzing around with strip settings 2012-01-09 00:24:08 -05:00
Sam Lantinga
d3d897c6d0 Fixed memory corruption in the upsampling code, caught by valgrind 2012-01-08 17:31:11 -05:00
Sam Lantinga
7e2e5d34e6 Fixed bug 1091 - Hardcoded size in SDL_audiocvt.c may lead to heap/stack corruption
Markovtsev Vadim 2011-01-18 22:00:16 PST

SDL_audiocvt.c:

static void SDLCALL
SDL_ConvertStereo(SDL_AudioCVT * cvt, SDL_AudioFormat format):

#define dup_chans_1_to_2(type) \
    { \
        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
        type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
        for (i = cvt->len_cvt / 2; i; --i, --src) { \
            const type val = *src; \
            dst -= 2; \
            dst[0] = dst[1] = val; \
        } \
    }

Pay attention to cvt->len_cvt / 2. 2 is the sizeof(Uint16), hovewer, below we
see that the conversion function supports Uint8 and Uint32:

switch (SDL_AUDIO_BITSIZE(format)) {
    case 8:
        dup_chans_1_to_2(Uint8);
        break;
    case 16:
        dup_chans_1_to_2(Uint16);
        break;
    case 32:
        dup_chans_1_to_2(Uint32);
        break;
    }

If type is Uint32, src will be decreased twice as it should be, memory being
written before the cvt->buf. If type is Uint8, the conversion will not be
complete. I suggest to change that define to

#define dup_chans_1_to_2(type) \
    { \
        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
        type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
        for (i = cvt->len_cvt / sizeof(type); i; --i, --src) { \
            const type val = *src; \
            dst -= 2; \
            dst[0] = dst[1] = val; \
        } \
    }

I tested that and now it's working fine. I did not consider the similar defines
in functions nearby.
2012-01-08 17:20:33 -05:00
Sam Lantinga
a9bcdb83a9 Fixed bug 1014 - SDL_ConvertAudio crashes
The patch Mark attached looks good and valgrind gives it a clean bill of health:

Mark.Howson@ntu.ac.uk 2010-12-15 07:45:25 PST

Reproducible here under Windows and Linux. Looking at the code for
SDL_Upsample_S16LSB_2c:

const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
while (dst > target) {
   dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   dst -= 2;
...

if dstsize is odd (and therefore dst), it'll write to target[1] which is one
byte before the allocated buf.

The attached patch to sdlgenaudiocvt.pl changes dst > target to dst >= target,
and removes the - $channels for the upsample case. The patch is not fully
tested, but seems to work here.
2012-01-08 17:10:57 -05:00
Sam Lantinga
6ebbe99d99 Updated Xcode project 2012-01-08 14:45:57 -05:00
Sam Lantinga
d3ab037501 Made the application activity events consistent between iOS and Android 2012-01-08 13:42:03 -05:00
Sam Lantinga
f7ad18f9fc X11 OpenGL ES minor corrections
Scott Percival 2012-01-08 04:21:22 PST

I tested the new build on my two ARM machines, and fixed a few bugs:
- if SDL_VIDEO_DRIVER_UIKIT, SDL_VIDEO_DRIVER_ANDROID or
SDL_VIDEO_DRIVER_PANDORA are specified, function pointers are grabbed from the
compile-linked library instead of through SDL_GL_GetProcAddress. (not sure if
this is the best way to go about it)
- removing "/usr/lib/" from all the library names (hey, with multiarch you
can't be too sure anymore)
- added glFinish to glesfuncs.h
- changed the eglGetProcAddress arg type to "const char *" as per the EGL spec
- filled in the stubs for X11_GLES_SetSwapInterval and X11_GLES_GetSwapInterval
2012-01-08 13:31:22 -05:00
Tim Angus
73b21090a2 * Take a global reference to the activity to prevent the reference being GCed 2011-08-26 13:23:40 +01:00
Sam Lantinga
296e78b65f Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT

This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.

The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION

So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.

The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.

I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
Sam Lantinga
02fe20203d Fixed bug 1287 - VS2010 project doesn't include the SDL_syscond.c file
Liam 2011-08-23 09:09:18 PDT
Hiya!

Seems like there's no implementation of condition variables included when
building with VS2010, adding the generic SDL_syscond.c file to the project
seems to fix it right up.
2012-01-08 01:15:20 -05:00
Sam Lantinga
64d81471d8 Fixed bug 1293 - [Android] Support Pause/Resume
Gabriel Jacobo 2011-12-23 12:55:11 PST

The attached files provide some improvement over the current handling of
pause/resume in Android.
- I disabled the exit(status) instruction in SDL_main as that makes the entire
app instead of the SDL thread exit (while not needed for pause/resume it is
needed for Live Wallpapers, an SDLActivity for which I'll upload in a separate
bug).
- Added nativePause and nativeResume which basically just mark the window as
visible/hidden, something that the end user needs to take into consideration
(ideally pausing the event loop).

Also, this arrangement creates a new GL context when needed, which at least in
my test system is every time you go away from the app and come back to it. So,
this means that the textures need to be generated again after resuming (a
problem the end user didn't have before because the app exited completely when
it should've been pausing). I'd like to know if there's a standard way of
letting the user know that the GL context has changed and that he needs to
refresh his textures, or if this is out of the scope of the library and each
user handles it in their own way (I don't know how/if this same thing is
handled in  the iPhone backend, but it would be wise to try to imitate that).

Gabriel Jacobo 2011-12-23 12:57:10 PST
Also, in the SDLActivity the EGL handling code is moved up to the Activity from
the Surface code, as I think it is possible (in theory) that the surface is
destroyed temporarily while the context remains alive (though in practice in my
test system this is not the case)
2012-01-08 01:05:25 -05:00
Sam Lantinga
d344b8d4a2 Fixed bug 1303 - SDL_CreateFromWindow duplicates window (Cocoa only)
Jens Köhler 2011-09-09 04:47:40 PDT

When calling SDL_CreateWindowFrom with a NSWindow which already contains a
NSView, the window will be duplicated because another NSView is added. I
attached a possible fix that prevents the creation of a second NSView.
2012-01-08 00:39:41 -05:00
Sam Lantinga
0093511f82 Fixed bug 1305 - mouse wheel scroll-down event created when mouse wheel is pressed down
Martin Schreiber 2011-09-15 06:08:38 PDT

patch attached
2012-01-08 00:36:32 -05:00