Skip to content

Commit

Permalink
fix: stop leaking gl state everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus8448 committed May 26, 2024
1 parent 88e796f commit ad39556
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 133 deletions.
5 changes: 5 additions & 0 deletions src/main/generated/assets/galacticraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
"death.attack.vine_poison": "%s succumbed to the poison of some vines",
"entity.galacticraft.arch_grey": "Arch Grey",
"entity.galacticraft.bubble": "Bubble",
"entity.galacticraft.buggy": "Buggy",
"entity.galacticraft.comet_cube": "Comet Cube",
"entity.galacticraft.evolved_creeper": "Evolved Creeper",
"entity.galacticraft.evolved_evoker": "Evolved Evoker",
Expand Down Expand Up @@ -541,6 +542,10 @@
"ui.galacticraft.celestialselection.cancel": "Cancel",
"ui.galacticraft.celestialselection.cannot_create_space_station": "Cannot Create Space Station",
"ui.galacticraft.celestialselection.catalog": "Catalog",
"ui.galacticraft.celestialselection.click_again": "Click again to zoom",
"ui.galacticraft.celestialselection.click_again.moons": "Click again to zoom (view moons)",
"ui.galacticraft.celestialselection.click_again.moons_and_satellites": "Click again to zoom (view moons & satellites)",
"ui.galacticraft.celestialselection.click_again.satellites": "Click again to zoom (view satellites)",
"ui.galacticraft.celestialselection.create_ss": "Create Space Station",
"ui.galacticraft.celestialselection.day_night_cycle": "Day/Night Cycle",
"ui.galacticraft.celestialselection.exit": "Exit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.serialization.Codec;
import dev.galacticraft.api.universe.display.CelestialDisplayType;
import dev.galacticraft.impl.universe.display.config.IconCelestialDisplayConfig;
Expand Down Expand Up @@ -67,7 +70,7 @@ public Vector4f render(GuiGraphics graphics, BufferBuilder buffer, int size, dou
config.decoration().ifPresent(decoration -> {
RenderSystem.setShaderTexture(0, decoration.texture());
float decoSize = size / 6.0F;
CelestialSelectionScreen.blit(positionMatrix, decoration.xScale() * decoSize, decoration.yScale() * decoSize, decoration.widthScale() * decoSize, decoration.heightScale() * decoSize, decoration.u(), decoration.v(), decoration.width(), decoration.height(), false, false, 32, 32);
CelestialSelectionScreen.blit(positionMatrix, decoration.xScale() * decoSize, decoration.yScale() * decoSize, decoration.widthScale() * decoSize, decoration.heightScale() * decoSize, decoration.u(), decoration.v(), decoration.width(), decoration.height(), 32, 32, 255, 255, 255, 255, false, false);
});

return new Vector4f(config.scale() * -size, config.scale() * -size, (config.scale() * size) * 2, (config.scale() * size) * 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;
import org.joml.Matrix4f;
Expand All @@ -47,6 +48,10 @@ public BatchedRenderer(BufferBuilder buffer, PoseStack pose, ResourceLocation te
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
}

public BatchedRenderer(GuiGraphics graphics, ResourceLocation texture, int textureWidth, int textureHeight) {
this(Tesselator.getInstance().getBuilder(), graphics.pose(), texture, textureWidth, textureHeight);
}

public void blit(int x, int y, int width, int height, float uOffset, float vOffset, int uWidth, int vHeight) {
blit(x, x + width, y, y + height, uWidth, vHeight, uOffset, vOffset);
}
Expand Down
Loading

0 comments on commit ad39556

Please sign in to comment.