Commit Graph

6154 Commits

Author SHA1 Message Date
Sam Lantinga
bbb0519eee Fix building the tests with Visual Studio 2012 (thanks Isaac!) 2013-08-07 09:20:41 -07:00
Sam Lantinga
dfac4af69a Reset the viewport when we reset the other D3D state.
From Sythical:

Hello, I've created a simple SDL2 application which draws a texture on the screen. The problem I'm having is that if I launch another program which loads the UAC popup or if I lock my PC and then login again, the application stops drawing the texture. I tried adding SDL_Delay(10000) after SDL_RenderPresent(renderer). This made the texture stay on the screen for a little bit but the texture wasn't drawn again after the delay. Here's my code:

#include "SDL.h"

int main(int argc, char *argv[])
{
    SDL_Renderer *renderer;
    SDL_Window *window;
    SDL_Surface *surface;
    SDL_Texture *rect_texture;
    SDL_Event main_event;
    SDL_Rect rect_data;
    int enable_vsync = 1;

    if(SDL_Init(SDL_INIT_VIDEO) < 0) return 1;

    window = SDL_CreateWindow("SDL2 Application", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 600, 600, SDL_WINDOW_RESIZABLE);

    renderer = SDL_CreateRenderer(window, -1, enable_vsync ? SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC : SDL_RENDERER_ACCELERATED);
    SDL_SetRenderDrawColor(renderer, 20, 20, 30, 255);

    surface = SDL_LoadBMP("icon.bmp");
    rect_texture = SDL_CreateTextureFromSurface(renderer, surface);

    rect_data.w = 32; rect_data.h = 32;
    rect_data.x = 300; rect_data.y = 300;

    while(main_event.type != SDL_QUIT)
    {
        SDL_PollEvent(&main_event);

        SDL_RenderClear(renderer);
        SDL_RenderCopy(renderer, rect_texture, NULL, &rect_data);
        SDL_RenderPresent(renderer);
    }

    SDL_DestroyTexture(rect_texture);
    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}
2013-08-07 01:14:04 -07:00
Sam Lantinga
51376e7d6b Unify the SetWindowPos() calls so that they all set the window state based on SDL state.
This prevents a rogue call to SetWindowPos() from changing the state unexpectedly.
Also moved the size correction code above the window position query, because the initial window size can affect the positioning.
2013-08-07 00:46:42 -07:00
Sam Lantinga
08caedf410 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
b3ce9dee4a Fixed bug 1848 - SDL_SetWindowSize cannot set sizes larger than desktop resolution in Windows 2013-08-06 22:55:55 -07:00
Sam Lantinga
4b9d9d7d74 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
Ryan C. Gordon
77b4978afb Removed function signature that doesn't actually exist yet. 2013-08-06 18:23:46 -07:00
Sam Lantinga
8b8f17d38d Fixed a number of missing keys in the X11 keyboard mapping. 2013-08-06 18:19:34 -07:00
Sam Lantinga
34fc54885e Added scancodes for F17, F18, F19 on a Mac keyboard 2013-08-06 12:56:47 -07:00
Sam Lantinga
be0246d732 Added tag macosx_10_4_supported for changeset ccf5fbfa2afa 2013-08-06 01:19:23 -07:00
Ryan C. Gordon
6282a112e5 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.
2013-08-06 00:23:04 -04:00
Sam Lantinga
a0bac03105 Added scancodes for F13-F19 from a Mac USB keyboard 2013-08-05 11:45:51 -07:00
Philipp Wiesemann
8aa3fca78a 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
Philipp Wiesemann
c14d87dec4 Fixed volume keys not being handled by Android if screen keyboard is visible.
See bug #1569.
2013-08-04 23:28:34 +02:00
Sam Lantinga
a5641a9745 Fixed bug 1972 - Changeset 7379 (b27c778a2bdb) breaks make process with msys+mingw (make 3.82.90)
Andreas

With the patch applied, make is not able to find the rule for Makefile.in anymore. Removing the patch resolves the issue.

The path is in fact correct (in my case: /c/external/SDL64/SDL). But it seems the windows build of GNU Make doesn't work well with pathnames in rules. Both the dependencies in "$(srcdir)/configure: $(srcdir)/configure.in" and "Makefile: $(srcdir)/Makefile.in" will cause rules not to be found when srcdir is defined.

