Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support repeating textures with SDL_RenderGeometry #5369

Closed
wants to merge 1 commit into from

Conversation

jayschwa
Copy link
Contributor

@jayschwa jayschwa commented Feb 27, 2022

This pull request is in a draft state to solicit feedback from the maintainers on the overall design.

Description

This pull request would allow SDL_RenderGeometry to draw repeating texture patterns. The default clamped behavior is unchanged, but the user can enable repetition with SDL_SetTextureWrapMode(texture, SDL_WRAPMODE_REPEAT).

My editor also automatically trimmed some trailing white space in the files I updated.

TODO

  • Decide if wrap mode should be per-axis.
  • Add a test for exercising the new functionality.
  • Add wrap mode support to the renderers I am capable of testing (probably GLES and software).
  • Beef up documentation so it's clear that wrap mode only applies to SDL_RenderGeometry for now.

Existing Issue(s)

This would partially implement #4820.

@dingogames
Copy link

I was just working on the same feature for my own use.
On the question of per-axis wrapping. I'm trying to replicate other 2d APIs that I have used, they didn't support per-axis. I also don't need it for my purposes. Not sure if other people would want per-axis. Another question is whether or not to include mirrored repeating (again, personally I don't need it).

Here's my implementation of it. I did an OpenGL and DirectX implementation (they seem to work but I'm pretty inexperienced working with these)
dingogames@32b1ed1

@slouken
Copy link
Collaborator

slouken commented Nov 23, 2022

We think this is a good idea for SDL 3.0.

@ell1e
Copy link
Contributor

ell1e commented Mar 10, 2024

For what it's worth, maybe a third mode of SDL_WRAPMODE_AUTO could be introduced as I suggested here to add this in to both maintain backward compatibility and still allow rendering past 0-to-1 coordinates at the same time. It would check at the beginning of the render call if the coordinates fall into 0-to-1 range and if yes, use SDL_WRAPMODE_CLAMP for the draw call, otherwise SDL_WRAPMODE_REPEAT.

As a side note, I think storing this per texture seems slightly inflexible for some use cases, although I suppose people can just change it on the texture to be rendered before each draw call if that's supported. However, that might prevent SDL from internally reordering or grouping the draw calls in some way that optimizes performance if that was ever desired.

slouken added a commit to slouken/SDL that referenced this pull request Jul 18, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
slouken added a commit to slouken/SDL that referenced this pull request Jul 20, 2024
Currently wrapping is based on whether texture coordinates are outside of [0,1], but the code is structured so it's easy to add an API to set it and add additional wrapping modes if we want.

Fixes libsdl-org#9238
Closes libsdl-org#5369
@slouken slouken closed this in 03bb2c1 Jul 20, 2024
@slouken
Copy link
Collaborator

slouken commented Jul 20, 2024

I went ahead and added the functionality you're asking for here. I didn't expose the wrap mode to the API yet, as I'm not sure that's needed, but if we want it, we can merge #10328.

@jayschwa jayschwa deleted the render-wrap-mode branch October 13, 2024 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants