Commit Graph

1465 Commits

Author SHA1 Message Date
Sam Lantinga 5bf6bc4d7d Renamed SDL_Get/SetProperty() to SDL_Get/SetPointerProperty()
This is consistent with the naming for the functions that affect other data types

Fixes https://github.com/libsdl-org/SDL/issues/10241
2024-07-12 10:41:02 -07:00
Anonymous Maarten ca36f6c43b sdlprocdump: remove dead code 2024-07-12 18:38:03 +02:00
Anonymous Maarten 40f9fd854f test: use SDL_HINT_(AUDIO,VIDEO)_DRIVER macro 2024-07-11 23:37:11 +02:00
Ethan Lee 5d506a53a6 testvulkan: Add call to SDL_Vulkan_GetPresentationSupport 2024-07-11 15:00:59 -04:00
Sam Lantinga 875c4f0a4c Support indexed surfaces without palettes (thanks @sulix!)
Currently, all SDL_Surfaces with an indexed pixel format have an
associated SDL_Palette. This palette either consists of entirely the
colour black, or -- in the special case of 1-bit surfaces, black and
white.

When an indexed surface is blitted to another indexed surface, a 'map'
is generated from the source surface's palette to the destination
surfaces palette, in order to preserve the look of the image if the
palettes differ.

However, in most cases, applications will want to blit the raw index
values, rather than translate to make the colours as similar as
possible. For instance, the destination surface's palette may have been
modified to fade the screen out.

This change allows an indexed surface to have no associated palette. If
either the source or destination surface of a blit do not have a
palette, then the raw indices are copied (assuming both have an indexed
format).

This mimics better what happens with most other APIs (such as
DirectDraw), where most users do not set a palette on any surface but
the screen, whose palette is implicitly used for the whole application.
2024-07-11 08:31:32 -07:00
Anonymous Maarten 131108ee48 Remove references to SDL_CreatePixelFormat and SDL_DestroyPixelFormat 2024-07-11 08:12:42 -07:00
David Gow 540a356199 test: Add testspritesurface
This is a cut-down version of testsprite which uses SDL_Surface (and
SDL_GetWindowSurface), instead of the Render API. It's useful for
quickly validating that blitting works, including some basic format
conversion (with a palette).

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-07-11 08:11:29 -07:00
Sam Lantinga 0b2c80557c Update the blit mapping when the palette is set on a surface
Make sure you do this even if the palette pointer hasn't changed, as the contents may have.

Fixes https://github.com/libsdl-org/SDL/issues/10225
2024-07-10 23:22:06 -07:00
Ryan C. Gordon af2dbf3ff3 video: Rename SDL_GL_DeleteContext to SDL_GL_DestroyContext.
Turns out that there isn't a strong OpenGL naming convention for "Delete" ...
WGL offers "wglDeleteContext" but the GLX equivalent is "glxDestroyContext"
and then EGL sealed the deal by going with Destroy as well! Since it matches
SDL3 naming conventions (Create/Destroy), we're renaming it.

Fixes #10197.
2024-07-10 15:54:08 -04:00
Ryan C. Gordon 4755055bc3 audio: Separate channel maps out of SDL_AudioSpec. 2024-07-10 15:43:57 -04:00
Sam Lantinga 2ba76dbe80 Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure.

The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect().

SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types.

SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value.

SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
2024-07-10 00:48:18 -07:00
Brick 43a5da358d Set ALLOWABLE_ERROR_BLENDED to 0 2024-07-08 20:59:42 +01:00
Anonymous Maarten 1cddc7b66e sdlprocdump: exceptions are not handled 2024-07-08 21:30:49 +02:00
Anonymous Maarten c4cbbca185 sdlprocdump: ignore C++ exceptions 2024-07-08 20:48:33 +02:00
Sam Lantinga d6c8485f28 Make sure we're actually running on Windows before using D3D renderers 2024-07-08 11:36:11 -07:00
Sam Lantinga 4d5f139f0f Add the blit automation tests 2024-07-08 10:58:48 -07:00
Isaac Aronson 3ecb927587 Remove last non-SDL types from test 2024-07-08 10:53:46 -07:00
Isaac Aronson adca9d408e Fixup tests to use correct types 2024-07-08 10:53:46 -07:00
Isaac Aronson f5ee88c2cf Implement mathematically correct scalar blitters 2024-07-08 10:53:46 -07:00
Isaac Aronson f0238ef615 Fix build issues 2024-07-08 10:53:46 -07:00
Isaac Aronson 594ca1a897 Add testautomation suite for alpha blending 2024-07-08 10:53:46 -07:00
Sam Lantinga 4fa5196820 Revert "Switch pixel format loss fields to number of bits"
This reverts commit 3c90b1c1f6.

It turns out this is problematic for sdl2-compat. We're investigating a more complete separation between SDL2 and SDL3 surfaces, but in the meantime, I'll fix the breakage.
2024-07-07 19:41:05 -07:00
Anonymous Maarten 18c9bd21b5 sdlprocdump: become C90 compatible 2024-07-07 21:18:16 +02:00
Sam Lantinga 3c90b1c1f6 Switch pixel format loss fields to number of bits
This makes more sense and handles pixel formats with > 8 bits per channel

Fixes https://github.com/libsdl-org/SDL/issues/10168
2024-07-06 11:37:16 -07:00
Anonymous Maarten be43dec798 sdlprocdump: store context and exception record in minidump 2024-07-06 17:36:16 +02:00
Ryan C. Gordon 2a8f1e11ca audio: Add gain support to audio streams and logical audio devices.
Fixes #10028.
2024-07-03 16:05:55 -04:00
Ryan C. Gordon 16e7fdc4f2 audio: Add channel remapping to SDL_AudioSpec and SDL_AudioStream.
Fixes #8367.
2024-07-03 14:38:33 -04:00
Ryan C. Gordon 0367f1af19 loopwave: Use SDL_ResumeAudioStreamDevice.
...instead of the more-wordy:

`SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));`
2024-07-03 14:38:33 -04:00
Sam Lantinga e8dbbf8380 Renamed SDLK_a-z to SDLK_A-Z
Made the symbols uppercase for consistency with the other SDLK_* constants, but the values are still lowercase.
2024-07-01 13:56:49 -07:00
Sam Lantinga d9dc4b320a The keycode in key events is the base, unmodified, keycode for the current keyboard layout 2024-07-01 13:56:49 -07:00
Anonymous Maarten 8290c4e82e sdlprocdump: also print a stacktrace on a fatal exception 2024-07-01 20:49:52 +02:00
Sam Lantinga 473257cce6 Added SDL_GetRenderLogicalPresentationRect()
Fixes https://github.com/libsdl-org/SDL/issues/8815
2024-06-29 14:25:59 -07:00
Sam Lantinga a522bfe3f1 Clean up any renderer in SDL_DestroyWindowSurface()
Also added an automated test to verify window surface functionality.

Fixes https://github.com/libsdl-org/SDL/issues/10133
2024-06-29 10:47:28 -07:00
Sam Lantinga 6f199eabb8 Removed SDL_RenderGeometryRawFloat()
After discussion with @ocornut, SDL_RenderGeometryRaw() will take floating point colors and conversion from 8-bit color can happen on the application side.  We can always add an 8-bit color fast path in the future if we need it on handheld platforms.

If you need code to do this in your application, you can use the following:

int SDL_RenderGeometryRaw8BitColor(SDL_Renderer *renderer, SDL_Texture *texture, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
{
    int i, retval, isstack;
    const Uint8 *color2 = (const Uint8 *)color;
    SDL_FColor *color3;

    if (num_vertices <= 0) {
        return SDL_InvalidParamError("num_vertices");
    }
    if (!color) {
        return SDL_InvalidParamError("color");
    }

    color3 = (SDL_FColor *)SDL_small_alloc(SDL_FColor, num_vertices, &isstack);
    if (!color3) {
        return -1;
    }

    for (i = 0; i < num_vertices; ++i) {
        color3[i].r = color->r / 255.0f;
        color3[i].g = color->g / 255.0f;
        color3[i].b = color->b / 255.0f;
        color3[i].a = color->a / 255.0f;
        color2 += color_stride;
        color = (const SDL_Color *)color2;
    }

    retval = SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, sizeof(*color3), uv, uv_stride, num_vertices, indices, num_indices, size_indices);

    SDL_small_free(color3, isstack);

    return retval;
}

Fixes https://github.com/libsdl-org/SDL/issues/9009
2024-06-29 00:10:08 -07:00
Sam Lantinga 212a491f7c Renamed SDL_HINT_IME_NATIVE_UI to SDL_HINT_IME_IMPLEMENTED_UI
This inverts the logic to make more sense from an application perspective.
2024-06-28 19:41:37 -07:00
Sam Lantinga 4c7db129df SDL_HINT_IME_INTERNAL_EDITING and SDL_HINT_IME_SHOW_UI are replaced with SDL_HINT_IME_NATIVE_UI 2024-06-28 17:09:22 -07:00
Sam Lantinga bdd531986b SDL_SetTextInputRect() has been renamed to SDL_SetTextInputArea()
The new function includes the cursor position so IME UI elements can be placed relative to the cursor, as well as having the whole text area available so on-screen keyboards can avoid it.
2024-06-28 17:09:22 -07:00
Sam Lantinga ed2022a175 Added SDL_EVENT_TEXT_EDITING_CANDIDATES
This allows applications that have set SDL_HINT_IME_SHOW_UI to "0" to get candidates lists they can draw themselves.

Fixes https://github.com/libsdl-org/SDL/issues/4855
2024-06-28 17:09:22 -07:00
Sam Lantinga 8165e96514 Fixed whitespace 2024-06-27 18:35:12 -07:00
Sam Lantinga dcd7b4e497 testime: highlight selected clauses in Japanese composition mode 2024-06-27 17:43:03 -07:00
Sam Lantinga 50250adba7 testime: draw a blinking cursor at the text insertion point 2024-06-27 17:43:03 -07:00
Sam Lantinga 3d525331aa testime: add a 1 pixel border around glyphs to avoid texture sampling into other glyphs 2024-06-27 17:43:03 -07:00
Sam Lantinga 938c974cca testime: use a replacement character for characters not in the font 2024-06-27 17:43:03 -07:00
Sam Lantinga a67e6b80de Updated unifont to version 15.1.05 2024-06-27 17:43:03 -07:00
Sam Lantinga 50f50612bd Removed checkkeysthreads
It's out of date relative to the IME changes and doesn't add any value
2024-06-27 17:43:03 -07:00
Ryan C. Gordon 1e0ac5771a testiconv: Remove half-baked SDL_StepUTF8 testing code. 2024-06-27 17:36:09 -04:00
Ryan C. Gordon a9cfcf6bde stdinc: Drastically improve SDL_StepUTF8() and make it a public API.
Fixes #10105.
2024-06-27 17:36:09 -04:00
Ryan C. Gordon 9b8c5f642f
testaudio: Better fix for NULL dereference.
This code already handled NULL fine, it just got wrapped in a SDL_strdup call
in e23257307e, so make that SDL_strdup check for
NULL first.
2024-06-27 17:24:49 -04:00
Ryan C. Gordon 5631c6dbaa
testaudio: Don't crash if SDL_GetAudioDeviceName() returns NULL.
It definitely will for default devices, so this crash is real, but it's also
good defensive coding if something blows up unexpectedly.

Fixes #10130.
2024-06-27 17:20:11 -04:00
Ryan C. Gordon 982feb7a65 vulkan: SDL_Vulkan_CreateSurface now returns the usual int (0=ok, -1=error).
Fixes #10091.
2024-06-27 15:25:10 -04:00