Posted July 4, 20187 yr I'm trying to allow the user to set the color of the lines I'm rendering, but it behaves strangely. The color glitches between Black and the intended color, but mostly the lines are black. Here's the code I'm using to render the lines: Spoiler GL11.glPushMatrix(); GL11.glTranslated(-doubleX, -doubleY, -doubleZ); GL11.glColor3ub((byte)r, (byte)g, (byte)b); GL11.glLineWidth(ConfigOptions.LineWidth); GL11.glBegin(GL11.GL_LINES); for (BlockPos[] bp : lines) { BlockPos a1 = bp[0]; BlockPos b2 = bp[1]; GL11.glVertex3f(a1.getX(), height(a1), a1.getZ()); GL11.glVertex3f(b2.getX(), height(b2), b2.getZ()); } GL11.glEnd(); GL11.glPopMatrix(); Does anyone know how to make the lines stay the right color?
July 4, 20187 yr 2 hours ago, _NIMJA said: Does anyone know how to make the lines stay the right color? Where are you setting the color based on payer input? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 5, 20187 yr Author Here: GL11.glColor3ub((byte)r, (byte)g, (byte)b); r, g, and b are integers between 0 and 255.
July 5, 20187 yr 2 hours ago, _NIMJA said: Here: I meant where are r, g, and b being set in code. Also where is this code being ran. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 5, 20187 yr First off, you should really be using GlStateManager rather than direct GL11.* calls. Regarding your problem, a GlStateManager.disableTexture2d() call before you draw might help here (although I am speculating, admittedly).
July 5, 20187 yr Author R, g, and b are set just above the GL11 stuff. float r = ConfigOptions.LineColor.R; float g = ConfigOptions.LineColor.G; float b = ConfigOptions.LineColor.B; GL11.glPushMatrix(); GL11.glTranslated(-doubleX, -doubleY, -doubleZ); And here is the config rgb stuff: @Name("Line Color") @Comment("The color of the border line.") public static ColorCat LineColor = new ColorCat(); public static class ColorCat{ @RangeInt(min = 0, max = 255) @Comment("RGB red value.") public int R = 0; @RangeInt(min = 0, max = 255) @Comment("RGB green value.") public int G = 0; @RangeInt(min = 0, max = 255) @Comment("RGB blue value.") public int B = 255; } The code is being ran here: @SubscribeEvent public static void renderBlocks(DrawBlockHighlightEvent event){ } Changing to GlStateManager and adding the Texture2D thing helped! However, the line is about 50% transparent.
July 5, 20187 yr Sounds like blending is enabled. Try calling GlStateManager.disableBlend() before you do your line drawing. Or ensuring an alpha value of 1.0 is passed in your call toGlStateManager.color(...)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.