Deviation when drawing lines? (SOLVED)

Hello there!

When I tried to draw two lines that start from the same point using

msg.post('@render:', 'draw_line', ...)

I found that it didn’t act properly, as the following capture shows.

image

It appeared these two lines don’t start from the same point. What’s going on?

My script:

function update(self, dt)
	local p = vmath.vector3(100, 100, 0)
	msg.post('@render:', 'draw_line', {
		start_point = p,
		end_point = vmath.vector3(100, 300, 0),
		color = vmath.vector4(1, 1, 1, 1)
	})
	msg.post('@render:', 'draw_line', {
		start_point = p,
		end_point = vmath.vector3(300, 100, 0),
		color = vmath.vector4(1, 1, 1, 1)
	})
end
1 Like

It does look odd, I must admit.
We don’t do anything weird, just pass those coordinates to the vertices.

Historically, the LINE primitive in OpenGL has had various support issues (different drivers doing different things), and is one of the reasons we only recommend using this for debug purposes.

Here’s what it looks like for me on OSX:
21

What are you using it for, perhaps we can suggest another way of doing it?

Also, a releveant extension for you might be the Draw Pixels extension.

2 Likes

Thanks for your reply.

What I want to do is simply to draw a perfect square, and the width of the square’s border measures 1px.

And yes, Draw Pixels could help me!

1 Like