Results 1 to 7 of 7

Thread: GL_LINES looks weird

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2008
    Posts
    3

    GL_LINES looks weird

    hey,

    I'm trying to draw grid lines in 2d ortho. proj. where the ortho delta depends on user input value delta.

    the line width is 1.0f and all lines are in same color and 1.0f alpha but the lines look weird like some are light and some are dark, some has thickness of 2 pixels and some 1 pixel as shown in screenshot below.

    I tried all combinations of enabling and disabling Line and Point smoothing and alpha blending.

    I realized it can be because my orthographic delta isn't scaled with screen delta and my points aren't actually hitting the actual pixel values in terms of orthographic coordinates.

    is there a method to solve this problem?

    here comes the screenshot:


  2. #2
    Senior Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    346

    Re: GL_LINES looks weird

    Try thicker lines if you use line smoothing, something like 1.33 is good. They will all be a bit thicker, but look more consistent.

    You cay also try setting glHint to GL_NICEST, though I've never seen an implementation that differentiated the slightest between GL_FASTEST and NICEST.

    I you really want 1px wide lines, disable line smoothing and make sure you pass the right coordinates. Also check out the FAQ about line rasterization: http://www.opengl.org/resources/faq/...terization.htm

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2008
    Posts
    3

    Re: GL_LINES looks weird

    Quote Originally Posted by remdul
    I you really want 1px wide lines, disable line smoothing and make sure you pass the right coordinates.
    aw. it's ridiculous to adapt your mathematical equations to a graphics api instead of adapting the api to your maths.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    May 2006
    Posts
    701

    Re: GL_LINES looks weird

    Quote Originally Posted by Troxtril
    aw. it's ridiculous to adapt your mathematical equations to a graphics api instead of adapting the api to your maths.
    It isn't adapting to a graphics API but adapting to the reality of discrete raster graphics.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2008
    Posts
    3

    Re: GL_LINES looks weird

    Quote Originally Posted by Xmas
    It isn't adapting to a graphics API but adapting to the reality of discrete raster graphics.
    oh well.. I choose constant line attributes and it decides to create them in various widths and colors with no api-side correction just because my value range does not cover "discrete raster graphics'" reality range?

    what if it's a scientific project which should be error-free? oh I can see the newsflash on TV after space shuttle accident "Shocking Confession from Engineers: We considered PI as 3. discrete raster graphics..."

    btw this is not about you xmas. I'm just tired and angry. many thanks u both for trying to help.

  6. #6
    Senior Member Regular Contributor CatDog's Avatar
    Join Date
    Mar 2006
    Location
    Germany
    Posts
    226

    Re: GL_LINES looks weird

    You're kidding, aren't you?

    You don't have to adjust your value range, you simply have to align the scale of the grid to evenly fit display resolution.

    CatDog

  7. #7
    Senior Member Frequent Contributor
    Join Date
    May 2006
    Posts
    701

    Re: GL_LINES looks weird

    Quote Originally Posted by Troxtril
    oh well.. I choose constant line attributes and it decides to create them in various widths and colors with no api-side correction just because my value range does not cover "discrete raster graphics'" reality range?
    It is called antialiasing. A one pixel wide line at fractional coordinates should not look the same as a one pixel wide line on integer coordinates. You'd be ignoring position information.

    Your result looks like you have multisample antialiasing enabled. If you don't like what you get, you can either disable it or align your lines to the pixel grid.

    what if it's a scientific project which should be error-free? oh I can see the newsflash on TV after space shuttle accident "Shocking Confession from Engineers: We considered PI as 3. discrete raster graphics..."
    Mapping a continuous space to a discrete space (pixel raster) won't be error-free. The result you expect isn't more "correct" than the result you get at the moment.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

Similar Threads

  1. glDrawArrays(GL_LINES)
    By jonpb1 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-17-2012, 08:00 PM
  2. understanding GL_LINES
    By DanUK in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-21-2011, 10:48 AM
  3. Illuminating gl_lines
    By Dylan in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 12-17-2006, 02:03 AM
  4. GL_LINES
    By Luca in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-06-2002, 09:18 AM
  5. GL_LINES
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-30-2001, 07:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean