Jump to content

Recommended Posts

Posted

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?

Posted

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).

Posted

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.

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.