Results 1 to 2 of 2

Thread: Not sure what's wrong

  1. #1

    Not sure what's wrong

    I have a problem with lighting

    If i change the view to the other side of the wall the normals are not defined.

    if key=1
    else if key=2
    side =side2

    draw ()
    If view = side 1
    normal nx,ny,nz
    normal -nx,-ny,-nz

    this is my logic

    only side 1 is working. the value of 'side' changes. but no change in normals

    where i went wrong?

    Also do i have to specify glNormal() inside GLbegin or outside??


  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000

    Re: Not sure what's wrong

    OpenGL does not figure out which side of a face is front by the normals at the vertices (there is no face normal!), but through the order in which the vertices are given.
    glFrontFace default is counter clockwise GL_CCW.

    To get the face lit from the backside you either need to change both, normal direction and vertex order, or you need to change the frontface winding direction and invert the normal, or you'll need to enable two sided lighting, disable face culling, and set back materials, too. OpenGL will invert the normal for you in case it finds a backfacing polygon and use the back material to light it.

    If you have only one normal for all vertices it's better to put it before the glBegin.

    [This message has been edited by Relic (edited 07-08-2003).]

Similar Threads

  1. something wrong with my vc++???
    By allen_dog in forum OpenGL: Windows
    Replies: 2
    Last Post: 02-11-2004, 02:40 PM
  2. What's wrong here??
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-10-2002, 04:32 AM
  3. HELP! What am I doing wrong?
    By Ketzal in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-07-2001, 05:44 AM
  4. What's wrong with this?
    By EvilGenius in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-05-2001, 06:20 PM

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