Results 1 to 4 of 4

Thread: GL_LINES with lighting enabled

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    3

    GL_LINES with lighting enabled

    I'm rendering a scene containing several lines. With lighting disabled everything renders fine using calls to glColor for the line coloring.

    The problem comes when I enable lighting and call glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE). As I rotate the model (or the light) the lines intensity changes. Expected behavior but I want the lines to render with consistent intensity all around. Anyone know of a descent solution to keep GL_LINES intensity constant with lighting enabled?

  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: GL_LINES with lighting enabled

    Why not just disable lighting when you draw the lines?

    I am not trying to be unhelpful btw.. But what you describe wanting.. "constant intensity" is best achieved when you don't light an object.

    Other than that you are going to get some effect, or have to do some fiddling with material properties, which frankly seems a bit of a waste of time..

    Perhaps I didn't understand what you want.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    3

    Re: GL_LINES with lighting enabled

    Quote Originally Posted by scratt
    Why not just disable lighting when you draw the lines?
    Doh! Because I'm a idiot. I made the assumption that lights were either on or off and I wanted to mix surfaces with my lines. But that assumption was wrong. I just tested it and if I disable lighting when I render lines, and re-enable to render surfaces things work perfect. Appreciate your response, because it would have taken me a lot longer to figure that out without it.

  4. #4
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: GL_LINES with lighting enabled

    Glad it solved it for you. And btw, if I had a penny for every time I've missed something obvious, well.. I'd have a very big pile of pennies! That's all I am saying!

Similar Threads

  1. Vertex color with lighting enabled
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-05-2006, 05:22 PM
  2. GL_LINES
    By Luca in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-06-2002, 09:18 AM
  3. Lighting problem with fog and light enabled
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-11-2001, 11:36 PM
  4. GL_LINES
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-30-2001, 07:01 AM
  5. Grey polys when Lighting is enabled....
    By Khrob in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-23-2000, 10:28 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