4646import static org .lwjgl .opengl .GL13 .GL_ACTIVE_TEXTURE ;
4747import static org .lwjgl .opengl .GL13 .GL_TEXTURE0 ;
4848
49+ //#if MC>=12111
50+ //$$ import com.mojang.blaze3d.textures.FilterMode;
51+ //#endif
52+
4953//#if MC>=12109
5054//$$ import net.minecraft.client.font.TextDrawable;
5155//$$ import net.minecraft.text.StyleSpriteSource;
@@ -519,9 +523,12 @@ public static void bindTexture(ResourceLocation resourceLocation) {
519523 }
520524 //#endif
521525
526+ @ Deprecated // see UGraphics.Globals
522527 public static void bindTexture (int index , int glTextureId ) {
523528 //#if STANDALONE
524529 //$$ configureTextureUnit(index, () -> glBindTexture(GL_TEXTURE_2D, glTextureId));
530+ //#elseif MC>=12111
531+ //$$ throw new UnsupportedOperationException("No longer supported on 1.21.11+, use `UBufferBuilder`/`URenderPipeline` instead.");
525532 //#elseif MC>=12106
526533 //$$ RenderSystem.setShaderTexture(index, RenderSystem.getDevice().createTextureView(new UnownedGlTexture(glTextureId)));
527534 //#elseif MC>=12105
@@ -534,6 +541,7 @@ public static void bindTexture(int index, int glTextureId) {
534541 }
535542
536543 //#if !STANDALONE
544+ @ Deprecated // see UGraphics.Globals
537545 public static void bindTexture (int index , ResourceLocation resourceLocation ) {
538546 bindTexture (index , getOrLoadTextureId (resourceLocation ));
539547 }
@@ -687,8 +695,13 @@ public static void drawString(UMatrixStack stack, String text, float x, float y,
687695 //$$ try (URenderPass renderPass = new URenderPass()) {
688696 //$$ renderPass.draw(UBuiltBuffer.wrap(builtBuffer), URenderPipeline.wrap(pipeline), builder -> {
689697 //$$ RenderPass mcRenderPass = ((URenderPass.DrawCallBuilderImpl) builder).getMc();
690- //$$ mcRenderPass.bindSampler("Sampler0", texture);
691- //$$ mcRenderPass.bindSampler("Sampler2", lightTexture);
698+ //#if MC>=12111
699+ //$$ mcRenderPass.bindTexture("Sampler0", texture, RenderSystem.getSamplerCache().get(FilterMode.NEAREST));
700+ //$$ mcRenderPass.bindTexture("Sampler2", lightTexture, RenderSystem.getSamplerCache().get(FilterMode.LINEAR));
701+ //#else
702+ //$$ mcRenderPass.bindSampler("Sampler0", texture);
703+ //$$ mcRenderPass.bindSampler("Sampler2", lightTexture);
704+ //#endif
692705 //$$ return kotlin.Unit.INSTANCE;
693706 //$$ });
694707 //$$ }
@@ -705,7 +718,11 @@ public static void drawString(UMatrixStack stack, String text, float x, float y,
705718 //$$ }
706719 //$$ drawable.render(matrix, bufferBuilder, LIGHT, false);
707720 //$$ }
721+ //#if MC>=12111
722+ //$$ @Override public void drawGlyph(TextDrawable.DrawnGlyphRect glyph) { draw(glyph); }
723+ //#else
708724 //$$ @Override public void drawGlyph(TextDrawable drawable) { draw(drawable); }
725+ //#endif
709726 //$$ @Override public void drawRectangle(TextDrawable drawable) { draw(drawable); }
710727 //#else
711728 //$$ private void setupBuffer(BakedGlyph bakedGlyph) {
@@ -1028,6 +1045,10 @@ public static void disableScissor() {
10281045
10291046 public enum DrawMode {
10301047 LINES (GL11 .GL_LINES ),
1048+ /**
1049+ * @deprecated No longer properly supported as of 1.21.11, use {@link #LINES} instead
1050+ */
1051+ @ Deprecated
10311052 LINE_STRIP (GL11 .GL_LINE_STRIP ),
10321053 TRIANGLES (GL11 .GL_TRIANGLES ),
10331054 TRIANGLE_STRIP (GL11 .GL_TRIANGLE_STRIP ),
@@ -1059,7 +1080,11 @@ public enum DrawMode {
10591080 //$$ private static VertexFormat.DrawMode glToMcDrawMode(int glMode) {
10601081 //$$ switch (glMode) {
10611082 //$$ case GL11.GL_LINES: return VertexFormat.DrawMode.LINES;
1062- //$$ case GL11.GL_LINE_STRIP: return VertexFormat.DrawMode.LINE_STRIP;
1083+ //#if MC>=12111
1084+ //$$ case GL11.GL_LINE_STRIP: return VertexFormat.DrawMode.DEBUG_LINE_STRIP;
1085+ //#else
1086+ //$$ case GL11.GL_LINE_STRIP: return VertexFormat.DrawMode.LINE_STRIP;
1087+ //#endif
10631088 //$$ case GL11.GL_TRIANGLES: return VertexFormat.DrawMode.TRIANGLES;
10641089 //$$ case GL11.GL_TRIANGLE_STRIP: return VertexFormat.DrawMode.TRIANGLE_STRIP;
10651090 //$$ case GL11.GL_TRIANGLE_FAN: return VertexFormat.DrawMode.TRIANGLE_FAN;
@@ -1071,7 +1096,11 @@ public enum DrawMode {
10711096 //$$ private static DrawMode fromMc(VertexFormat.DrawMode mcMode) {
10721097 //$$ switch (mcMode) {
10731098 //$$ case LINES: return DrawMode.LINES;
1074- //$$ case LINE_STRIP: return DrawMode.LINE_STRIP;
1099+ //#if MC>=12111
1100+ //$$ case DEBUG_LINE_STRIP: return DrawMode.LINE_STRIP;
1101+ //#else
1102+ //$$ case LINE_STRIP: return DrawMode.LINE_STRIP;
1103+ //#endif
10751104 //$$ case TRIANGLES: return DrawMode.TRIANGLES;
10761105 //$$ case TRIANGLE_STRIP: return DrawMode.TRIANGLE_STRIP;
10771106 //$$ case TRIANGLE_FAN: return DrawMode.TRIANGLE_FAN;
@@ -1543,7 +1572,7 @@ public UGraphics light(int u, int v) {
15431572 return this ;
15441573 }
15451574
1546- //#if MC>=12105 && !STANDALONE
1575+ //#if MC>=12105 && MC<12111
15471576 //$$ private static class UnownedGlTexture extends GlTexture {
15481577 //$$ public UnownedGlTexture(int glId) {
15491578 //#if MC>=12106
@@ -1606,6 +1635,8 @@ public static void scale(double x, double y, double z) {
16061635 * {@code RenderSystem.setShaderTexture}, but just like the vanilla {@code RenderPipeline},
16071636 * {@code URenderPipeline} also requires textures to be set explicitly, despite {@code UGraphics.bindTexture} not
16081637 * yet being deprecated (because it's still used for {@code RenderLayer}).
1638+ * <br>
1639+ * Update: As of 1.21.11, {@code UGraphics.bindTexture} is now deprecated too.
16091640 * <p>
16101641 * If you need to still use the old global state on versions prior to 1.21.5, you may use the methods declared in
16111642 * this class. They are functionally identical to the ones in UGraphics but are not deprecated with the
@@ -1691,5 +1722,17 @@ public UGraphics beginWithDefaultShader(DrawMode mode, VertexFormat format) {
16911722 }
16921723 //#endif
16931724 //#endif
1725+
1726+ //#if MC<12111 || STANDALONE
1727+ public static void bindTexture (int index , int glTextureId ) {
1728+ UGraphics .bindTexture (index , glTextureId );
1729+ }
1730+
1731+ //#if !STANDALONE
1732+ public static void bindTexture (int index , ResourceLocation resourceLocation ) {
1733+ UGraphics .bindTexture (index , resourceLocation );
1734+ }
1735+ //#endif
1736+ //#endif
16941737 }
16951738}
0 commit comments