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

LineWidth not working #207

Closed
tito opened this issue Jul 25, 2011 · 14 comments
Closed

LineWidth not working #207

tito opened this issue Jul 25, 2011 · 14 comments
Labels
Component: graphics kivy/graphics

Comments

@tito
Copy link
Member

tito commented Jul 25, 2011

jw_carleton reported that LineWidth instruction is not working:

   with self.canvas:
       LineWidth(5.0)
       points = [200, 0, 200, self.height]
       Line(points=points)
@hansent
Copy link
Contributor

hansent commented Sep 26, 2011

This is becasue we have linewidth set as context parameter, which we set as uniform in shader. However shader never uses the linewidth value. We can do one of two things I think:

  • put an if in context instrxution and check if state name is linewidth, and if so use glLineWidth
  • handle line width in shader, in this case, we should draw quads, instead of lines. and probably, we must do either a geometry shader to move vertices based on line width (can slow down pipeline?), or do something funky like index a linewidth texture or compute alpha in fragment shader (can give nice AA, not sure about speed/performance issue). Overall though, anyone implementing own shader must then also take care of this? Also not sure if we must draw lines sperately / with own shader / or how else to differentiate between line / other vertex in shader.

@hansent
Copy link
Contributor

hansent commented Sep 26, 2011

guess other option would be to remove LineWidth instruction, and add width parameter to Line instruction, and have the quads computed there, when points or width changes

@tito
Copy link
Member Author

tito commented Sep 26, 2011

The issue with quad is overlapping. draw a line on paper, and dilate it by hand. All the corner will by default overlap previous/next quad. How to avoid that ?

  1. stencil ?
  2. binary add op ? (=> then use of library for that ?)
  3. shader trick that i don't know about ?

@hansent
Copy link
Contributor

hansent commented Sep 26, 2011

make it shorter by 1/2 linewidth, and then draw 2 triangles to connect the lines. I.e. you have to draw the joints yourslef.

On Mon, Sep 26, 2011 at 1:14 PM, Mathieu Virbel
reply@reply.github.com
wrote:

The issue with quad is overlapping. draw a line on paper, and dilate it by hand. All the corner will by default overlap previous/next quad. How to avoid that ?

  1. stencil ?
  2. binary add op ? (=> then use of library for that ?)
  3. shader trick that i don't know about ?

Reply to this email directly or view it on GitHub:
https://github.com/tito/kivy/issues/207#issuecomment-2201554

@tito
Copy link
Member Author

tito commented Sep 26, 2011

Nop, cannot work => (1, 1, 2, 2, 3, 3) => nop. :)

@hansent
Copy link
Contributor

hansent commented Sep 26, 2011

vertices are float no? OpenGL should handle it still.

On Mon, Sep 26, 2011 at 2:52 PM, Mathieu Virbel
reply@reply.github.com
wrote:

Nop, cannot work => (1, 1, 2, 2, 3, 3) => nop. :)

Reply to this email directly or view it on GitHub:
https://github.com/tito/kivy/issues/207#issuecomment-2203051

@hansent
Copy link
Contributor

hansent commented Sep 26, 2011

@hansent
Copy link
Contributor

hansent commented Sep 26, 2011

I have C + glsl code from another project to draw very nice anti aliased lines with good joints. but I'm not sure about sure using seperate shader for specific instructions is good, since it will break when user set another shader.

@tito
Copy link
Member Author

tito commented Oct 14, 2011

That not working if you have alpha. Because you'll see the joint :/

@tito
Copy link
Member Author

tito commented Oct 14, 2011

I'll remove the instructions from Kivy right now, until we found a proper solution. Using an external shader might be overkill, but some people might want it.

tito added a commit that referenced this issue Oct 14, 2011
@jbrumberg
Copy link

Has there been any progress on this issue? It seemed like the glLineWidth option was the most straightforward, but the shader option was more popular. Is there an unknown difficulty with using glLineWidth? With either solution (context instruction or shader), will it be possible to add line width to a Bezier curve?

@tito
Copy link
Member Author

tito commented Apr 20, 2012

No, glLineWidth was the previous implementation, but it's not working under all the case, specially on mobile. This will work when somebody will start to implement a Path class, where you can add point, stoke, extrude etc. I did'nt started yet, time is missing... and it's quite a big part to implement :)

@jbrumberg
Copy link

Understood - thanks for the reply!

On Fri, Apr 20, 2012 at 7:50 PM, Mathieu Virbel
reply@reply.github.com
wrote:

No, glLineWidth was the previous implementation, but it's not working under all the case, specially on mobile. This will work when somebody will start to implement a Path class, where you can add point, stoke, extrude etc. I did'nt started yet, time is missing... and it's quite a big part to implement :)


Reply to this email directly or view it on GitHub:
#207 (comment)

@tshirtman
Copy link
Member

@tito I think this one can be closed :)

@tito tito closed this as completed Oct 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: graphics kivy/graphics
Projects
None yet
Development

No branches or pull requests

4 participants