Results 1 to 4 of 4

Thread: LIghting problem

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jul 2003
    Location
    Bangalore, Karnataka, India
    Posts
    123

    LIghting problem

    Dear All,

    I am renderng a move around a scene(using camera movement techniques). I have defined both ambient and position of the light in the scene.I want tthe light to be lit whereever we are moving in the scene. But I am not getting the desired effect. As I move around the scene,some parts are recieving the light and other parts are looking very dark.Moreover a polygon which have drawn(having blue color)
    is rendered with a black color. I am giving the necessary code given below.

    /* Light Declaration */
    static GLfloat lightpos[] =
    {1.0f,1.0f,1.0f,1.0f};
    GLfloat ambient[] = { 1.0, 1.0, 1.0, 1.0 };

    /* Light Definition */

    void renderscene( )
    {
    glLoadIdentity();
    gluLookAt(x, y, z,
    x + lx,y + ly,z + lz,
    0.0f,1.0f,0.0f);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0,GL_AMBIENT,ambient);
    glLightfv(GL_LIGHT0,GL_POSITION,lightpos);
    /* Here I am 100 x 100 Floor */
    /* Rest the code for code for other scenes */
    for( i = -10; i < 10; i++)
    for(int j = -10; j < 10; j++)
    {
    glPushMatrix();
    glTranslatef(5+i*10.0,0,5+j * 10.0);
    draw_house()
    }
    }

    kindly tell me how to create the light.

    Thanks

  2. #2
    Guest

    Re: LIghting problem

    Have you checked the normals?

  3. #3
    Guest

    Re: LIghting problem

    Either you're not defining normals, or the lighting is overriding something.

  4. #4
    Member Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: LIghting problem

    when you use lighting you cannot use glColor3f by default. to define colors - use glMaterial...
    but you can make it work if you call glEnable(GL_COLOR_MATERIAL);

Similar Threads

  1. Lighting problem
    By stefkos in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-09-2012, 11:36 AM
  2. Lighting problem,
    By dreamspaced in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-18-2005, 11:46 PM
  3. Replies: 4
    Last Post: 09-27-2004, 06:27 AM
  4. Odd problem with lighting...
    By Baltor in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-12-2004, 03:49 PM
  5. Lighting problem (opengl + shader lighting)
    By ox1d_47 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-19-2004, 09:43 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