GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


opengl lightning problem by skyke
void CView::lightSettings( void ) {
    GLfloat light_diffuse []={ 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_ambient []={ 0.2, 0.2, 0.2, 1.0 };
    GLfloat light_spec []={ 1.0, 1.0, 1.0, 1.0 };
    GLfloat spot_direction[] = { 0.0, -1.0, 0.0 };
    
    glLightfv ( GL_LIGHT0, GL_AMBIENT_AND_DIFFUSE, light_diffuse );
    glLightfv ( GL_LIGHT0, GL_SPECULAR, light_spec );
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.0);
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0);
    glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0006);
    glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0);
    glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);

    GLfloat lmodel_ambient[] = { 0.0, 1.0, 0.0, 1.0 };
}

        lightSettings();
    glEnable( GL_LIGHTING );
    glEnable( GL_LIGHT0 );
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);
    glEnable( GL_POLYGON_SMOOTH ); 

        GLfloat light0_position [] = {0.0f, 0.0f, 0.0f, 1.0f};
    glLightfv ( GL_LIGHT0, GL_POSITION, light0_position );