Skip to content

Commit

Permalink
ScreenDrawing+Texture: Improve GUI sprite rendering
Browse files Browse the repository at this point in the history
- Fix choppiness from using int coordinates
- UV order is normalised and flipping is explicitly not supported
  • Loading branch information
Juuxel committed Sep 27, 2023
1 parent c8ef782 commit 60de29e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public static void texturedRect(DrawContext context, int x, int y, int width, in
if (Float.isInfinite(fullWidth) || Float.isInfinite(fullHeight)) break outer;

// Calculate the offset left/top coordinates.
int xo = x - (int) (fullWidth * texture.u1());
int yo = y - (int) (fullHeight * texture.v1());
float xo = x - fullWidth * Math.min(texture.u1(), texture.u2());
float yo = y - fullHeight * Math.min(texture.v1(), texture.v2());

MatrixStack matrices = context.getMatrices();
matrices.push();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
* and they need to be drawn with specific {@code Texture}-accepting methods
* or {@link net.minecraft.client.gui.DrawContext}.
*
* <p>GUI sprite textures don't currently support flipping the texture by flipping UV coordinates.
*
* @param image the image of this texture
* @param type the type of this texture
* @param u1 the start U-coordinate, between 0 and 1
Expand Down

0 comments on commit 60de29e

Please sign in to comment.