Commit Graph

178 Commits

Author SHA1 Message Date
Sam Lantinga
5e513ecc7f Don't automatically free temporary memory, let the application call SDL_FreeTemporaryMemory() when it's ready.
Also mark up all functions that return temporary memory with SDL_DECLSPEC_TEMP, to help people implementing language bindings.

Fixes https://github.com/libsdl-org/SDL/issues/10378
2024-07-26 10:05:03 -07:00
SDL Wiki Bot
ba8495c214 Sync SDL3 wiki -> header 2024-07-25 00:41:44 +00:00
Sam Lantinga
cf8b158ccb Added SDL_GetRenderSafeArea() 2024-07-24 17:40:41 -07:00
Sam Lantinga
c4bf5f9f59 SDL_CreateTexture() uses the SDL_TextureAccess type for the access parameter 2024-07-22 09:32:02 -07:00
SDL Wiki Bot
979c71b18b Sync SDL3 wiki -> header 2024-07-21 01:22:39 +00:00
Sam Lantinga
6209c71f54 Added SDL_BlitSurface9Grid() and SDL_RenderTexture9Grid() 2024-07-20 18:21:19 -07:00
Sam Lantinga
198caa54a1 Added SDL_RenderTextureTiled() 2024-07-20 18:21:19 -07:00
SDL Wiki Bot
975457cfb6 Sync SDL3 wiki -> header 2024-07-19 19:23:24 +00:00
Sam Lantinga
71a60d4c0e Updated documentation for functions that return temporary memory 2024-07-19 12:22:03 -07:00
Sam Lantinga
637e9700dd Standardize placement of '*' in function declarations
Implemented using these sed commands on the headers:
sed -E -i'' '/SDLCALL|;/ s,([a-z])\* ,\1 *,g' *
sed -E -i'' 's,(\(.*[^\*])\* ([a-z])(.*\)),\1*\2\3,g' *
sed -E -i'' 's,\*const,* const,g' *
sed -E -i'' 's,\*SDLCALL,* SDLCALL,g' *
sed -E -i'' 's,void\(,void (,g' *
git checkout *gl*
2024-07-19 12:22:03 -07:00
Sam Lantinga
217330a7b3 Made return value descriptions more consistent across the API 2024-07-19 12:22:03 -07:00
Sam Lantinga
d73c7311d5 Clarify that the SDL_GetStringRule means that SDL will automatically free the memory later. 2024-07-19 12:22:03 -07:00
Sam Lantinga
5f5e91eab6 Reverted 3d2e5a0b66
Applying these changes to external code doesn't actually improve anything, and within the context of the other Get* functions for renderers and surfaces, these stand out as outliers, so I'm going to back this change out.
2024-07-17 10:27:37 -07:00
Sam Lantinga
3d2e5a0b66 Fixed a few remaining functions to directly return their values instead of an error code. 2024-07-16 21:32:17 -07:00
SDL Wiki Bot
9406a9d527 Sync SDL3 wiki -> header 2024-07-14 23:42:33 +00:00
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
SDL Wiki Bot
fdc04708f1 Sync SDL3 wiki -> header 2024-07-10 07:48:48 +00: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
SDL Wiki Bot
d5a0f60963 Sync SDL3 wiki -> header 2024-07-05 15:59:26 +00:00
Sam Lantinga
8412f52853 Clarified that the renderer should be destroyed before the window
I didn't add a note to SDL_DestroyWindow() because we actually protect against this case now, but it's useful information to know conceptually when working with the renderer.
2024-07-05 08:57:30 -07:00
SDL Wiki Bot
ede4483420 Sync SDL3 wiki -> header 2024-06-29 21:26:31 +00: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
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
SDL Wiki Bot
ab98d51b9f Sync SDL3 wiki -> header 2024-06-19 14:15:46 +00:00
Hubert Maier
81d8fcb5d8
JANITORIAL: Fix judgement typos (#10059) 2024-06-19 07:14:58 -07:00
Ryan C. Gordon
51902d4ac5
Updated headers with latest wikiheaders tweaks. 2024-06-14 02:09:55 -04:00
SDL Wiki Bot
674cc04ef4 Sync SDL3 wiki -> header 2024-06-13 02:25:45 +00:00
Sam Lantinga
80a907e0e6 Backed out the viewport and cliprect changes in 9fb5a9ccac
This ended up being lots of application code churn without any real benefit in practice.
2024-06-12 19:25:15 -07:00
SDL Wiki Bot
5b0f14a936 Sync SDL3 wiki -> header 2024-06-12 17:19:08 +00:00
Sam Lantinga
9fb5a9ccac Use floating point values for viewport, clip rectangle, and texture sizes
These are integer values internally, but the API has been changed to make it easier to mix other render code with querying those values.

Fixes https://github.com/libsdl-org/SDL/issues/7519
2024-06-12 10:18:39 -07:00
Sam Lantinga
9b2debb131 Renamed old function reference 2024-06-04 22:25:37 -07:00
SDL Wiki Bot
e5101ebae6 Sync SDL3 wiki -> header 2024-06-04 04:11:34 +00:00
Sam Lantinga
a0d1445ccb Replaced SDL_GetRendererInfo() with SDL_GetRendererName()
The texture formats are available via the SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER property

Fixes https://github.com/libsdl-org/SDL/issues/9851
2024-06-03 21:10:58 -07:00
Ryan C. Gordon
e23257307e Introduce formal policy for APIs that return strings.
This declares that any `const char *` returned from SDL is owned by SDL, and
promises to be valid _at least_ until the next time the event queue runs, or
SDL_Quit() is called, even if the thing that owns the string gets destroyed
or changed before then.

This is noted in the headers as "the SDL_GetStringRule", so this will both be
greppable to find a detailed explaination in docs/README-strings.md and
wikiheaders will automatically turn it into a link we can point at the
appropriate documentation.

Fixes #9902.

(and several FIXMEs, both known and yet-undocumented.)
2024-06-03 14:20:49 -04:00
Ryan C. Gordon
e508d82f74
include: Tweaked some vsync-related documentation.
Reference PR #9903.
2024-05-27 16:57:32 -04:00
Sam Lantinga
dfe4445214 Added SDL_SetWindowSurfaceVSync() and SDL_GetWindowSurfaceVSync()
Fixes https://github.com/libsdl-org/SDL/issues/9347
2024-05-27 13:12:17 -07:00
SDL Wiki Bot
6429806dce Sync SDL3 wiki -> header 2024-05-22 19:47:56 +00:00
SDL Wiki Bot
983544a53e Sync SDL3 wiki -> header 2024-05-22 00:41:09 +00:00
Sam Lantinga
6f2621438a Renamed DECLSPEC to SDL_DECLSPEC 2024-05-17 17:09:09 -07:00
Ryan C. Gordon
253c917296
SDL_render.h: Remove unnecessary struct x; before typedef struct x x;. 2024-05-16 12:21:14 -04:00
Ryan C. Gordon
5e6d85b8f0
wikiheaders: bridge wiki Category docs to the headers!
Did an initial cleanup on the headers and wrote a few pieces of documentation,
but this needs more work to fill out the documentation.
2024-05-16 11:48:23 -04:00
SDL Wiki Bot
c6354252a1 Sync SDL3 wiki -> header 2024-05-15 21:33:30 +00:00
Susko3
e6345716e0 Fix typo 2024-05-15 14:32:11 -07:00
Susko3
968e8c9275 Prefix names with SDL_RENDERER_ 2024-05-15 14:32:11 -07:00
Susko3
8d7f91f8e4 Add defined constants for renderer vsync values 2024-05-15 14:32:11 -07:00
SDL Wiki Bot
c7087fea01 Sync SDL3 wiki -> header 2024-05-13 22:07:34 +00:00
Sam Lantinga
17520c2e6e Removed SDL_RendererFlags
The flags parameter has been removed from SDL_CreateRenderer() and SDL_RENDERER_PRESENTVSYNC has been replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during window creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation.

SDL_SetRenderVSync() now takes additional values besides 0 and 1.

The maximum texture size has been removed from SDL_RendererInfo, replaced with SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER.
2024-05-13 15:06:11 -07:00
SDL Wiki Bot
06d6f2cb25 Sync SDL3 wiki -> header 2024-05-13 16:09:32 +00:00
Sam Lantinga
fc62dfc6e2 Added properties for the swap chain in the direct3d11 and direct3d12 renderers
Fixes https://github.com/libsdl-org/SDL/issues/9775
2024-05-13 09:06:57 -07:00
Sam Lantinga
598b4e0a1f Removed the limit on the number of supported renderer texture formats
Fixes https://github.com/libsdl-org/SDL/issues/9056
2024-05-09 13:30:07 -07:00