Results 1 to 4 of 4

Thread: antoher boring question about lighting...

  1. #1
    Member Contributor
    Join Date
    Apr 2002
    Location
    kremnica, slovakia, europe, earth, sol :-)
    Posts
    99

    antoher boring question about lighting...

    ok... i started with gl some time ago and now, i've got a crazy idea to put some lighting to my code.....

    so i tried and it won't work! (what a surprise )... just everything seems to be black and white

    i tried to set up ligting using this code (stolen from nehe)

    GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 0.1f };
    GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 0.1f };
    GLfloat LightPosition[]= { -10.0f, 0.0f, -3.0f, 1.0f };
    GLfloat SceneAmbient[]= { 0.7f, 0.7f, 0.7f, 0.5f };

    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, SceneAmbient);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT1);

    what's wrong or what's missing?.... i'm sure normal vectors are good... i'm lost, i need your help...

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: antoher boring question about lighting...

    Have you set material properties? When using lighting, color is based on material properties rather than what you give to glColor. You can use glColorMaterial in order to make glColor change a particular material property, though.
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Huntsville, AL. USA
    Posts
    302

    Re: antoher boring question about lighting...

    Yup, u r missing some code ...

    Code :
    	GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
    	GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
    	GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    	GLfloat mat_shininess = 10.0f;
     
    	glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
    	glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
    	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    Obsessive - A word used by the lazy to describe the motivated.

  4. #4
    Member Contributor
    Join Date
    Apr 2002
    Location
    kremnica, slovakia, europe, earth, sol :-)
    Posts
    99

    Re: antoher boring question about lighting...

    tnx a lot, people.... now it's working well

Similar Threads

  1. EGL_BAD_ALLOC with eGLMakeCurrent on antoher window.
    By RungeKutta in forum OpenGL ES
    Replies: 1
    Last Post: 12-08-2008, 03:47 AM
  2. a boring problem
    By thunder2001 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-17-2004, 03:40 AM
  3. a boring problem
    By thunder2001 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-07-2004, 10:10 PM
  4. a boring problem
    By thunder2001 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-07-2004, 04:34 AM
  5. lighting question
    By schwinn in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-01-2002, 01: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