Jump to content

GL11 lines flash between black and intended color


_NIMJA

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.