The same problem occurs if the patch is removed and I supply configure with a srcdir manually.
2013-08-04 09:37:27 -07:00
Sam Lantinga
c2d6d45a9f Added extra Visual C++ files to the ignore list 2013-08-04 09:35:35 -07:00
Sam Lantinga
2170675d1e 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
a55a716143 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
acff4dec41 Added missing return statement. 2013-08-03 23:40:28 +02:00
Philipp Wiesemann
54bd7cde7b 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
8d20160ad0 Fixes bug #1889, allows for GL Context deletion/recreation on Android
Thanks ny00!
2013-08-03 12:54:39 -03:00
Ryan C. Gordon
e623a7cea4 Some fixes for SDL_MaximizeWindow().
Fixes Bugzilla #1441.
2013-08-03 02:20:00 -04:00
Ryan C. Gordon
91068a6c21 Fixed some whitespace. 2013-08-02 18:25:20 -04:00
Gabriel Jacobo
4b9c3c0664 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
a082c12fd1 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
796b937fca 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
4af79f780e 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
Sam Lantinga
0e06fd2dfc More work on bug 1999, added missing CFBundleExecutable key to Info.plist 2013-07-31 21:31:23 -07:00
Ryan C. Gordon
260c212fd0 Move the fix for Bugzilla #1395 into WIN_GL_SetupWindow() directly.
It's a cleaner solution.
2013-08-01 00:27:22 -04:00
Sam Lantinga
e5aa1694db Documented why we have global and thread-local variables for the GL context. 2013-07-31 21:22:09 -07:00
Sam Lantinga
c7dfdbb52f Fixed bug 1569 - Android volume keys not honoured inside SDL
Joseba García Echebarria

The current version of SDL HG in Android doesn't do anything when volume keys are pressed.
The change makes SDL ignore volume keys so that they're handled by the OS and the sound volume can be changed within an app.
2013-07-31 21:08:22 -07:00
Ryan C. Gordon
5c921db1f1 Windows: Don't lose the existing current GL context in SDL_CreateWindow().
Fixes Bugzilla #1395.
2013-08-01 00:01:57 -04:00
Gabriel Jacobo
53cf4bf3c6 Set mAudioTrack to null when AudioTrack initialization fails
Prevents potential problems when stopping the app.
2013-07-31 16:25:50 -03:00
Edward Rudd
fb8455ec81 Further fix SIZEOF_VOIDP in SDL_config.h.in
The configure script was still overwriting SIZEOF_VOIDP so both ended up as either 4 or 8 depending on the arch.  This simply removes the check from configure.in
2013-07-31 12:13:26 -04:00
Ryan C. Gordon
6bcb92b468 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
b5b67aacf8 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
ccdd2f87a3 Fixed bug 2000 - The framework INSTALL_PATH still uses @executable_path
dak180

Since the MACOSX_DEPLOYMENT_TARGET is 10.5; INSTALL_PATH should use @rpath.

See http://www.dribin.org/dave/blog/archives/2009/11/15/rpath/ for the details on why this is a good idea.
2013-07-30 23:33:32 -07:00
Sam Lantinga
1a3a905aa9 Added code signature step to Framework build process 2013-07-30 21:39:38 -07:00
Sam Lantinga
94c6b39a04 Check for negative source rectangle in SDL_SoftBlit() (thanks John!) 2013-07-30 20:57:26 -07:00
Philipp Wiesemann
0f4de98390 Added support for the two new key codes from Android 4.3. 2013-07-30 23:24:23 +02:00
Sam Lantinga
ff814534d2 Fixed compiler warning with gcc 2013-07-30 00:02:45 -07:00
Sam Lantinga
a804c33317 Fixed stack smashing crash when using the GCC compiled DLL with Visual Studio. 2013-07-29 23:28:25 -07:00
Ryan C. Gordon
a164f89158 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
ff56141020 These should be __inline__, not inline. 2013-07-30 01:30:32 -04:00
Ryan C. Gordon
ece38070df 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
Sam Lantinga
1d3d9d10fb Added documentation saying the render API isn't for multi-threading. 2013-07-28 11:24:16 -07:00
Philipp Wiesemann
1de7a622ab Changed test program to be more compatible C. 2013-07-27 21:11:12 +02:00
Philipp Wiesemann
719f8227e0 Removed unused variable from test program. 2013-07-27 21:07:07 +02:00
Philipp Wiesemann
af2f530b05 Removed unused parameter in test program. 2013-07-27 21:05:04 +02:00
Philipp Wiesemann
81450906db Corrected words in comments of test programs. 2013-07-27 21:02:50 +02:00