Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antialiased lines #3082

Closed
sonoro1234 opened this issue Mar 29, 2020 · 3 comments
Closed

antialiased lines #3082

sonoro1234 opened this issue Mar 29, 2020 · 3 comments

Comments

@sonoro1234
Copy link

sonoro1234 commented Mar 29, 2020

Version: 1.75
Branch: master

Back-ends: glfw and opengl3 from cimgui

Operating System: widows7

I dont get antialiased lines with this code

local points = {}
local pointsI 
function GL.imgui()
	local igio = ig.GetIO()
	local mpos = igio.MousePos
	local dl = ig.GetForegroundDrawList()
	dl.Flags = bit.bor(dl.Flags,ig.lib.ImDrawListFlags_AntiAliasedLines)

	if igio.MouseClicked[0] then
		points[#points+1]= ig.ImVec2(GL:ScreenToViewport(mpos.x, mpos.y))
		pointsI = ffi.new("ImVec2[?]",#points)
	end

	for i=1,#points do 
		pointsI[i-1] = ig.ImVec2(GL:ViewportToScreen(points[i].x,points[i].y))
		dl:AddCircleFilled(pointsI[i-1], 4, ig.U32(1,0,0,1))
	end
	dl:AddPolyline(pointsI,#points,ig.U32(1,1,0,1),true, 2)
end

GIF

am I doing something wrong?

My second question would be: Is there any workaround to avoid converting coordinates from viewport space to screen space every frame?
(As in my framework anima there are both reference spaces where viewport is a fixed size FBO centered in a variable screen (window) size)

@ocornut
Copy link
Owner

ocornut commented Mar 29, 2020

Acute angles are wrongly rendering, see #2183, #2964

Is there any workaround to avoid converting coordinates from viewport space to screen space every frame?

Use ImDrawList callbacks to pass e.g. projection matrixes to your custom rendering loop, and apply those projection in the render loop.

@ocornut ocornut closed this as completed Mar 29, 2020
@sonoro1234
Copy link
Author

Use ImDrawList callbacks to pass e.g. projection matrixes to your custom rendering loop, and apply those projection in the render loop.

There is still to few information for me in:
https://github.com/ocornut/imgui/search?q=%22ImDrawList+callbacks%22&unscoped_q=%22ImDrawList+callbacks%22&type=Issues

May be some day we have a worked example?

@ocornut
Copy link
Owner

ocornut commented Mar 29, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants