I can't set Line Width to 1 pixel

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

I can't set Line Width to 1 pixel

elect
Hello guys,

I'm trying to set some line loops to 1 pixel width, but I always get some antialiasing effect when the width number is an odd number

Here some example code:

                        gl2.glLineWidth(1.0f);
                        gl2.glBegin(GL2.GL_LINES);
                            gl2.glVertex2i(-10, 0);
                            gl2.glVertex2i(-10, 10);
                        gl2.glEnd();
                       
                        gl2.glLineWidth(2.0f);
                        gl2.glBegin(GL2.GL_LINES);
                            gl2.glVertex2i(-10, -10);
                            gl2.glVertex2i(-10, 0);
                        gl2.glEnd();
                       
                        gl2.glLineWidth(3.0f);
                        gl2.glBegin(GL2.GL_LINES);
                            gl2.glVertex2i(-10, -20);
                            gl2.glVertex2i(-10, -10);
                        gl2.glEnd();
                       
                        gl2.glLineWidth(4.0f);
                        gl2.glBegin(GL2.GL_LINES);
                            gl2.glVertex2i(-10, -30);
                            gl2.glVertex2i(-10, -20);
                        gl2.glEnd();
                       
                        gl2.glLineWidth(5.0f);
                        gl2.glBegin(GL2.GL_LINES);
                            gl2.glVertex2i(-10, -40);
                            gl2.glVertex2i(-10, -30);
                        gl2.glEnd();

produces this (in order from up to down):

http://dl.dropbox.com/u/1401029/LineWidth.png

gl2.glIsEnabled(GL2.GL_LINE_SMOOTH) returns false and gl2.glhint doesnt seem to affect it at all

any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: I can't set Line Width to 1 pixel

Wade Walker
Administrator
You might try querying the supported widths as described at http://www.opengl.org/wiki/GLAPI/glLineWidth. Implementations aren't required to support non-antialiased line widths greater than 1.
Reply | Threaded
Open this post in threaded view
|

Re: I can't set Line Width to 1 pixel

elect
Wade Walker wrote
You might try querying the supported widths as described at http://www.opengl.org/wiki/GLAPI/glLineWidth. Implementations aren't required to support non-antialiased line widths greater than 1.

                      float[] b = new float[2];

                        gl2.glGetFloatv(GL2.GL_ALIASED_LINE_WIDTH_RANGE, b, 0);
                        System.out.println("b[0]: "+b[0]+" b[1]: "+b[1]);
                        gl2.glGetFloatv(GL2.GL_SMOOTH_LINE_WIDTH_RANGE, b, 0);
                        System.out.println("b[0]: "+b[0]+" b[1]: "+b[1]);
                        gl2.glGetFloatv(GL2.GL_SMOOTH_LINE_WIDTH_GRANULARITY, b, 0);
                        System.out.println("b[0]: "+b[0]);


b[0]: 1.0 b[1]: 10.0
b[0]: 0.5 b[1]: 10.0
b[0]: 0.125
Reply | Threaded
Open this post in threaded view
|

Re: I can't set Line Width to 1 pixel

Wade Walker
Administrator
Very strange that the anti-aliasing would be width-dependent... do you have multisampling AA turned on, by any chance?
Reply | Threaded
Open this post in threaded view
|

Re: I can't set Line Width to 1 pixel

elect
Wade Walker wrote
Very strange that the anti-aliasing would be width-dependent... do you have multisampling AA turned on, by any chance?

Where do you mean exactly?
Reply | Threaded
Open this post in threaded view
|

Re: I can't set Line Width to 1 pixel

Wade Walker
Administrator
I mean, have you got full-screen antialiasing turned on via ARB_multisample (defined at http://www.opengl.org/registry/specs/ARB/multisample.txt, see http://nehe.gamedev.net/tutorial/fullscreen_antialiasing/16008/ for an example). This could give the appearance of line antialiasing, though I don't know why it would only work at some widths.

This could also just be a driver bug or bad line implementation in your graphics card. As I understand it, consumer graphics cards sometimes don't implement lines very well, since they're mostly used in CAD applications. You might try on another graphics card to see if you get the same results.