Results 1 to 5 of 5

Thread: Problems with lighting

  1. #1
    Member Contributor
    Join Date
    Nov 2000
    Location
    Thuringia, Germany
    Posts
    85

    Problems with lighting

    Hi!

    I have al little problem with Lighting.
    when i put a object on screen, colored red
    (
    glBegin(GL_TRIANGLES);
    glColor3f(1,0,0);glVertex3f(blah...);
    bla....
    )

    the triangle is displayed red. when i put a white lightsource in the scene, the object is displayed only black and white, independend of: normal, diffuse, secular, ambient values. (gl_smooth is on)
    the next problem is, if a triangle is on the same line (say, middle on z-axis, lightsource in 0,0,0) the triangle BEHIND this is also lighting.....?
    ligthing is my last big opengl-problem


    thanks for help,

    sebastian.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Problems with lighting

    Do you setup material properties, and not only light properties? glColor*() got no effect when lighing is on.

    And second, do you mean that you have two triangles in a row, and you expect the one close to the light to cast a shadow on the other one? If so, then forget it. No offense, but shadows is up to you do do. OpenGL draws whatever you want it to draw, and don't care about what has already been drawn or what will be drawn.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    5

    Re: Problems with lighting

    and the Normals???

    Before drawing the polygon you should give it a normal like this:
    glNormal3f(1.0f,0.0f,0.0f);
    This face is 'looking' to the dir X=1, Y=0, Z=0

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Caracas/Venezuela
    Posts
    182

    Re: Problems with lighting

    You can use glColor if you enable Color Material (see glEnable(GL_COLOR_MATERIAL)) instead of glMaterial, its easier to play with maybe.

    And yes, surface normals are absolutelly needed. You have to provide them, since opengl wont calculate them. GLU functions will generate normals for the GLU primitives if you ask for it.

  5. #5
    Member Contributor
    Join Date
    Nov 2000
    Location
    Thuringia, Germany
    Posts
    85

    Re: Problems with lighting

    Yeah, this helped a lot. i forgot to say that i use glNormals...

    btw: I'm now trying to make a shadow-system.

    Bastian.

Similar Threads

  1. Lighting Problems
    By TheRealSmolt in forum OpenGL: GLSL
    Replies: 3
    Last Post: 01-23-2019, 01:57 PM
  2. lighting problems
    By Lurking in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 12-31-2003, 12:30 PM
  3. Lighting problems
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-20-2003, 03:26 AM
  4. Lighting Problems
    By wpcmmx in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-03-2001, 11:34 AM
  5. Two Problems with Lighting
    By B. Jacob in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-10-2001, 03:29 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