Best Image Scaling

This commit is contained in:
Kam committed 2025-02-06 15:55:21 -05:00
1 parent 3e6a5410ab
commit 328a3d4186
2 files changed
+21 -29

No files matched your search

@@ -66,26 +66,21 @@ public class GuiNpcSquareButton extends GuiNpcButton {
// --- Draw the icon ---
if (iconTexture != null) {
this.zLevel = 100.0F;
mc.getTextureManager().bindTexture(iconTexture);
GL11.glPushMatrix();
// Disable lighting so the icon is drawn at full brightness.
RenderHelper.disableStandardItemLighting();
// Set color to white
GL11.glColor4f(1F, 1F, 1F, 1F);
// Compute center of icon area.
float centerX = xPosition + size / 2.0F;
float centerY = yPosition + iconAreaHeight / 2.0F;
GL11.glTranslatef(centerX, centerY, 0F);
float scale = (float) iconAreaHeight / iconHeight;
// Scale so that original icon height maps to the icon area height.
float scale = (float) iconAreaHeight / (float) iconHeight; // iconHeight should be 24 now.
GL11.glScalef(scale, scale, 1F);
GL11.glTranslatef(-8F, -8F, 0F);
// Draw the icon (using stored UV coordinates)
GL11.glTranslatef(-iconWidth / 2.0F, -iconHeight / 2.0F, 0F);
this.drawTexturedModalRect(0, 0, iconPosX, iconPosY, iconWidth, iconHeight);
GL11.glPopMatrix();
this.zLevel = 0f;
}
// --- Draw the child text button ---