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

The drawing order of tooltips is incorrect #543

Closed
BloCamLimb opened this issue Jun 8, 2024 · 1 comment · Fixed by #548
Closed

The drawing order of tooltips is incorrect #543

BloCamLimb opened this issue Jun 8, 2024 · 1 comment · Fixed by #548
Labels
bug Something isn't working

Comments

@BloCamLimb
Copy link

Describe the bug

Tooltips have transparency and its Z value is 400, if the tooltip is drawn first, then all the elements that are drawn later will be discarded by depth test. So you cannot draw tooltips immediately before all elements with Z<400 are drawn.

public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
graphics.blit(getTextureIdentifier(), getX(), getY(), 238, isHovered ? 35 : 16, WIDTH, HEIGHT);
graphics.blit(
getTextureIdentifier(),
getX() + 1,
getY() + 1,
getXTexture(),
getYTexture(),
WIDTH - 2,
HEIGHT - 2
);
if (isHovered) {
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f);
graphics.blit(getTextureIdentifier(), getX(), getY(), 238, 54, WIDTH, HEIGHT);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
Platform.INSTANCE.renderTooltip(graphics, buildTooltip(), mouseX, mouseY);
}
if (warning != null) {
renderWarning(graphics);
}
}

Screen#setTooltipForNextRenderPass is the right way to go. Please refer to this issue for a detailed explanation BloCamLimb/ModernUI#216

How can we reproduce this bug or crash?

The issue is just there, Platform.INSTANCE.renderTooltip(graphics, buildTooltip(), mouseX, mouseY); should not be called at that time.

public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
graphics.blit(getTextureIdentifier(), getX(), getY(), 238, isHovered ? 35 : 16, WIDTH, HEIGHT);
graphics.blit(
getTextureIdentifier(),
getX() + 1,
getY() + 1,
getXTexture(),
getYTexture(),
WIDTH - 2,
HEIGHT - 2
);
if (isHovered) {
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f);
graphics.blit(getTextureIdentifier(), getX(), getY(), 238, 54, WIDTH, HEIGHT);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
Platform.INSTANCE.renderTooltip(graphics, buildTooltip(), mouseX, mouseY);
}
if (warning != null) {
renderWarning(graphics);
}
}

What Minecraft version is this happening on?

Minecraft 1.20.4

What NeoForge or Fabric version is this happening on?

The latest version at this moment

What Refined Storage version is this happening on?

The latest version at this moment

Relevant log output

No response

@BloCamLimb BloCamLimb added the bug Something isn't working label Jun 8, 2024
@raoulvdberge raoulvdberge added this to the v2.0.0-milestone.3 milestone Jun 8, 2024
@raoulvdberge raoulvdberge moved this from Todo to In Progress in Refined Storage 2 Jun 9, 2024
@raoulvdberge
Copy link
Contributor

Thanks for reporting back, this will be fixed for mc 1.20.4.

raoulvdberge added a commit that referenced this issue Jun 9, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Refined Storage 2 Jun 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants