LWJGL 3 Line Positioning issues

Started by GiantNuker, September 29, 2017, 18:28:30

Previous topic - Next topic

GiantNuker

My lines for my checkbox check vary with position, Here is one at (50, 70)

And here is one at (10, 70)


My Code:

CheckBox render method:
Lines 11 & 12 have check drawing code.
@Override
	public void render() {
		GLDrawHelper.color(borderColor);
		GLDrawHelper.drawRect(area);
		ScreenRect2D area2 = area.subtract(2);
		GLDrawHelper.color(color);
		GLDrawHelper.drawRect(area2);
		if (pressed) {
			ScreenRect2D area3 = area2.subtract(2);
			GLDrawHelper.color(pressedColor); //from here
			GLDrawHelper.drawLine(area3.getUpperRight(), area3.getLowerLeft().add(area3.getLowerLeft().x / 2, 0));
			GLDrawHelper.drawLine(area3.getLowerLeft().add(area3.getLowerLeft().x / 2, 0), area3.getUpperLeft().subtract(0, (area3.getLowerLeft().y / 4) - area3.getUpperLeft().y / 2));//to here
		}
		GLDrawHelper.color(Color.BLACK);
		GLDrawHelper.drawString(text, area.getLowerLeft().subtract(0, area.getHeight() / 2).subtract(-15, GLDrawHelper.getHeight(text, scale) * 2), scale);
	}

GLDrawHelper drawLine
public static void drawLine(ScreenPos2D pos1, ScreenPos2D pos2) {
		GL11.glBegin(GL11.GL_LINES);
		GL11.glVertex2d(pos1.x, pos1.y);
		GL11.glVertex2d(pos2.x, pos2.y);
		GL11.glEnd();
	}

ScreenRect2D(area)
public class ScreenRect2D {
	public ScreenPos2D min, max;
	public ScreenRect2D(ScreenPos2D min, ScreenPos2D max) {
		this.min = min;
		this.max = max;
	}
	public ScreenRect2D(double minX, double minY, double maxX, double maxY) {
		this(new ScreenPos2D(minX, minY), new ScreenPos2D(maxX, maxY));
	}
	public boolean isInRect(double x, double y) {
		return (x >= min.x) && (x <= max.x) && (y >= min.y) && (y <= max.y);
	}
	public ScreenPos2D getUpperLeft() {
		return min;
	}
	public ScreenPos2D getUpperRight() {
		return new ScreenPos2D(max.x, min.y);
	}
	public ScreenPos2D getLowerLeft() {
		return new ScreenPos2D(min.x, max.y);
	}
	public ScreenPos2D getLowerRight() {
		return max;
	}
	public double getHeight() {
		return max.y - min.y;
	}
	public double getWidth() {
		return max.x - min.x;
	}
	public ScreenRect2D add(double amount) {
		return new ScreenRect2D(min.subtract(amount, amount), max.add(amount, amount));
	}
	public ScreenRect2D subtract(double amount) {
		return add(-amount);
	}
}

ScreenPos2D(min & max)
public class ScreenPos2D {
	public double x, y;
	public ScreenPos2D(double minX, double minY) {
		this.x = minX;
		this.y = minY;
	}
	public ScreenPos2D add(double x, double y) {
		return new ScreenPos2D(this.x + x, this.y + y);
	}
	public ScreenPos2D add(ScreenPos2D pos) {
		return add(pos.x, pos.y);
	}
	public ScreenPos2D subtract(ScreenPos2D pos) {
		return add(-pos.x, -pos.y);
	}
	public ScreenPos2D subtract(double x, double y) {
		return add(-x, -y);
	}
}
I am new to LWJGL and I probably need help. ???

Please help me! :)