Created
August 18, 2020 03:53
-
-
Save TeamDman/29b8d520c8511dd36f3b73950755c9c0 to your computer and use it in GitHub Desktop.
Drawing transparent textures that are otherwise opqaue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void drawTextureRaw( | |
MatrixStack matrixStack, int x, int y, | |
int srcX, int srcY, int w, int h, int r, int g, int b, int a | |
) { | |
RenderSystem.enableBlend(); | |
RenderSystem.disableAlphaTest(); | |
Matrix4f matrix = matrixStack.getLast().getMatrix(); | |
int blitOffset = getBlitOffset(); | |
BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer(); | |
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); | |
bufferbuilder.pos(matrix, (float) x, (float) (y + h), (float) blitOffset) | |
.color(r,g,b,a) | |
.tex(((float) srcX + 0.0F) / (float) 256, ((float) srcY + (float) h) / (float) 256) | |
.endVertex(); | |
bufferbuilder.pos(matrix, (float) (x + w), (float) (y + h), (float) blitOffset) | |
.color(r,g,b,a) | |
.tex(((float) srcX + (float) w) / (float) 256, ((float) srcY + (float) h) / (float) 256) | |
.endVertex(); | |
bufferbuilder.pos(matrix, (float) (x + w), (float) y, (float) blitOffset) | |
.color(r,g,b,a) | |
.tex(((float) srcX + (float) w) / (float) 256, ((float) srcY + 0.0F) / (float) 256) | |
.endVertex(); | |
bufferbuilder.pos(matrix, (float) x, (float) y, (float) blitOffset) | |
.color(r,g,b,a) | |
.tex(((float) srcX + 0.0F) / (float) 256, ((float) srcY + 0.0F) / (float) 256) | |
.endVertex(); | |
bufferbuilder.finishDrawing(); | |
RenderSystem.enableAlphaTest(); | |
WorldVertexBufferUploader.draw(bufferbuilder); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment